Class JwtBearerTokenAuthenticationConverter

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

public final class JwtBearerTokenAuthenticationConverter extends Object implements org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt, org.springframework.security.authentication.AbstractAuthenticationToken>
A Converter that takes a Jwt and converts it into a BearerTokenAuthentication. In the process, it will attempt to parse either the "scope" or "scp" attribute, whichever it finds first. It's not intended that this implementation be configured since it is simply an adapter. If you are using, for example, a custom JwtGrantedAuthoritiesConverter, then it's recommended that you simply create your own Converter that delegates to your custom JwtGrantedAuthoritiesConverter and instantiates the appropriate BearerTokenAuthentication.
Since:
5.2
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.security.authentication.AbstractAuthenticationToken
    convert(org.springframework.security.oauth2.jwt.Jwt jwt)
     
    void
    setJwtPrincipalConverter(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt, org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal> jwtPrincipalConverter)
    Sets the Converter<Jwt, OAuth2AuthenticatedPrincipal> to use.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.core.convert.converter.Converter

    andThen
  • Constructor Details

    • JwtBearerTokenAuthenticationConverter

      public JwtBearerTokenAuthenticationConverter()
  • Method Details

    • convert

      public 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>
    • setJwtPrincipalConverter

      public void setJwtPrincipalConverter(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt, org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal> jwtPrincipalConverter)
      Sets the Converter<Jwt, OAuth2AuthenticatedPrincipal> to use.

      By default, constructs a DefaultOAuth2AuthenticatedPrincipal based on the claims and authorities derived from the Jwt.

      Parameters:
      jwtPrincipalConverter - The converter
      Since:
      7.1