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

public final class JwtAuthenticationToken

  1. Object
  2. AbstractAuthenticationToken
  3. JwtAuthenticationToken

ImplementsAuthentication

Who a request is from, when a verified JWT says so. The principal is the Jwt itself, so a controller reads any claim off it:

@GetMapping("/me")
String me(@AuthenticationPrincipal Jwt jwt) {
    return jwt.getClaimAsString("email");
}

Constructors

public JwtAuthenticationToken(Jwt jwt, Collection<? extends GrantedAuthority> authorities)Named after the token’s subject.
public JwtAuthenticationToken(Jwt jwt, Collection<? extends GrantedAuthority> authorities, String name)

Methods

public Jwt getToken()The verified token.
public Map<String, Object> getTokenAttributes()The token’s claims.
public Object getPrincipal()The identity: a username before authentication, and afterwards usually the UserDetails it was resolved to.
public Object getCredentials()What proves the principal is who it says: a password, usually, and null once it has been checked.
public String getName()The principal’s name.

Inherited methods

Constructor details

JwtAuthenticationToken

public JwtAuthenticationToken(Jwt jwt, Collection<? extends GrantedAuthority> authorities)
Named after the token’s subject.

JwtAuthenticationToken

public JwtAuthenticationToken(Jwt jwt, Collection<? extends GrantedAuthority> authorities, String name)

Method details

getToken

public Jwt getToken()
The verified token.

getTokenAttributes

public Map<String, Object> getTokenAttributes()
The token’s claims.

getPrincipal

public Object getPrincipal()
The identity: a username before authentication, and afterwards usually the UserDetails it was resolved to.

getCredentials

public Object getCredentials()
What proves the principal is who it says: a password, usually, and null once it has been checked.

getName

public String getName()
The principal’s name.