Class DelegatingJwtGrantedAuthoritiesConverter

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

public class DelegatingJwtGrantedAuthoritiesConverter extends Object implements org.springframework.core.convert.converter.Converter<Jwt, Collection<GrantedAuthority>>
A Jwt to GrantedAuthority Converter that is a composite of converters.

This is handy when needing to read authorities from multiple locations in a JWT; each underlying converter is called in series and the results are aggregated into a single collection of authorities.

For example, you might have a claim called "scope" and another called "roles". With DelegatingJwtGrantedAuthoritiesConverter, you can do: JwtGrantedAuthoritiesConverter scopes = new JwtGrantedAuthoritiesConverter(); JwtGrantedAuthoritiesConverter roles = new JwtGrantedAUthoritiesConverter(); roles.setAuthoritiesClaimName("roles"); roles.setAuthorityPrefix("ROLE_"); return new DelegatingJwtGrantedAuthoritiesConverter(scopes, roles);

Since:
5.5
See Also: