Class JwtAuthenticationToken

java.lang.Object
com.codename1.backend.security.AbstractAuthenticationToken
com.codename1.backend.security.oauth2.server.resource.JwtAuthenticationToken
All Implemented Interfaces:
Authentication

public final class JwtAuthenticationToken extends AbstractAuthenticationToken

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");
}
  • Constructor Details

  • Method Details

    • getToken

      public Jwt getToken()
      The verified token.
    • getTokenAttributes

      public Map<String,Object> getTokenAttributes()
      The token's claims.
    • getPrincipal

      public Object getPrincipal()
      Description copied from interface: Authentication
      The identity: a username before authentication, and afterwards usually the UserDetails it was resolved to.
    • getCredentials

      public Object getCredentials()
      Description copied from interface: Authentication
      What proves the principal is who it says: a password, usually, and null once it has been checked.
    • getName

      public String getName()
      Description copied from interface: Authentication
      The principal's name.
      Specified by:
      getName in interface Authentication
      Overrides:
      getName in class AbstractAuthenticationToken