Class MappedJwtClaimSetConverter
java.lang.Object
org.springframework.security.oauth2.jwt.MappedJwtClaimSetConverter
- All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<Map<String,Object>, Map<String, Object>>
public final class MappedJwtClaimSetConverter
extends Object
implements org.springframework.core.convert.converter.Converter<Map<String,Object>,Map<String,Object>>
Converts a JWT claim set, claim by claim. Can be configured with custom converters by
claim name.
- Since:
- 5.1
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMappedJwtClaimSetConverter(Map<String, org.springframework.core.convert.converter.Converter<Object, ?>> claimTypeConverters) Constructs aMappedJwtClaimSetConverterwith the provided arguments This will completely replace any set of default converters. -
Method Summary
Modifier and TypeMethodDescriptionstatic MappedJwtClaimSetConverterwithDefaults(Map<String, org.springframework.core.convert.converter.Converter<Object, ?>> claimTypeConverters) Construct aMappedJwtClaimSetConverter, overriding individual claim converters with the providedMapofConverters.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.core.convert.converter.Converter
andThen
-
Constructor Details
-
MappedJwtClaimSetConverter
public MappedJwtClaimSetConverter(Map<String, org.springframework.core.convert.converter.Converter<Object, ?>> claimTypeConverters) Constructs aMappedJwtClaimSetConverterwith the provided arguments This will completely replace any set of default converters. A converter that returnsnullremoves the claim from the claim set. A converter that returns a non-nullvalue adds or replaces that claim in the claim set.- Parameters:
claimTypeConverters- TheMapof converters to use
-
-
Method Details
-
withDefaults
public static MappedJwtClaimSetConverter withDefaults(Map<String, org.springframework.core.convert.converter.Converter<Object, ?>> claimTypeConverters) Construct aMappedJwtClaimSetConverter, overriding individual claim converters with the providedMapofConverters. For example, the following would give an instance that is configured with only the default claim converters:MappedJwtClaimSetConverter.withDefaults(Collections.emptyMap());Or, the following would supply a custom converter for the subject, leaving the other defaults in place:MappedJwtClaimsSetConverter.withDefaults( Collections.singletonMap(JwtClaimNames.SUB, new UserDetailsServiceJwtSubjectConverter()));To completely replace the underlyingMapof converters, seeMappedJwtClaimSetConverter(Map). A converter that returnsnullremoves the claim from the claim set. A converter that returns a non-nullvalue adds or replaces that claim in the claim set.- Parameters:
claimTypeConverters-- Returns:
- An instance of
MappedJwtClaimSetConverterthat contains the converters provided, plus any defaults that were not overridden.
-
convert
-