Package com.auth0.jwt
Class JWTVerifier.BaseVerification
java.lang.Object
com.auth0.jwt.JWTVerifier.BaseVerification
- All Implemented Interfaces:
Verification
- Enclosing class:
- JWTVerifier
-
Method Summary
Modifier and TypeMethodDescriptionacceptExpiresAt(long leeway)
Set a specific leeway window in seconds in which the Expires At ("exp") Claim will still be valid.acceptIssuedAt(long leeway)
Set a specific leeway window in seconds in which the Issued At ("iat") Claim will still be valid.acceptLeeway(long leeway)
Define the default window in seconds in which the Not Before, Issued At and Expires At Claims will still be valid.acceptNotBefore(long leeway)
Set a specific leeway window in seconds in which the Not Before ("nbf") Claim will still be valid.build()
Creates a new and reusable instance of the JWTVerifier with the configuration already provided.Creates a new and reusable instance of the JWTVerifier with the configuration already provided.Skip the Issued At ("iat") date verification.withAnyOfAudience(String... audience)
Require that the Audience ("aud") claim contain at least one of the specified audiences.withArrayClaim(String name, Integer... items)
Require a specific Array Claim to contain at least the given items.withArrayClaim(String name, Long... items)
Require a specific Array Claim to contain at least the given items.withArrayClaim(String name, String... items)
Require a specific Array Claim to contain at least the given items.withAudience(String... audience)
Require a specific Audience ("aud") claim.Require a specific Claim value.Require a specific Claim value.Require a specific Claim value.Require a specific Claim value.Require a specific Claim value.Require a specific Claim value.withClaimPresence(String name)
Require a claim to be present, with any value.withIssuer(String... issuer)
Require a specific Issuer ("iss") claim.Require a specific JWT Id ("jti") claim.withSubject(String subject)
Require a specific Subject ("sub") claim.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.auth0.jwt.interfaces.Verification
withIssuer
-
Method Details
-
withIssuer
Description copied from interface:Verification
Require a specific Issuer ("iss") claim.- Specified by:
withIssuer
in interfaceVerification
- Parameters:
issuer
- the required Issuer value. If multiple values are given, the claim must at least match one of them- Returns:
- this same Verification instance.
-
withSubject
Description copied from interface:Verification
Require a specific Subject ("sub") claim.- Specified by:
withSubject
in interfaceVerification
- Parameters:
subject
- the required Subject value- Returns:
- this same Verification instance.
-
withAudience
Description copied from interface:Verification
Require a specific Audience ("aud") claim. If multiple audiences are specified, they must all be present in the "aud" claim. If this is used in conjunction withVerification.withAnyOfAudience(String...)
, whichever one is configured last will determine the audience validation behavior.- Specified by:
withAudience
in interfaceVerification
- Parameters:
audience
- the required Audience value- Returns:
- this same Verification instance.
-
withAnyOfAudience
Description copied from interface:Verification
Require that the Audience ("aud") claim contain at least one of the specified audiences. If this is used in conjunction withVerification.withAudience(String...)
, whichever one is configured last will determine the audience validation behavior. Note: This method was added after the interface was released. It is defined as a default method for compatibility reasons. From version 4.0 on, the method will be abstract and all implementations of this interface will have to provide their own implementation. The default implementation throws an UnsupportedOperationException.- Specified by:
withAnyOfAudience
in interfaceVerification
- Parameters:
audience
- the required Audience value for which the "aud" claim must contain at least one value.- Returns:
- this same Verification instance.
-
acceptLeeway
Description copied from interface:Verification
Define the default window in seconds in which the Not Before, Issued At and Expires At Claims will still be valid. Setting a specific leeway value on a given Claim will override this value for that Claim.- Specified by:
acceptLeeway
in interfaceVerification
- Parameters:
leeway
- the window in seconds in which the Not Before, Issued At and Expires At Claims will still be valid.- Returns:
- this same Verification instance.
- Throws:
IllegalArgumentException
- if leeway is negative.
-
acceptExpiresAt
Description copied from interface:Verification
Set a specific leeway window in seconds in which the Expires At ("exp") Claim will still be valid. Expiration Date is always verified when the value is present. This method overrides the value set with acceptLeeway- Specified by:
acceptExpiresAt
in interfaceVerification
- Parameters:
leeway
- the window in seconds in which the Expires At Claim will still be valid.- Returns:
- this same Verification instance.
- Throws:
IllegalArgumentException
- if leeway is negative.
-
acceptNotBefore
Description copied from interface:Verification
Set a specific leeway window in seconds in which the Not Before ("nbf") Claim will still be valid. Not Before Date is always verified when the value is present. This method overrides the value set with acceptLeeway- Specified by:
acceptNotBefore
in interfaceVerification
- Parameters:
leeway
- the window in seconds in which the Not Before Claim will still be valid.- Returns:
- this same Verification instance.
- Throws:
IllegalArgumentException
- if leeway is negative.
-
acceptIssuedAt
Description copied from interface:Verification
Set a specific leeway window in seconds in which the Issued At ("iat") Claim will still be valid. This method overrides the value set withVerification.acceptLeeway(long)
. By default, the Issued At claim is always verified when the value is present, unless disabled withVerification.ignoreIssuedAt()
. If Issued At verification has been disabled, no verification of the Issued At claim will be performed, and this method has no effect.- Specified by:
acceptIssuedAt
in interfaceVerification
- Parameters:
leeway
- the window in seconds in which the Issued At Claim will still be valid.- Returns:
- this same Verification instance.
- Throws:
IllegalArgumentException
- if leeway is negative.
-
ignoreIssuedAt
Description copied from interface:Verification
Skip the Issued At ("iat") date verification. By default, the verification is performed.- Specified by:
ignoreIssuedAt
in interfaceVerification
- Returns:
- this same Verification instance.
-
withJWTId
Description copied from interface:Verification
Require a specific JWT Id ("jti") claim.- Specified by:
withJWTId
in interfaceVerification
- Parameters:
jwtId
- the required Id value- Returns:
- this same Verification instance.
-
withClaimPresence
Description copied from interface:Verification
Require a claim to be present, with any value.- Specified by:
withClaimPresence
in interfaceVerification
- Parameters:
name
- the Claim's name.- Returns:
- this same Verification instance
- Throws:
IllegalArgumentException
- if the name is null.
-
withClaim
Description copied from interface:Verification
Require a specific Claim value.- Specified by:
withClaim
in interfaceVerification
- Parameters:
name
- the Claim's name.value
- the Claim's value.- Returns:
- this same Verification instance.
- Throws:
IllegalArgumentException
- if the name is null.
-
withClaim
Description copied from interface:Verification
Require a specific Claim value.- Specified by:
withClaim
in interfaceVerification
- Parameters:
name
- the Claim's name.value
- the Claim's value.- Returns:
- this same Verification instance.
- Throws:
IllegalArgumentException
- if the name is null.
-
withClaim
Description copied from interface:Verification
Require a specific Claim value.- Specified by:
withClaim
in interfaceVerification
- Parameters:
name
- the Claim's name.value
- the Claim's value.- Returns:
- this same Verification instance.
- Throws:
IllegalArgumentException
- if the name is null.
-
withClaim
Description copied from interface:Verification
Require a specific Claim value.- Specified by:
withClaim
in interfaceVerification
- Parameters:
name
- the Claim's name.value
- the Claim's value.- Returns:
- this same Verification instance.
- Throws:
IllegalArgumentException
- if the name is null.
-
withClaim
Description copied from interface:Verification
Require a specific Claim value.- Specified by:
withClaim
in interfaceVerification
- Parameters:
name
- the Claim's name.value
- the Claim's value.- Returns:
- this same Verification instance.
- Throws:
IllegalArgumentException
- if the name is null.
-
withClaim
Description copied from interface:Verification
Require a specific Claim value.- Specified by:
withClaim
in interfaceVerification
- Parameters:
name
- the Claim's name.value
- the Claim's value.- Returns:
- this same Verification instance.
- Throws:
IllegalArgumentException
- if the name is null.
-
withArrayClaim
Description copied from interface:Verification
Require a specific Array Claim to contain at least the given items.- Specified by:
withArrayClaim
in interfaceVerification
- Parameters:
name
- the Claim's name.items
- the items the Claim must contain.- Returns:
- this same Verification instance.
- Throws:
IllegalArgumentException
- if the name is null.
-
withArrayClaim
Description copied from interface:Verification
Require a specific Array Claim to contain at least the given items.- Specified by:
withArrayClaim
in interfaceVerification
- Parameters:
name
- the Claim's name.items
- the items the Claim must contain.- Returns:
- this same Verification instance.
- Throws:
IllegalArgumentException
- if the name is null.
-
withArrayClaim
Description copied from interface:Verification
Require a specific Array Claim to contain at least the given items.- Specified by:
withArrayClaim
in interfaceVerification
- Parameters:
name
- the Claim's name.items
- the items the Claim must contain.- Returns:
- this same Verification instance.
- Throws:
IllegalArgumentException
- if the name is null.
-
build
Description copied from interface:Verification
Creates a new and reusable instance of the JWTVerifier with the configuration already provided.- Specified by:
build
in interfaceVerification
- Returns:
- a new JWTVerifier instance.
-
build
Creates a new and reusable instance of the JWTVerifier with the configuration already provided. ONLY FOR TEST PURPOSES.- Parameters:
clock
- the instance that will handle the current time.- Returns:
- a new JWTVerifier instance with a custom Clock.
-