Class NimbusReactiveJwtDecoder.SecretKeyReactiveJwtDecoderBuilder
- Enclosing class:
- NimbusReactiveJwtDecoder
NimbusReactiveJwtDecoder instances based on a
SecretKey.- Since:
- 5.2
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the configuredNimbusReactiveJwtDecoder.jwtProcessorCustomizer(Consumer<com.nimbusds.jwt.proc.ConfigurableJWTProcessor<com.nimbusds.jose.proc.SecurityContext>> jwtProcessorCustomizer) Use the givenConsumerto customize theConfigurableJWTProcessorbefore passing it to the buildNimbusReactiveJwtDecoder.macAlgorithm(MacAlgorithm macAlgorithm) Use the given algorithm when generating the MAC.validateType(boolean shouldValidateTypHeader) Whether to use Nimbus's typ header verification.
-
Method Details
-
macAlgorithm
public NimbusReactiveJwtDecoder.SecretKeyReactiveJwtDecoderBuilder macAlgorithm(MacAlgorithm macAlgorithm) Use the given algorithm when generating the MAC. The value should be one of HS256, HS384 or HS512.- Parameters:
macAlgorithm- the MAC algorithm to use- Returns:
- a
NimbusReactiveJwtDecoder.SecretKeyReactiveJwtDecoderBuilderfor further configurations
-
validateType
public NimbusReactiveJwtDecoder.SecretKeyReactiveJwtDecoderBuilder validateType(boolean shouldValidateTypHeader) 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,
NimbusReactiveJwtDecoderexpects 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:
NimbusReactiveJwtDecoder jwtDecoder = NimbusReactiveJwtDecoder.withIssuerLocation(issuer).build(); jwtDecoder.setJwtValidator(JwtValidators.createDefaultWithIssuer(issuer);Is equivalent to this:
NimbusReactiveJwtDecoder jwtDecoder = NimbusReactiveJwtDecoder.withSecretKey(key) .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:NimbusReactiveJwtDecoder jwtDecoder = NimbusReactiveJwtDecoder.withSecretKey(key) .validateType(false) .build(); jwtDecoder.setJwtValidator(new MyAtJwtValidator());- Parameters:
shouldValidateTypHeader- whether Nimbus should validate the typ header or not- Returns:
- a
NimbusReactiveJwtDecoder.PublicKeyReactiveJwtDecoderBuilderfor further configurations - Since:
- 6.5
-
jwtProcessorCustomizer
public NimbusReactiveJwtDecoder.SecretKeyReactiveJwtDecoderBuilder jwtProcessorCustomizer(Consumer<com.nimbusds.jwt.proc.ConfigurableJWTProcessor<com.nimbusds.jose.proc.SecurityContext>> jwtProcessorCustomizer) Use the givenConsumerto customize theConfigurableJWTProcessorbefore passing it to the buildNimbusReactiveJwtDecoder.- Parameters:
jwtProcessorCustomizer- the callback used to alter the processor- Returns:
- a
NimbusReactiveJwtDecoder.SecretKeyReactiveJwtDecoderBuilderfor further configurations - Since:
- 5.4
-
build
Build the configuredNimbusReactiveJwtDecoder.- Returns:
- the configured
NimbusReactiveJwtDecoder
-