Package com.auth0.jwt
Class JWTVerifier
java.lang.Object
com.auth0.jwt.JWTVerifier
- All Implemented Interfaces:
JWTVerifier
The JWTVerifier class holds the verify method to assert that a given Token has not only a proper JWT format, but also it's signature matches.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe Verification class holds the Claims required by a JWT to be valid. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidassertDateIsFuture(Date date, long leeway, Date today) private voidassertDateIsPast(Date date, long leeway, Date today) private voidassertValidAudienceClaim(List<String> audience, List<String> value) private voidassertValidClaim(Claim claim, String claimName, Object value) private voidassertValidDateClaim(Date date, long leeway, boolean shouldBeFuture) private voidassertValidIssuerClaim(String issuer, List<String> value) private voidassertValidStringClaim(String claimName, String value, String expectedValue) (package private) static VerificationInitialize a JWTVerifier instance using the given Algorithm.verify(DecodedJWT jwt) Perform the verification against the given decoded JWT, using any previous configured options.Perform the verification against the given Token, using any previous configured options.private voidverifyAlgorithm(DecodedJWT jwt, Algorithm expectedAlgorithm) private voidverifyClaims(DecodedJWT jwt, Map<String, Object> claims)
-
Field Details
-
algorithm
-
claims
-
clock
-
parser
-
-
Constructor Details
-
JWTVerifier
-
-
Method Details
-
init
Initialize a JWTVerifier instance using the given Algorithm.- Parameters:
algorithm- the Algorithm to use on the JWT verification.- Returns:
- a JWTVerifier.Verification instance to configure.
- Throws:
IllegalArgumentException- if the provided algorithm is null.
-
verify
Perform the verification against the given Token, using any previous configured options.- Specified by:
verifyin interfaceJWTVerifier- Parameters:
token- to verify.- Returns:
- a verified and decoded JWT.
- Throws:
AlgorithmMismatchException- if the algorithm stated in the token's header it's not equal to the one defined in theJWTVerifier.SignatureVerificationException- if the signature is invalid.TokenExpiredException- if the token has expired.InvalidClaimException- if a claim contained a different value than the expected one.JWTVerificationException- if any of the verification steps fail
-
verify
Perform the verification against the given decoded JWT, using any previous configured options.- Specified by:
verifyin interfaceJWTVerifier- Parameters:
jwt- to verify.- Returns:
- a verified and decoded JWT.
- Throws:
AlgorithmMismatchException- if the algorithm stated in the token's header it's not equal to the one defined in theJWTVerifier.SignatureVerificationException- if the signature is invalid.TokenExpiredException- if the token has expired.InvalidClaimException- if a claim contained a different value than the expected one.JWTVerificationException- if any of the verification steps fail
-
verifyAlgorithm
private void verifyAlgorithm(DecodedJWT jwt, Algorithm expectedAlgorithm) throws AlgorithmMismatchException - Throws:
AlgorithmMismatchException
-
verifyClaims
private void verifyClaims(DecodedJWT jwt, Map<String, Object> claims) throws TokenExpiredException, InvalidClaimException -
assertValidClaim
-
assertValidStringClaim
-
assertValidDateClaim
-
assertDateIsFuture
-
assertDateIsPast
-
assertValidAudienceClaim
-
assertValidIssuerClaim
-