Class NimbusJwtDecoder.JwkSetUriJwtDecoderBuilder
- Enclosing class:
- NimbusJwtDecoder
NimbusJwtDecoder instances based on a
JWK Set
uri.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the configuredNimbusJwtDecoder.cache(org.springframework.cache.Cache cache) Use the givenCacheto store JWK Set.Enables discovery of supported JWS algorithms from the remote JWK Set.jwsAlgorithm(SignatureAlgorithm signatureAlgorithm) Append the given signing algorithm to the set of algorithms to use.jwsAlgorithms(Consumer<Set<SignatureAlgorithm>> signatureAlgorithmsConsumer) Configure the list of algorithms to use with the givenConsumer.jwtProcessorCustomizer(Consumer<com.nimbusds.jwt.proc.ConfigurableJWTProcessor<com.nimbusds.jose.proc.SecurityContext>> jwtProcessorCustomizer) Use the givenConsumerto customize theConfigurableJWTProcessorbefore passing it to the buildNimbusJwtDecoder.restOperations(org.springframework.web.client.RestOperations restOperations) validateType(boolean shouldValidateTypHeader) Whether to use Nimbus's typ header verification.
-
Method Details
-
validateType
Whether to use Nimbus's typ header verification. This istrueby default, however it may change tofalsein a future major release.By turning off this feature,
NimbusJwtDecoderexpects applications to check thetypheader themselves in order to determine what kind of validation is neededThis is done for you when you use
JwtValidatorsto construct a validator.That means that this:
NimbusJwtDecoder jwtDecoder = NimbusJwtDecoder.withIssuerLocation(issuer).build(); jwtDecoder.setJwtValidator(JwtValidators.createDefaultWithIssuer(issuer);Is equivalent to this:
NimbusJwtDecoder jwtDecoder = NimbusJwtDecoder.withIssuerLocation(issuer) .validateType(false) .build(); jwtDecoder.setJwtValidator(JwtValidators.createDefaultWithValidators( new JwtIssuerValidator(issuer), JwtTypeValidator.jwt());The difference is that by setting this to
false, it allows you to provide validation by type, like forat+jwt:NimbusJwtDecoder jwtDecoder = NimbusJwtDecoder.withIssuerLocation(issuer) .validateType(false) .build(); jwtDecoder.setJwtValidator(new MyAtJwtValidator());- Parameters:
shouldValidateTypHeader- whether Nimbus should validate the typ header or not- Returns:
- a
NimbusJwtDecoder.JwkSetUriJwtDecoderBuilderfor further configurations - Since:
- 6.5
-
jwsAlgorithm
public NimbusJwtDecoder.JwkSetUriJwtDecoderBuilder jwsAlgorithm(SignatureAlgorithm signatureAlgorithm) Append the given signing algorithm to the set of algorithms to use.- Parameters:
signatureAlgorithm- the algorithm to use- Returns:
- a
NimbusJwtDecoder.JwkSetUriJwtDecoderBuilderfor further configurations
-
jwsAlgorithms
public NimbusJwtDecoder.JwkSetUriJwtDecoderBuilder jwsAlgorithms(Consumer<Set<SignatureAlgorithm>> signatureAlgorithmsConsumer) Configure the list of algorithms to use with the givenConsumer.- Parameters:
signatureAlgorithmsConsumer- aConsumerfor further configuring the algorithm list- Returns:
- a
NimbusJwtDecoder.JwkSetUriJwtDecoderBuilderfor further configurations
-
restOperations
public NimbusJwtDecoder.JwkSetUriJwtDecoderBuilder restOperations(org.springframework.web.client.RestOperations restOperations) Use the givenRestOperationsto coordinate with the authorization servers indicated in the JWK Set uri as well as the Issuer.- Parameters:
restOperations- theRestOperationsinstance to use- Returns:
- a
NimbusJwtDecoder.JwkSetUriJwtDecoderBuilderfor further configurations
-
cache
Use the givenCacheto store JWK Set.- Parameters:
cache- theCacheto be used to store JWK Set- Returns:
- a
NimbusJwtDecoder.JwkSetUriJwtDecoderBuilderfor further configurations - Since:
- 5.4
-
discoverJwsAlgorithms
Enables discovery of supported JWS algorithms from the remote JWK Set.- Returns:
- a
NimbusJwtDecoder.JwkSetUriJwtDecoderBuilderfor further configuration - Since:
- 7.0.0
-
jwtProcessorCustomizer
public NimbusJwtDecoder.JwkSetUriJwtDecoderBuilder jwtProcessorCustomizer(Consumer<com.nimbusds.jwt.proc.ConfigurableJWTProcessor<com.nimbusds.jose.proc.SecurityContext>> jwtProcessorCustomizer) Use the givenConsumerto customize theConfigurableJWTProcessorbefore passing it to the buildNimbusJwtDecoder.- Parameters:
jwtProcessorCustomizer- the callback used to alter the processor- Returns:
- a
NimbusJwtDecoder.JwkSetUriJwtDecoderBuilderfor further configurations - Since:
- 5.4
-
build
Build the configuredNimbusJwtDecoder.- Returns:
- the configured
NimbusJwtDecoder
-