Package com.jetdrone.vertx.yoke.core

Examples of com.jetdrone.vertx.yoke.core.YokeException


                final Object field = get(request);
                final boolean optional = isOptional();

                // null is handled as a special case
                if (field == null) {
                    throw new YokeException(errorCode, "'" + path + "' cannot be NULL");
                }

                if (field instanceof Number) {
                    if (value.equals(field)) {
                        return;
                    }
                    throw new YokeException(errorCode, "'" + path + "' does not equal [" + value + "] be NULL");
                }
            }
        };
    }
View Full Code Here


            public void ok(final YokeRequest request) throws YokeException {

                final Object field = get(request);

                if (field == null) {
                    throw new YokeException(errorCode, "'" + path + "' cannot be NULL");
                }

                if (field instanceof String) {
                    if (DATETIME.matcher((CharSequence) field).matches()) {
                        Date date;
                        try {
                            date = DATEFORMAT.parse((String) field);
                        } catch (ParseException e) {
                            throw new YokeException(errorCode, "Failed to validate", e);
                        }
                        if (value.equals(date)) {
                            return;
                        }
                        throw new YokeException(errorCode, "'" + path + "' does not equal [" + value + "] be NULL");
                    }
                    if (DATE.matcher((CharSequence) field).matches()) {
                        Date date;
                        try {
                            date = DATEFORMAT.parse(field + "T00:00:00Z");
                        } catch (ParseException e) {
                            throw new YokeException(errorCode, "Failed to validate", e);
                        }
                        if (value.equals(date)) {
                            return;
                        }
                        throw new YokeException(errorCode, "'" + path + "' does not equal [" + value + "] be NULL");
                    }
                }
                // unknown
                throw new YokeException(errorCode, "Failed to validate");
            }
        };
    }
View Full Code Here

                final Object field = get(request);
                final boolean optional = isOptional();

                // null is handled as a special case
                if (field == null) {
                    throw new YokeException(errorCode, "'" + path + "' cannot be NULL");
                }

                if (field instanceof Boolean) {
                    if (value.equals(field)) {
                        return;
                    }
                    throw new YokeException(errorCode, "'" + path + "' does not equal [" + value + "] be NULL");
                }
            }
        };
    }
View Full Code Here

                final Object field = get(request);
                final boolean optional = isOptional();

                // null is handled as a special case
                if (field == null) {
                    throw new YokeException(errorCode, "'" + path + "' cannot be NULL");
                }

                if (field instanceof String) {
                    if (!value.equals(field)) {
                        return;
                    }
                    throw new YokeException(errorCode, "'" + path + "' does not equal [" + value + "] be NULL");
                }
            }
        };
    }
View Full Code Here

                final Object field = get(request);
                final boolean optional = isOptional();

                // null is handled as a special case
                if (field == null) {
                    throw new YokeException(errorCode, "'" + path + "' cannot be NULL");
                }

                if (field instanceof Number) {
                    if (!value.equals(field)) {
                        return;
                    }
                    throw new YokeException(errorCode, "'" + path + "' does not equal [" + value + "] be NULL");
                }
            }
        };
    }
View Full Code Here

            public void ok(final YokeRequest request) throws YokeException {

                final Object field = get(request);

                if (field == null) {
                    throw new YokeException(errorCode, "'" + path + "' cannot be NULL");
                }

                if (field instanceof String) {
                    if (DATETIME.matcher((CharSequence) field).matches()) {
                        Date date;
                        try {
                            date = DATEFORMAT.parse((String) field);
                        } catch (ParseException e) {
                            throw new YokeException(errorCode, "Failed to validate", e);
                        }
                        if (!value.equals(date)) {
                            return;
                        }
                        throw new YokeException(errorCode, "'" + path + "' does not equal [" + value + "] be NULL");
                    }
                    if (DATE.matcher((CharSequence) field).matches()) {
                        Date date;
                        try {
                            date = DATEFORMAT.parse(field + "T00:00:00Z");
                        } catch (ParseException e) {
                            throw new YokeException(errorCode, "Failed to validate", e);
                        }
                        if (!value.equals(date)) {
                            return;
                        }
                        throw new YokeException(errorCode, "'" + path + "' does not equal [" + value + "] be NULL");
                    }
                }
                // unknown
                throw new YokeException(errorCode, "Failed to validate");
            }
        };
    }
View Full Code Here

                final Object field = get(request);
                final boolean optional = isOptional();

                // null is handled as a special case
                if (field == null) {
                    throw new YokeException(errorCode, "'" + path + "' cannot be NULL");
                }

                if (field instanceof Boolean) {
                    if (!value.equals(field)) {
                        return;
                    }
                    throw new YokeException(errorCode, "'" + path + "' does not equal [" + value + "] be NULL");
                }
            }
        };
    }
View Full Code Here

                if (BEARER.matcher(scheme).matches()) {
                    token = credentials;
                }
            } else {
                next.handle(new YokeException(401, "Format is Authorization: Bearer [token]"));
                return;
            }
        } else {
            next.handle(new YokeException(401, "No Authorization header was found"));
            return;
        }

        try {
            final JsonObject jwtToken = jwt.decode(token);

            final long now = System.currentTimeMillis();

            if (jwtToken.containsField("iat")) {
                Long iat = jwtToken.getLong("iat");
                // issue at must be in the past
                if (iat >= now) {
                    next.handle(new YokeException(401, "Invalid Token!"));
                    return;
                }
            }

            if (jwtToken.containsField("nbf")) {
                Long nbf = jwtToken.getLong("nbf");
                // not before must be after now
                if (nbf >= now) {
                    next.handle(new YokeException(401, "Invalid Token!"));
                    return;
                }
            }

            if (jwtToken.containsField("exp")) {
                Long exp = jwtToken.getLong("exp");
                // expires must be after now
                if (now > exp) {
                    next.handle(new YokeException(401, "Invalid Token!"));
                    return;
                }
            }
            request.put("jwt", jwtToken);

            if (handler == null) {
                next.handle(null);
                return;
            }

            handler.handle(jwtToken, next);
        } catch (RuntimeException e) {
            next.handle(new YokeException(401, e));
        }
    }
View Full Code Here

TOP

Related Classes of com.jetdrone.vertx.yoke.core.YokeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.