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 Details

    • JwtGrantedAuthoritiesConverter

      public JwtGrantedAuthoritiesConverter()
  • Method Details

    • convert

      public Collection<GrantedAuthority> convert(Jwt jwt)
      Extract GrantedAuthoritys from the given Jwt.
      Specified by:
      convert in interface org.springframework.core.convert.converter.Converter<Jwt,Collection<GrantedAuthority>>
      Parameters:
      jwt - The Jwt token
      Returns:
      The authorities read from the token scopes
    • setAuthorityPrefix

      public void setAuthorityPrefix(String authorityPrefix)
      Sets the prefix to use for authorities mapped by this converter. Defaults to DEFAULT_AUTHORITY_PREFIX.
      Parameters:
      authorityPrefix - The authority prefix
      Since:
      5.2
    • setAuthoritiesClaimName

      public void setAuthoritiesClaimName(String authoritiesClaimName)
      Sets the name of token claim to use for mapping authorities by this converter. Defaults to WELL_KNOWN_AUTHORITIES_CLAIM_NAMES.
      Parameters:
      authoritiesClaimName - The token claim name to map authorities
      Since:
      5.2