Class JwtGrantedAuthoritiesConverter
- java.lang.Object
-
- org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter
-
- All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<Jwt,java.util.Collection<GrantedAuthority>>
public final class JwtGrantedAuthoritiesConverter extends java.lang.Object implements org.springframework.core.convert.converter.Converter<Jwt,java.util.Collection<GrantedAuthority>>
Extracts theGrantedAuthority
s from scope attributes typically found in aJwt
.- Since:
- 5.2
-
-
Constructor Summary
Constructors Constructor Description JwtGrantedAuthoritiesConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<GrantedAuthority>
convert(Jwt jwt)
ExtractGrantedAuthority
s from the givenJwt
.void
setAuthoritiesClaimName(java.lang.String authoritiesClaimName)
Sets the name of token claim to use for mappingauthorities
by this converter.void
setAuthorityPrefix(java.lang.String authorityPrefix)
Sets the prefix to use forauthorities
mapped by this converter.
-
-
-
Method Detail
-
convert
public java.util.Collection<GrantedAuthority> convert(Jwt jwt)
ExtractGrantedAuthority
s from the givenJwt
.- Specified by:
convert
in interfaceorg.springframework.core.convert.converter.Converter<Jwt,java.util.Collection<GrantedAuthority>>
- Parameters:
jwt
- TheJwt
token- Returns:
- The
authorities
read from the token scopes
-
setAuthorityPrefix
public void setAuthorityPrefix(java.lang.String authorityPrefix)
Sets the prefix to use forauthorities
mapped by this converter. Defaults toDEFAULT_AUTHORITY_PREFIX
.- Parameters:
authorityPrefix
- The authority prefix- Since:
- 5.2
-
setAuthoritiesClaimName
public void setAuthoritiesClaimName(java.lang.String authoritiesClaimName)
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
-
-