@ThreadSafe public class DefaultJWTClaimsVerifier<C extends SecurityContext> extends Object implements JWTClaimsSetVerifier<C>, JWTClaimsVerifier, ClockSkewAware
JWT claims verifier
implementation. This class
is thread-safe.
Performs the following checks:
This class may be extended to perform additional checks.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_CLOCK_SKEW_SECONDS
The default maximum acceptable clock skew, in seconds (60).
|
Constructor and Description |
---|
DefaultJWTClaimsVerifier()
Creates a new JWT claims verifier.
|
DefaultJWTClaimsVerifier(JWTClaimsSet exactMatchClaims,
Set<String> requiredClaims)
Creates a new JWT claims verifier.
|
DefaultJWTClaimsVerifier(Set<String> acceptedAudience,
JWTClaimsSet exactMatchClaims,
Set<String> requiredClaims,
Set<String> prohibitedClaims)
Creates new default JWT claims verifier.
|
DefaultJWTClaimsVerifier(String requiredAudience,
JWTClaimsSet exactMatchClaims,
Set<String> requiredClaims)
Creates new default JWT claims verifier.
|
Modifier and Type | Method and Description |
---|---|
Set<String> |
getAcceptedAudienceValues()
Returns the accepted audience values.
|
JWTClaimsSet |
getExactMatchClaims()
Returns the JWT claims that must match exactly.
|
int |
getMaxClockSkew()
Gets the maximum acceptable clock skew.
|
Set<String> |
getProhibitedClaims()
Returns the names of the JWT claims that must not be present.
|
Set<String> |
getRequiredClaims()
Returns the names of the JWT claims that must be present, including
the name of those that must match exactly.
|
void |
setMaxClockSkew(int maxClockSkewSeconds)
Sets the maximum acceptable clock skew.
|
void |
verify(JWTClaimsSet claimsSet)
Performs verification of selected or all claims in the specified JWT
claims set.
|
void |
verify(JWTClaimsSet claimsSet,
C context)
Verifies selected or all claims from the specified JWT claims set.
|
public static final int DEFAULT_MAX_CLOCK_SKEW_SECONDS
public DefaultJWTClaimsVerifier()
public DefaultJWTClaimsVerifier(JWTClaimsSet exactMatchClaims, Set<String> requiredClaims)
exactMatchClaims
- The JWT claims that must match exactly,
null
if none.requiredClaims
- The names of the JWT claims that must be
present, empty set or null
if none.public DefaultJWTClaimsVerifier(String requiredAudience, JWTClaimsSet exactMatchClaims, Set<String> requiredClaims)
requiredAudience
- The required JWT audience, null
if
not specified.exactMatchClaims
- The JWT claims that must match exactly,
null
if none.requiredClaims
- The names of the JWT claims that must be
present, empty set or null
if none.public DefaultJWTClaimsVerifier(Set<String> acceptedAudience, JWTClaimsSet exactMatchClaims, Set<String> requiredClaims, Set<String> prohibitedClaims)
acceptedAudience
- The accepted JWT audience values,
null
if not specified. A
null
value in the set allows JWTs
with no audience.exactMatchClaims
- The JWT claims that must match exactly,
null
if none.requiredClaims
- The names of the JWT claims that must be
present, empty set or null
if none.prohibitedClaims
- The names of the JWT claims that must not be
present, empty set or null
if none.public Set<String> getAcceptedAudienceValues()
null
if not
specified. A null
value in the set allows JWTs with
no audience.public JWTClaimsSet getExactMatchClaims()
public Set<String> getRequiredClaims()
public Set<String> getProhibitedClaims()
public int getMaxClockSkew()
ClockSkewAware
getMaxClockSkew
in interface ClockSkewAware
public void setMaxClockSkew(int maxClockSkewSeconds)
ClockSkewAware
setMaxClockSkew
in interface ClockSkewAware
maxClockSkewSeconds
- The maximum acceptable clock skew, in
seconds. Zero if none.public void verify(JWTClaimsSet claimsSet) throws BadJWTException
JWTClaimsVerifier
verify
in interface JWTClaimsVerifier
claimsSet
- The JWT claims set. Not null
.BadJWTException
- If the JWT claims set is rejected.public void verify(JWTClaimsSet claimsSet, C context) throws BadJWTException
JWTClaimsSetVerifier
verify
in interface JWTClaimsSetVerifier<C extends SecurityContext>
claimsSet
- The JWT claims set. Not null
.context
- Optional context, null
if not required.BadJWTException
- If the JWT claims set is rejected.Copyright © 2019 Connect2id Ltd.. All rights reserved.