Class DefaultJwtBearerTokenAuthenticationConverter

java.lang.Object
com.broadleafcommerce.oauth2.resource.security.token.converter.DefaultJwtBearerTokenAuthenticationConverter
All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,org.springframework.security.oauth2.server.resource.authentication.BearerTokenAuthentication>

public class DefaultJwtBearerTokenAuthenticationConverter extends Object implements org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,org.springframework.security.oauth2.server.resource.authentication.BearerTokenAuthentication>
A Converter that takes a Jwt and converts it into a BearerTokenAuthentication.
Author:
Nick Crum (ncrum)
See Also:
  • for reference implementation
  • Field Details

  • Constructor Details

    • DefaultJwtBearerTokenAuthenticationConverter

      public DefaultJwtBearerTokenAuthenticationConverter()
  • Method Details

    • convert

      public org.springframework.security.oauth2.server.resource.authentication.BearerTokenAuthentication 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.oauth2.server.resource.authentication.BearerTokenAuthentication>
    • extractName

      protected String extractName(org.springframework.security.oauth2.jwt.Jwt jwt)
      Extracts the principal name from the JWT. This first looks for a subject, which is the standard way of providing the principal name. Secondly, it will look up a "user_name" claim, which is a non-standard way Spring Security OAuth provides the principal name. Lastly, we fall back on the "client_id", in the event no user principal is tied to the access token.
      Parameters:
      jwt - the jwt
      Returns:
      the principal name
    • extractAuthorities

      protected Collection<org.springframework.security.core.GrantedAuthority> extractAuthorities(org.springframework.security.oauth2.jwt.Jwt jwt)