Class JwtGrantedAuthoritiesConverter

  • All Implemented Interfaces:
    org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,​java.util.Collection<org.springframework.security.core.GrantedAuthority>>

    public final class JwtGrantedAuthoritiesConverter
    extends java.lang.Object
    implements org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,​java.util.Collection<org.springframework.security.core.GrantedAuthority>>
    Extracts the GrantedAuthoritys from scope attributes typically found in a Jwt.
    Since:
    5.2
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Collection<org.springframework.security.core.GrantedAuthority> convert​(org.springframework.security.oauth2.jwt.Jwt jwt)
      Extract GrantedAuthoritys from the given Jwt.
      void setAuthoritiesClaimName​(java.lang.String authoritiesClaimName)
      Sets the name of token claim to use for mapping authorities by this converter.
      void setAuthorityPrefix​(java.lang.String authorityPrefix)
      Sets the prefix to use for authorities 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 Detail

      • JwtGrantedAuthoritiesConverter

        public JwtGrantedAuthoritiesConverter()
    • Method Detail

      • convert

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

        public void setAuthorityPrefix​(java.lang.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​(java.lang.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