Class JwtAuthenticationConverter

  • All Implemented Interfaces:
    org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,​org.springframework.security.authentication.AbstractAuthenticationToken>

    public class JwtAuthenticationConverter
    extends java.lang.Object
    implements org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,​org.springframework.security.authentication.AbstractAuthenticationToken>
    Since:
    5.1
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      org.springframework.security.authentication.AbstractAuthenticationToken convert​(org.springframework.security.oauth2.jwt.Jwt jwt)  
      protected java.util.Collection<org.springframework.security.core.GrantedAuthority> extractAuthorities​(org.springframework.security.oauth2.jwt.Jwt jwt)
      Deprecated.
      Since 5.2.
      void setJwtGrantedAuthoritiesConverter​(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,​java.util.Collection<org.springframework.security.core.GrantedAuthority>> jwtGrantedAuthoritiesConverter)
      Sets the Converter<Jwt, Collection<GrantedAuthority>> to use.
      void setPrincipalClaimName​(java.lang.String principalClaimName)
      Sets the principal claim name.
      • 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

      • JwtAuthenticationConverter

        public JwtAuthenticationConverter()
    • Method Detail

      • convert

        public final org.springframework.security.authentication.AbstractAuthenticationToken convert​(org.springframework.security.oauth2.jwt.Jwt jwt)
        Specified by:
        convert in interface org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,​org.springframework.security.authentication.AbstractAuthenticationToken>
      • extractAuthorities

        @Deprecated
        protected java.util.Collection<org.springframework.security.core.GrantedAuthority> extractAuthorities​(org.springframework.security.oauth2.jwt.Jwt jwt)
        Deprecated.
        Since 5.2. Use your own custom converter instead
        Extracts the GrantedAuthoritys from scope attributes typically found in a Jwt
        Parameters:
        jwt - The token
        Returns:
        The collection of GrantedAuthoritys found on the token
        See Also:
        JwtGrantedAuthoritiesConverter, setJwtGrantedAuthoritiesConverter(Converter)
      • setJwtGrantedAuthoritiesConverter

        public void setJwtGrantedAuthoritiesConverter​(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,​java.util.Collection<org.springframework.security.core.GrantedAuthority>> jwtGrantedAuthoritiesConverter)
        Sets the Converter<Jwt, Collection<GrantedAuthority>> to use. Defaults to JwtGrantedAuthoritiesConverter.
        Parameters:
        jwtGrantedAuthoritiesConverter - The converter
        Since:
        5.2
        See Also:
        JwtGrantedAuthoritiesConverter
      • setPrincipalClaimName

        public void setPrincipalClaimName​(java.lang.String principalClaimName)
        Sets the principal claim name. Defaults to JwtClaimNames.SUB.
        Parameters:
        principalClaimName - The principal claim name
        Since:
        5.4