public static boolean isValidJWToken(String secret, SignedJWT jwt) {
		try {
			if (secret != null && jwt != null) {
				JWSVerifier verifier = new MACVerifier(secret);
				if (jwt.verify(verifier)) {
					Date referenceTime = new Date();
					JWTClaimsSet claims = jwt.getJWTClaimsSet();

					Date expirationTime = claims.getExpirationTime();
					Date notBeforeTime = claims.getNotBeforeTime();
					boolean expired = expirationTime == null || expirationTime.before(referenceTime);
					boolean notYetValid = notBeforeTime == null || notBeforeTime.after(referenceTime);

					return !(expired || notYetValid);
				}
			}
		} catch (JOSEException e) {
			logger.warn(null, e);
		} catch (ParseException ex) {
			logger.warn(null, ex);
		}
		return false;
	}
public static boolean isValidJWToken ( String secret , SignedJWT jwt ) { try { if ( secret != null && jwt != null ) { JWSVerifier verifier = new MACVerifier ( secret ) ; if ( jwt . verify ( verifier ) ) { Date referenceTime = new Date ( ) ; JWTClaimsSet claims = jwt . getJWTClaimsSet ( ) ; Date expirationTime = claims . getExpirationTime ( ) ; Date notBeforeTime = claims . getNotBeforeTime ( ) ; boolean expired = expirationTime == null || expirationTime . before ( referenceTime ) ; boolean notYetValid = notBeforeTime == null || notBeforeTime . after ( referenceTime ) ; return ! ( expired || notYetValid ) ; } } } catch ( JOSEException e ) { logger . warn ( null , e ) ; } catch ( ParseException ex ) { logger . warn ( null , ex ) ; } return false ; }
Validates a JWT token.
@param secret secret used for generating the token
@param jwt token to validate
@return true if token is valid