Class JWTVerifier


  • public final class JWTVerifier
    extends Object
    Helper class to verify JWTs.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.auth0.jwt.interfaces.DecodedJWT verify​(com.auth0.jwt.interfaces.DecodedJWT jwt, List<String> claimConstraints, com.auth0.jwt.algorithms.Algorithm... algorithms)
      Verifies a given decoded JWT with the given claim constraints and algorithms.
      static com.auth0.jwt.interfaces.DecodedJWT verify​(com.auth0.jwt.interfaces.DecodedJWT jwt, List<String> claimConstraints, List<com.auth0.jwt.algorithms.Algorithm> algorithms)
      Verifies a given decoded JWT with the given claim constraints and algorithms.
      static com.auth0.jwt.interfaces.DecodedJWT verify​(String token, String secret, List<String> claimConstraints)
      Verifies a given JWT string with a secret and given claim constraints.
      static com.auth0.jwt.interfaces.DecodedJWT verify​(String token, GuavaCachedUrlJwkProvider provider, List<String> claimConstraints)
      Verifies a given JWT string with a given JWK provider and given claim constraints.
    • Method Detail

      • verify

        public static com.auth0.jwt.interfaces.DecodedJWT verify​(String token,
                                                                 GuavaCachedUrlJwkProvider provider,
                                                                 List<String> claimConstraints)
                                                          throws com.auth0.jwk.JwkException
        Verifies a given JWT string with a given JWK provider and given claim constraints.
        Parameters:
        token - The JWT string.
        provider - The JWK provider.
        claimConstraints - The claim constraints.
        Returns:
        The decoded and verified JWT.
        Throws:
        com.auth0.jwk.JwkException - If the JWT cannot be verified successfully.
      • verify

        public static com.auth0.jwt.interfaces.DecodedJWT verify​(String token,
                                                                 String secret,
                                                                 List<String> claimConstraints)
                                                          throws com.auth0.jwt.exceptions.JWTVerificationException
        Verifies a given JWT string with a secret and given claim constraints.
        Parameters:
        token - The JWT string.
        secret - The secret.
        claimConstraints - The claim constraints.
        Returns:
        The decoded and verified JWT.
        Throws:
        com.auth0.jwt.exceptions.JWTVerificationException - If the JWT cannot be verified successfully.
      • verify

        public static com.auth0.jwt.interfaces.DecodedJWT verify​(com.auth0.jwt.interfaces.DecodedJWT jwt,
                                                                 List<String> claimConstraints,
                                                                 List<com.auth0.jwt.algorithms.Algorithm> algorithms)
                                                          throws com.auth0.jwt.exceptions.JWTVerificationException
        Verifies a given decoded JWT with the given claim constraints and algorithms. The verification has to be successful with at least one provided algorithm. Otherwise a JWTVerificationException is thrown.
        Parameters:
        jwt - The decoded JWT.
        claimConstraints - The claim constraints.
        algorithms - The algorithms.
        Returns:
        The decoded and verified JWT.
        Throws:
        com.auth0.jwt.exceptions.JWTVerificationException - If the JWT cannot be verified successfully.
      • verify

        public static com.auth0.jwt.interfaces.DecodedJWT verify​(com.auth0.jwt.interfaces.DecodedJWT jwt,
                                                                 List<String> claimConstraints,
                                                                 com.auth0.jwt.algorithms.Algorithm... algorithms)
                                                          throws com.auth0.jwt.exceptions.JWTVerificationException
        Verifies a given decoded JWT with the given claim constraints and algorithms. The verification has to be successful with at least one provided algorithm. Otherwise a JWTVerificationException is thrown.
        Parameters:
        jwt - The decoded JWT.
        claimConstraints - The claim constraints.
        algorithms - The algorithms.
        Returns:
        The decoded and verified JWT.
        Throws:
        com.auth0.jwt.exceptions.JWTVerificationException - If the JWT cannot be verified successfully.