Class NimbusJwtDecoder
- java.lang.Object
-
- org.springframework.security.oauth2.jwt.NimbusJwtDecoder
-
- All Implemented Interfaces:
JwtDecoder
public final class NimbusJwtDecoder extends java.lang.Object implements JwtDecoder
A low-level Nimbus implementation ofJwtDecoderwhich takes a raw Nimbus configuration.- Since:
- 5.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNimbusJwtDecoder.JwkSetUriJwtDecoderBuilderA builder for creatingNimbusJwtDecoderinstances based on a JWK Set uri.static classNimbusJwtDecoder.PublicKeyJwtDecoderBuilderA builder for creatingNimbusJwtDecoderinstances based on a public key.static classNimbusJwtDecoder.SecretKeyJwtDecoderBuilderA builder for creatingNimbusJwtDecoderinstances based on aSecretKey.
-
Constructor Summary
Constructors Constructor Description NimbusJwtDecoder(com.nimbusds.jwt.proc.JWTProcessor<com.nimbusds.jose.proc.SecurityContext> jwtProcessor)Configures aNimbusJwtDecoderwith the given parameters
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Jwtdecode(java.lang.String token)Decode and validate the JWT from its compact claims representation formatvoidsetClaimSetConverter(org.springframework.core.convert.converter.Converter<java.util.Map<java.lang.String,java.lang.Object>,java.util.Map<java.lang.String,java.lang.Object>> claimSetConverter)Use the followingConverterfor manipulating the JWT's claim setvoidsetJwtValidator(OAuth2TokenValidator<Jwt> jwtValidator)Use thisJwtValidatorstatic NimbusJwtDecoder.JwkSetUriJwtDecoderBuilderwithJwkSetUri(java.lang.String jwkSetUri)Use the given JWK Set uri.static NimbusJwtDecoder.PublicKeyJwtDecoderBuilderwithPublicKey(java.security.interfaces.RSAPublicKey key)Use the given public key to validate JWTsstatic NimbusJwtDecoder.SecretKeyJwtDecoderBuilderwithSecretKey(javax.crypto.SecretKey secretKey)Use the givenSecretKeyto validate the MAC on a JSON Web Signature (JWS).
-
-
-
Constructor Detail
-
NimbusJwtDecoder
public NimbusJwtDecoder(com.nimbusds.jwt.proc.JWTProcessor<com.nimbusds.jose.proc.SecurityContext> jwtProcessor)
Configures aNimbusJwtDecoderwith the given parameters- Parameters:
jwtProcessor- - theJWTProcessorto use
-
-
Method Detail
-
setJwtValidator
public void setJwtValidator(OAuth2TokenValidator<Jwt> jwtValidator)
Use thisJwtValidator- Parameters:
jwtValidator- - the Jwt Validator to use
-
setClaimSetConverter
public void setClaimSetConverter(org.springframework.core.convert.converter.Converter<java.util.Map<java.lang.String,java.lang.Object>,java.util.Map<java.lang.String,java.lang.Object>> claimSetConverter)
Use the followingConverterfor manipulating the JWT's claim set- Parameters:
claimSetConverter- theConverterto use
-
decode
public Jwt decode(java.lang.String token) throws JwtException
Decode and validate the JWT from its compact claims representation format- Specified by:
decodein interfaceJwtDecoder- Parameters:
token- the JWT value- Returns:
- a validated
Jwt - Throws:
JwtException
-
withJwkSetUri
public static NimbusJwtDecoder.JwkSetUriJwtDecoderBuilder withJwkSetUri(java.lang.String jwkSetUri)
Use the given JWK Set uri.- Parameters:
jwkSetUri- the JWK Set uri to use- Returns:
- a
NimbusJwtDecoder.JwkSetUriJwtDecoderBuilderfor further configurations
-
withPublicKey
public static NimbusJwtDecoder.PublicKeyJwtDecoderBuilder withPublicKey(java.security.interfaces.RSAPublicKey key)
Use the given public key to validate JWTs- Parameters:
key- the public key to use- Returns:
- a
NimbusJwtDecoder.PublicKeyJwtDecoderBuilderfor further configurations
-
withSecretKey
public static NimbusJwtDecoder.SecretKeyJwtDecoderBuilder withSecretKey(javax.crypto.SecretKey secretKey)
Use the givenSecretKeyto validate the MAC on a JSON Web Signature (JWS).- Parameters:
secretKey- theSecretKeyused to validate the MAC- Returns:
- a
NimbusJwtDecoder.SecretKeyJwtDecoderBuilderfor further configurations
-
-