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
GrantedAuthority
s from scope attributes typically found in a
Jwt
.- Since:
- 5.2
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionExtractGrantedAuthority
s from the givenJwt
.void
setAuthoritiesClaimName
(String authoritiesClaimName) Sets the name of token claim to use for mappingauthorities
by this converter.void
setAuthorityPrefix
(String authorityPrefix) Sets the prefix to use forauthorities
mapped by this converter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.core.convert.converter.Converter
andThen
-
Constructor Details
-
JwtGrantedAuthoritiesConverter
public JwtGrantedAuthoritiesConverter()
-
-
Method Details
-
convert
ExtractGrantedAuthority
s from the givenJwt
.- Specified by:
convert
in interfaceorg.springframework.core.convert.converter.Converter<Jwt,
Collection<GrantedAuthority>> - Parameters:
jwt
- TheJwt
token- Returns:
- The
authorities
read from the token scopes
-
setAuthorityPrefix
Sets the prefix to use forauthorities
mapped by this converter. Defaults toDEFAULT_AUTHORITY_PREFIX
.- Parameters:
authorityPrefix
- The authority prefix- Since:
- 5.2
-
setAuthoritiesClaimName
Sets the name of token claim to use for mappingauthorities
by this converter. Defaults toWELL_KNOWN_AUTHORITIES_CLAIM_NAMES
.- Parameters:
authoritiesClaimName
- The token claim name to map authorities- Since:
- 5.2
-