void validate(JwtContext jwtCtx) throws InvalidJwtException { List<ErrorCodeValidator.Error> issues = new ArrayList<>(); for (ErrorCodeValidator validator : validators) { ErrorCodeValidator.Error error; try { error = validator.validate(jwtCtx); } catch (MalformedClaimException e) { error = new ErrorCodeValidator.Error(MALFORMED_CLAIM, e.getMessage()); } catch (Exception e) { String msg = "Unexpected exception thrown from validator " + validator.getClass().getName() + ": " + ExceptionHelp.toStringWithCausesAndAbbreviatedStack(e, this.getClass()); error = new ErrorCodeValidator.Error(MISCELLANEOUS, msg); } if (error != null) { issues.add(error); } } if (!issues.isEmpty()) { String msg = "JWT (claims->" + jwtCtx.getJwtClaims().getRawJson() + ") rejected due to invalid claims."; throw new InvalidJwtException(msg, issues, jwtCtx); } }