@Singleton public class JwtTokenValidator extends Object implements TokenValidator
Modifier and Type | Field and Description |
---|---|
protected List<EncryptionConfiguration> |
encryptionConfigurations |
protected List<GenericJwtClaimsValidator> |
genericJwtClaimsValidators |
protected JwtAuthenticationFactory |
jwtAuthenticationFactory |
protected List<SignatureConfiguration> |
signatureConfigurations |
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
JwtTokenValidator(Collection<SignatureConfiguration> signatureConfigurations,
Collection<EncryptionConfiguration> encryptionConfigurations)
Deprecated.
|
JwtTokenValidator(Collection<SignatureConfiguration> signatureConfigurations,
Collection<EncryptionConfiguration> encryptionConfigurations,
Collection<GenericJwtClaimsValidator> genericJwtClaimsValidators,
JwtAuthenticationFactory jwtAuthenticationFactory)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Optional<Authentication> |
authenticationIfValidJwtSignatureAndClaims(String token,
Collection<? extends JwtClaimsValidator> claimsValidators)
Authentication if JWT has valid signature and claims are verified.
|
List<EncryptionConfiguration> |
getEncryptionConfigurations() |
List<GenericJwtClaimsValidator> |
getGenericJwtClaimsValidators() |
List<SignatureConfiguration> |
getSignatureConfigurations() |
Optional<com.nimbusds.jwt.JWT> |
parseJwtIfValidSignature(String token)
Retuns a JWT if the signature could be verified.
|
boolean |
validate(String token) |
boolean |
validate(String token,
Collection<? extends JwtClaimsValidator> claimsValidators) |
Optional<com.nimbusds.jwt.JWT> |
validateEncryptedJWTSignature(com.nimbusds.jwt.EncryptedJWT encryptedJWT,
String token)
Validates a encrypted JWT Signature.
|
Optional<com.nimbusds.jwt.JWT> |
validateJwtSignatureAndClaims(String token)
Validates JWT signature and Claims.
|
Optional<com.nimbusds.jwt.JWT> |
validateJwtSignatureAndClaims(String token,
Collection<? extends JwtClaimsValidator> claimsValidators)
Validates JWT signature and Claims.
|
Optional<com.nimbusds.jwt.JWT> |
validatePlainJWTSignature(com.nimbusds.jwt.JWT jwt)
Validates the Signature of a plain JWT.
|
Optional<com.nimbusds.jwt.JWT> |
validateSignedJWTSignature(com.nimbusds.jwt.SignedJWT signedJWT)
Validates a Signed JWT signature.
|
Publisher<Authentication> |
validateToken(String token)
Validates the provided token and returns the authentication state.
|
boolean |
verifyClaims(com.nimbusds.jwt.JWTClaimsSet jwtClaimsSet,
Collection<? extends JwtClaimsValidator> claimsValidators)
Verifies the provided claims with the provided validators.
|
protected final List<SignatureConfiguration> signatureConfigurations
protected final List<EncryptionConfiguration> encryptionConfigurations
protected final List<GenericJwtClaimsValidator> genericJwtClaimsValidators
protected final JwtAuthenticationFactory jwtAuthenticationFactory
@Inject public JwtTokenValidator(Collection<SignatureConfiguration> signatureConfigurations, Collection<EncryptionConfiguration> encryptionConfigurations, Collection<GenericJwtClaimsValidator> genericJwtClaimsValidators, JwtAuthenticationFactory jwtAuthenticationFactory)
signatureConfigurations
- List of Signature configurations which are used to attempt validation.encryptionConfigurations
- List of Encryption configurations which are used to attempt validation.genericJwtClaimsValidators
- Generic JWT Claims validators which should be used to validate any JWT.jwtAuthenticationFactory
- Utility to generate an Authentication given a JWT.@Deprecated public JwtTokenValidator(Collection<SignatureConfiguration> signatureConfigurations, Collection<EncryptionConfiguration> encryptionConfigurations)
JwtTokenValidator(Collection, Collection, Collection, JwtAuthenticationFactory)
instead.signatureConfigurations
- List of Signature configurations which are used to attempt validation.encryptionConfigurations
- List of Encryption configurations which are used to attempt validation.public Optional<com.nimbusds.jwt.JWT> validatePlainJWTSignature(com.nimbusds.jwt.JWT jwt)
jwt
- a JWT Tokenpublic Optional<com.nimbusds.jwt.JWT> validateSignedJWTSignature(com.nimbusds.jwt.SignedJWT signedJWT)
signedJWT
- a Signed JWT Tokenpublic boolean verifyClaims(com.nimbusds.jwt.JWTClaimsSet jwtClaimsSet, Collection<? extends JwtClaimsValidator> claimsValidators)
jwtClaimsSet
- JWT ClaimsclaimsValidators
- The claims validatorspublic Optional<com.nimbusds.jwt.JWT> validateEncryptedJWTSignature(com.nimbusds.jwt.EncryptedJWT encryptedJWT, String token)
encryptedJWT
- a encrytped JWT Tokentoken
- the JWT token as Stringpublic Publisher<Authentication> validateToken(String token)
TokenValidator
validateToken
in interface TokenValidator
token
- The token string.Authentication
based on the JWT or empty if the validation fails.public Optional<Authentication> authenticationIfValidJwtSignatureAndClaims(String token, Collection<? extends JwtClaimsValidator> claimsValidators)
token
- A JWT tokenclaimsValidators
- a Collection of claims Validators.public Optional<com.nimbusds.jwt.JWT> validateJwtSignatureAndClaims(String token)
token
- A JWT tokenpublic boolean validate(String token)
token
- A JWT tokenpublic boolean validate(String token, Collection<? extends JwtClaimsValidator> claimsValidators)
token
- A JWT tokenclaimsValidators
- a Collection of claims Validators.public Optional<com.nimbusds.jwt.JWT> validateJwtSignatureAndClaims(String token, Collection<? extends JwtClaimsValidator> claimsValidators)
token
- A JWT tokenclaimsValidators
- a Collection of claims Validators.public Optional<com.nimbusds.jwt.JWT> parseJwtIfValidSignature(String token)
token
- a JWT tokenpublic List<SignatureConfiguration> getSignatureConfigurations()
public List<EncryptionConfiguration> getEncryptionConfigurations()
public List<GenericJwtClaimsValidator> getGenericJwtClaimsValidators()