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 ofJwtDecoder
which takes a raw Nimbus configuration.- Since:
- 5.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NimbusJwtDecoder.JwkSetUriJwtDecoderBuilder
A builder for creatingNimbusJwtDecoder
instances based on a JWK Set uri.static class
NimbusJwtDecoder.PublicKeyJwtDecoderBuilder
A builder for creatingNimbusJwtDecoder
instances based on a public key.static class
NimbusJwtDecoder.SecretKeyJwtDecoderBuilder
A builder for creatingNimbusJwtDecoder
instances based on aSecretKey
.
-
Constructor Summary
Constructors Constructor Description NimbusJwtDecoder(com.nimbusds.jwt.proc.JWTProcessor<com.nimbusds.jose.proc.SecurityContext> jwtProcessor)
Configures aNimbusJwtDecoder
with the given parameters
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Jwt
decode(java.lang.String token)
Decode and validate the JWT from its compact claims representation formatvoid
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 followingConverter
for manipulating the JWT's claim setvoid
setJwtValidator(OAuth2TokenValidator<Jwt> jwtValidator)
Use thisJwt
Validatorstatic NimbusJwtDecoder.JwkSetUriJwtDecoderBuilder
withJwkSetUri(java.lang.String jwkSetUri)
Use the given JWK Set uri.static NimbusJwtDecoder.PublicKeyJwtDecoderBuilder
withPublicKey(java.security.interfaces.RSAPublicKey key)
Use the given public key to validate JWTsstatic NimbusJwtDecoder.SecretKeyJwtDecoderBuilder
withSecretKey(javax.crypto.SecretKey secretKey)
Use the givenSecretKey
to 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 aNimbusJwtDecoder
with the given parameters- Parameters:
jwtProcessor
- - theJWTProcessor
to use
-
-
Method Detail
-
setJwtValidator
public void setJwtValidator(OAuth2TokenValidator<Jwt> jwtValidator)
Use thisJwt
Validator- 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 followingConverter
for manipulating the JWT's claim set- Parameters:
claimSetConverter
- theConverter
to use
-
decode
public Jwt decode(java.lang.String token) throws JwtException
Decode and validate the JWT from its compact claims representation format- Specified by:
decode
in 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.JwkSetUriJwtDecoderBuilder
for 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.PublicKeyJwtDecoderBuilder
for further configurations
-
withSecretKey
public static NimbusJwtDecoder.SecretKeyJwtDecoderBuilder withSecretKey(javax.crypto.SecretKey secretKey)
Use the givenSecretKey
to validate the MAC on a JSON Web Signature (JWS).- Parameters:
secretKey
- theSecretKey
used to validate the MAC- Returns:
- a
NimbusJwtDecoder.SecretKeyJwtDecoderBuilder
for further configurations
-
-