Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class JwtAuthenticationConverter

  1. Object
  2. JwtAuthenticationConverter

ImplementsConverter<Jwt, AbstractAuthenticationToken>

Makes the JwtAuthenticationToken of a verified token: its authorities, through a JwtGrantedAuthoritiesConverter unless another is set, and its name, from the sub claim unless another is named.

JwtAuthenticationConverter converter = new JwtAuthenticationConverter();
converter.setPrincipalClaimName("preferred_username");
http.oauth2ResourceServer(o -> o.jwt(jwt -> jwt.jwtAuthenticationConverter(converter)));

Constructors

public JwtAuthenticationConverter()

Methods

public void setJwtGrantedAuthoritiesConverter(Converter<Jwt, Collection<GrantedAuthority>> jwtGrantedAuthoritiesConverter)What reads the authorities out of a token.
public void setPrincipalClaimName(String principalClaimName)The claim Authentication.getName() answers with; sub unless set.
public AbstractAuthenticationToken convert(Jwt jwt)What source becomes; null when it becomes nothing.

Inherited methods

Constructor details

JwtAuthenticationConverter

public JwtAuthenticationConverter()

Method details

setJwtGrantedAuthoritiesConverter

public void setJwtGrantedAuthoritiesConverter(Converter<Jwt, Collection<GrantedAuthority>> jwtGrantedAuthoritiesConverter)
What reads the authorities out of a token.

setPrincipalClaimName

public void setPrincipalClaimName(String principalClaimName)
The claim Authentication.getName() answers with; sub unless set.

convert

public AbstractAuthenticationToken convert(Jwt jwt)
What source becomes; null when it becomes nothing.