Class Jwt

  • All Implemented Interfaces:
    java.io.Serializable, org.springframework.security.oauth2.core.ClaimAccessor, org.springframework.security.oauth2.core.OAuth2Token, JwtClaimAccessor

    public class Jwt
    extends org.springframework.security.oauth2.core.AbstractOAuth2Token
    implements JwtClaimAccessor
    An implementation of an AbstractOAuth2Token representing a JSON Web Token (JWT).

    JWTs represent a set of "claims" as a JSON object that may be encoded in a JSON Web Signature (JWS) and/or JSON Web Encryption (JWE) structure. The JSON object, also known as the JWT Claims Set, consists of one or more claim name/value pairs. The claim name is a String and the claim value is an arbitrary JSON object.

    Since:
    5.0
    See Also:
    AbstractOAuth2Token, JwtClaimAccessor, JSON Web Token (JWT), JSON Web Signature (JWS), JSON Web Encryption (JWE), Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Jwt.Builder
      Helps configure a Jwt
    • Constructor Summary

      Constructors 
      Constructor Description
      Jwt​(java.lang.String tokenValue, java.time.Instant issuedAt, java.time.Instant expiresAt, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> claims)
      Constructs a Jwt using the provided parameters.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Map<java.lang.String,​java.lang.Object> getClaims()
      Returns the JWT Claims Set.
      java.util.Map<java.lang.String,​java.lang.Object> getHeaders()
      Returns the JOSE header(s).
      static Jwt.Builder withTokenValue​(java.lang.String tokenValue)
      Return a Jwt.Builder
      • Methods inherited from class org.springframework.security.oauth2.core.AbstractOAuth2Token

        equals, getExpiresAt, getIssuedAt, getTokenValue, hashCode
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.springframework.security.oauth2.core.ClaimAccessor

        containsClaim, getClaim, getClaimAsBoolean, getClaimAsInstant, getClaimAsMap, getClaimAsString, getClaimAsStringList, getClaimAsURL, hasClaim
    • Constructor Detail

      • Jwt

        public Jwt​(java.lang.String tokenValue,
                   java.time.Instant issuedAt,
                   java.time.Instant expiresAt,
                   java.util.Map<java.lang.String,​java.lang.Object> headers,
                   java.util.Map<java.lang.String,​java.lang.Object> claims)
        Constructs a Jwt using the provided parameters.
        Parameters:
        tokenValue - the token value
        issuedAt - the time at which the JWT was issued
        expiresAt - the expiration time on or after which the JWT MUST NOT be accepted
        headers - the JOSE header(s)
        claims - the JWT Claims Set
    • Method Detail

      • getHeaders

        public java.util.Map<java.lang.String,​java.lang.Object> getHeaders()
        Returns the JOSE header(s).
        Returns:
        a Map of the JOSE header(s)
      • getClaims

        public java.util.Map<java.lang.String,​java.lang.Object> getClaims()
        Returns the JWT Claims Set.
        Specified by:
        getClaims in interface org.springframework.security.oauth2.core.ClaimAccessor
        Returns:
        a Map of the JWT Claims Set