Class DelegatingJwtGrantedAuthoritiesConverter

java.lang.Object
org.springframework.security.oauth2.server.resource.authentication.DelegatingJwtGrantedAuthoritiesConverter
All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,Collection<org.springframework.security.core.GrantedAuthority>>

public class DelegatingJwtGrantedAuthoritiesConverter extends Object implements org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,Collection<org.springframework.security.core.GrantedAuthority>>
A Jwt to GrantedAuthority Converter that is a composite of converters.
Since:
5.5
See Also:
  • Constructor Details

    • DelegatingJwtGrantedAuthoritiesConverter

      public DelegatingJwtGrantedAuthoritiesConverter(Collection<org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,Collection<org.springframework.security.core.GrantedAuthority>>> authoritiesConverters)
      Constructs a DelegatingJwtGrantedAuthoritiesConverter using the provided Collection of Converters
      Parameters:
      authoritiesConverters - the Collection of Converters to use
    • DelegatingJwtGrantedAuthoritiesConverter

      @SafeVarargs public DelegatingJwtGrantedAuthoritiesConverter(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,Collection<org.springframework.security.core.GrantedAuthority>>... authoritiesConverters)
      Constructs a DelegatingJwtGrantedAuthoritiesConverter using the provided array of Converters
      Parameters:
      authoritiesConverters - the array of Converters to use
  • Method Details

    • convert

      public Collection<org.springframework.security.core.GrantedAuthority> convert(org.springframework.security.oauth2.jwt.Jwt jwt)
      Extract GrantedAuthoritys from the given Jwt.

      The authorities are extracted from each delegated Converter one at a time. For each converter, its authorities are added in order, with duplicates removed.

      Specified by:
      convert in interface org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,Collection<org.springframework.security.core.GrantedAuthority>>
      Parameters:
      jwt - The Jwt token
      Returns:
      The authorities read from the token scopes