Class JwtGrantedAuthoritiesConverter
java.lang.Object
org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter
- All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<Jwt,Collection<GrantedAuthority>>
public final class JwtGrantedAuthoritiesConverter
extends Object
implements org.springframework.core.convert.converter.Converter<Jwt,Collection<GrantedAuthority>>
Extracts the
GrantedAuthoritys from scope attributes typically found in a
Jwt.- Since:
- 5.2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionExtractGrantedAuthoritys from the givenJwt.voidsetAuthoritiesClaimDelimiter(String authoritiesClaimDelimiter) Sets the regex to use for splitting the value of the authorities claim intoauthorities.voidsetAuthoritiesClaimName(String authoritiesClaimName) Sets the name of token claim to use for mappingauthoritiesby this converter.voidsetAuthorityPrefix(String authorityPrefix) Sets the prefix to use forauthoritiesmapped by this converter.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
-
JwtGrantedAuthoritiesConverter
public JwtGrantedAuthoritiesConverter()
-
-
Method Details
-
convert
ExtractGrantedAuthoritys from the givenJwt.- Specified by:
convertin interfaceorg.springframework.core.convert.converter.Converter<Jwt,Collection<GrantedAuthority>> - Parameters:
jwt- TheJwttoken- Returns:
- The
authoritiesread from the token scopes
-
setAuthorityPrefix
Sets the prefix to use forauthoritiesmapped by this converter. Defaults toDEFAULT_AUTHORITY_PREFIX.- Parameters:
authorityPrefix- The authority prefix- Since:
- 5.2
-
setAuthoritiesClaimDelimiter
Sets the regex to use for splitting the value of the authorities claim intoauthorities. Defaults toDEFAULT_AUTHORITIES_CLAIM_DELIMITER.- Parameters:
authoritiesClaimDelimiter- The regex used to split the authorities- Since:
- 6.1
-
setAuthoritiesClaimName
Sets the name of token claim to use for mappingauthoritiesby this converter. Defaults toWELL_KNOWN_AUTHORITIES_CLAIM_NAMES.- Parameters:
authoritiesClaimName- The token claim name to map authorities- Since:
- 5.2
-