@Singleton public class JwtTokenValidator extends java.lang.Object implements TokenValidator
Modifier and Type | Field and Description |
---|---|
protected java.util.List<EncryptionConfiguration> |
encryptionConfigurations |
protected java.util.List<GenericJwtClaimsValidator> |
genericJwtClaimsValidators |
protected JwtAuthenticationFactory |
jwtAuthenticationFactory |
protected java.util.List<SignatureConfiguration> |
signatureConfigurations |
Constructor and Description |
---|
JwtTokenValidator(java.util.Collection<SignatureConfiguration> signatureConfigurations,
java.util.Collection<EncryptionConfiguration> encryptionConfigurations)
Deprecated.
|
JwtTokenValidator(java.util.Collection<SignatureConfiguration> signatureConfigurations,
java.util.Collection<EncryptionConfiguration> encryptionConfigurations,
java.util.Collection<GenericJwtClaimsValidator> genericJwtClaimsValidators,
JwtAuthenticationFactory jwtAuthenticationFactory)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.util.Optional<Authentication> |
authenticationIfValidJwtSignatureAndClaims(java.lang.String token,
java.util.Collection<? extends JwtClaimsValidator> claimsValidators)
Authentication if JWT has valid signature and claims are verified.
|
java.util.List<EncryptionConfiguration> |
getEncryptionConfigurations() |
java.util.List<GenericJwtClaimsValidator> |
getGenericJwtClaimsValidators() |
java.util.List<SignatureConfiguration> |
getSignatureConfigurations() |
java.util.Optional<com.nimbusds.jwt.JWT> |
parseJwtIfValidSignature(java.lang.String token)
|
boolean |
validate(java.lang.String token) |
boolean |
validate(java.lang.String token,
java.util.Collection<? extends JwtClaimsValidator> claimsValidators) |
java.util.Optional<com.nimbusds.jwt.JWT> |
validateEncryptedJWTSignature(com.nimbusds.jwt.EncryptedJWT encryptedJWT,
java.lang.String token)
|
java.util.Optional<com.nimbusds.jwt.JWT> |
validateJwtSignatureAndClaims(java.lang.String token)
Validates JWT signature and Claims.
|
java.util.Optional<com.nimbusds.jwt.JWT> |
validateJwtSignatureAndClaims(java.lang.String token,
java.util.Collection<? extends JwtClaimsValidator> claimsValidators)
Deprecated.
|
java.util.Optional<com.nimbusds.jwt.JWT> |
validatePlainJWTSignature(com.nimbusds.jwt.JWT jwt)
Validates the Signature of a plain JWT.
|
java.util.Optional<com.nimbusds.jwt.JWT> |
validateSignedJWTSignature(com.nimbusds.jwt.SignedJWT signedJWT)
Validates a Signed JWT signature.
|
org.reactivestreams.Publisher<Authentication> |
validateToken(java.lang.String token)
Validates the provided token and returns the authentication state.
|
boolean |
verifyClaims(com.nimbusds.jwt.JWTClaimsSet jwtClaimsSet,
java.util.Collection<? extends JwtClaimsValidator> claimsValidators)
|
protected final java.util.List<SignatureConfiguration> signatureConfigurations
protected final java.util.List<EncryptionConfiguration> encryptionConfigurations
protected final java.util.List<GenericJwtClaimsValidator> genericJwtClaimsValidators
protected final JwtAuthenticationFactory jwtAuthenticationFactory
@Inject public JwtTokenValidator(java.util.Collection<SignatureConfiguration> signatureConfigurations, java.util.Collection<EncryptionConfiguration> encryptionConfigurations, java.util.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(java.util.Collection<SignatureConfiguration> signatureConfigurations, java.util.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 java.util.Optional<com.nimbusds.jwt.JWT> validatePlainJWTSignature(com.nimbusds.jwt.JWT jwt)
jwt
- a JWT Tokenpublic java.util.Optional<com.nimbusds.jwt.JWT> validateSignedJWTSignature(com.nimbusds.jwt.SignedJWT signedJWT)
signedJWT
- a Signed JWT Token@Deprecated public boolean verifyClaims(com.nimbusds.jwt.JWTClaimsSet jwtClaimsSet, java.util.Collection<? extends JwtClaimsValidator> claimsValidators)
JwtTokenValidatorUtils.verifyClaims(io.micronaut.security.token.jwt.generator.claims.JwtClaims, Collection)
instead.jwtClaimsSet
- JWT ClaimsclaimsValidators
- The claims validators@Deprecated public java.util.Optional<com.nimbusds.jwt.JWT> validateEncryptedJWTSignature(com.nimbusds.jwt.EncryptedJWT encryptedJWT, java.lang.String token)
JwtTokenValidatorUtils.validateEncryptedJWTSignature(EncryptedJWT, String, List, List)
encryptedJWT
- a encrytped JWT Tokentoken
- the JWT token as Stringpublic org.reactivestreams.Publisher<Authentication> validateToken(java.lang.String token)
TokenValidator
validateToken
in interface TokenValidator
token
- The token string.Authentication
based on the JWT or empty if the validation fails.public java.util.Optional<Authentication> authenticationIfValidJwtSignatureAndClaims(java.lang.String token, java.util.Collection<? extends JwtClaimsValidator> claimsValidators)
token
- A JWT tokenclaimsValidators
- a Collection of claims Validators.public java.util.Optional<com.nimbusds.jwt.JWT> validateJwtSignatureAndClaims(java.lang.String token)
token
- A JWT tokenpublic boolean validate(java.lang.String token)
token
- A JWT tokenpublic boolean validate(java.lang.String token, java.util.Collection<? extends JwtClaimsValidator> claimsValidators)
token
- A JWT tokenclaimsValidators
- a Collection of claims Validators.@Deprecated public java.util.Optional<com.nimbusds.jwt.JWT> validateJwtSignatureAndClaims(java.lang.String token, java.util.Collection<? extends JwtClaimsValidator> claimsValidators)
JwtTokenValidatorUtils.validateJwtSignatureAndClaims(String, Collection, List, List)
instead.token
- A JWT tokenclaimsValidators
- a Collection of claims Validators.@Deprecated public java.util.Optional<com.nimbusds.jwt.JWT> parseJwtIfValidSignature(java.lang.String token)
token
- a JWT tokenpublic java.util.List<SignatureConfiguration> getSignatureConfigurations()
public java.util.List<EncryptionConfiguration> getEncryptionConfigurations()
public java.util.List<GenericJwtClaimsValidator> getGenericJwtClaimsValidators()