private Map<String, Object> validateJwt(String token, JWTPolicyBean config)
            throws ExpiredJwtException, PrematureJwtException, MalformedJwtException, SignatureException, InvalidClaimException {
        // check if we have to use jwk(s)
        if (urlValidator.isValid(config.getSigningKeyString())){
            if (provider == null){
                provider = getNewJwksProvider(config.getSigningKeyString());
            }
            Jwk jwk;
            try {
                jwk = provider.get(config.getKid());
                if (config.getSigningKey() == null || !(config.getSigningKey().equals(jwk.getPublicKey()))) {
                    config.setSigningKey(jwk.getPublicKey());
                }
            } catch (JwkException e) {
               throw new SignatureException("JWK was not found with kid: " + config.getKid(), e);
            }
        }
        JwtParser parser = Jwts.parser()
                .setSigningKey(config.getSigningKey())
                .setAllowedClockSkewSeconds(config.getAllowedClockSkew());
        // Set all claims
        config.getRequiredClaims().stream() // TODO add type variable to allow dates, etc
            .forEach(requiredClaim -> parser.require(requiredClaim.getClaimName(), requiredClaim.getClaimValue()));
        return parser.parse(token, new ConfigCheckingJwtHandler(config));
    }
private Map<String, Object> validateJwt(String token, JWTPolicyBean config)
            throws ExpiredJwtException, PrematureJwtException, MalformedJwtException, SignatureException, InvalidClaimException {
       
        if (urlValidator.isValid(config.getSigningKeyString())){
            if (provider == null){
                provider = getNewJwksProvider(config.getSigningKeyString());
            }
            Jwk jwk;
            try {
                jwk = provider.get(config.getKid());
                if (config.getSigningKey() == null || !(config.getSigningKey().equals(jwk.getPublicKey()))) {
                    config.setSigningKey(jwk.getPublicKey());
                }
            } catch (JwkException e) {
               throw new SignatureException("JWK was not found with kid: " + config.getKid(), e);
            }
        }
        JwtParser parser = Jwts.parser()
                .setSigningKey(config.getSigningKey())
                .setAllowedClockSkewSeconds(config.getAllowedClockSkew());
       
        config.getRequiredClaims().stream()
            .forEach(requiredClaim -> parser.require(requiredClaim.getClaimName(), requiredClaim.getClaimValue()));
        return parser.parse(token, new ConfigCheckingJwtHandler(config));
    }
private map<string, object> validatejwt(string token, jwtpolicybean config) throws expiredjwtexception, prematurejwtexception, malformedjwtexception, signatureexception, invalidclaimexception { if (urlvalidator.isvalid(config.getsigningkeystring())){ if (provider == null){ provider = getnewjwksprovider(config.getsigningkeystring()); } jwk jwk; try { jwk = provider.get(config.getkid()); if (config.getsigningkey() == null || !(config.getsigningkey().equals(jwk.getpublickey()))) { config.setsigningkey(jwk.getpublickey()); } } catch (jwkexception e) { throw new signatureexception("jwk was not found with kid: " + config.getkid(), e); } } jwtparser parser = jwts.parser() .setsigningkey(config.getsigningkey()) .setallowedclockskewseconds(config.getallowedclockskew()); config.getrequiredclaims().stream() .foreach(requiredclaim -> parser.require(requiredclaim.getclaimname(), requiredclaim.getclaimvalue())); return parser.parse(token, new configcheckingjwthandler(config)); }