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 class
The Verification class holds the Claims required by a JWT to be valid. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
assertDateIsFuture
(Date date, long leeway, Date today) private void
assertDateIsPast
(Date date, long leeway, Date today) private void
assertValidAudienceClaim
(List<String> audience, List<String> value) private void
assertValidClaim
(Claim claim, String claimName, Object value) private void
assertValidDateClaim
(Date date, long leeway, boolean shouldBeFuture) private void
assertValidIssuerClaim
(String issuer, List<String> value) private void
assertValidStringClaim
(String claimName, String value, String expectedValue) (package private) static Verification
Initialize 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 void
verifyAlgorithm
(DecodedJWT jwt, Algorithm expectedAlgorithm) private void
verifyClaims
(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:
verify
in 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:
verify
in 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
-