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

public class JsonPathJwtConverter extends Object implements org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,org.springframework.security.authentication.AbstractAuthenticationToken>
The json path jwt converter.
Author:
Christian Bremer
  • Constructor Details

    • JsonPathJwtConverter

      public JsonPathJwtConverter(String nameJsonPath, String firstNameJsonPath, String lastNameJsonPath, String emailJsonPath, String rolesJsonPath, boolean rolesValueList, String rolesValueSeparator, org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper authoritiesMapper)
      Instantiates a new Json path jwt converter.
      Parameters:
      nameJsonPath - the name json path
      firstNameJsonPath - the first name json path
      lastNameJsonPath - the last name json path
      emailJsonPath - the email json path
      rolesJsonPath - the roles json path
      rolesValueList - the roles value list
      rolesValueSeparator - the roles value separator
      authoritiesMapper - the authorities mapper
  • Method Details

    • convert

      @NonNull public NormalizedJwtAuthenticationToken convert(@NonNull org.springframework.security.oauth2.jwt.Jwt source)
      Specified by:
      convert in interface org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,org.springframework.security.authentication.AbstractAuthenticationToken>
    • getGrantedAuthorities

      protected Collection<? extends org.springframework.security.core.GrantedAuthority> getGrantedAuthorities(JsonPathJwtParser parser)
      Gets granted authorities.
      Parameters:
      parser - the parser
      Returns:
      the granted authorities
    • getAuthoritiesFromList

      protected Stream<String> getAuthoritiesFromList(JsonPathJwtParser parser)
      Gets authorities from list.
      Parameters:
      parser - the parser
      Returns:
      the authorities from list
    • getAuthoritiesFromValue

      protected Stream<String> getAuthoritiesFromValue(JsonPathJwtParser parser)
      Gets authorities from value.
      Parameters:
      parser - the parser
      Returns:
      the authorities from value
    • getUsername

      protected String getUsername(org.springframework.security.oauth2.jwt.Jwt source, JsonPathJwtParser parser)
      Gets username.
      Parameters:
      source - the source
      parser - the parser
      Returns:
      the username
    • getFirstName

      protected String getFirstName(JsonPathJwtParser parser)
      Gets first name.
      Parameters:
      parser - the parser
      Returns:
      the first name
    • getLastName

      protected String getLastName(JsonPathJwtParser parser)
      Gets last name.
      Parameters:
      parser - the parser
      Returns:
      the last name
    • getEmail

      protected String getEmail(JsonPathJwtParser parser)
      Gets email.
      Parameters:
      parser - the parser
      Returns:
      the email