org.keycloak.representations

## Class JsonWebToken

- java.lang.Object
- - org.keycloak.representations.JsonWebToken

- All Implemented Interfaces:
    Serializable, Token
  Direct Known Subclasses:
    CIBAAuthenticationRequest, DefaultActionTokenKey, DockerResponseToken, IDToken, InitialAccessToken, LogoutToken, PermissionTicketToken, RegistrationAccessToken, TokenIntrospectionResponse

      public class JsonWebToken
      extends Object
      implements Serializable, Token

  Version:
    $Revision: 1 $
  Author:
    Bill Burke
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String[]` | `audience`
    `protected Long` | `exp`
    `protected Long` | `iat`
    `protected String` | `id`
    `String` | `issuedFor`
    `protected String` | `issuer`
    `protected Long` | `nbf`
    `protected Map<String,Object>` | `otherClaims`
    `protected String` | `subject`
    `protected String` | `type`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JsonWebToken()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `JsonWebToken` | `addAudience(String audience)`
    `JsonWebToken` | `audience(String... audience)`
    `JsonWebToken` | `exp(Long exp)`
    `JsonWebToken` | `expiration(int expiration)` Deprecated. int will overflow with values after 2038. Use `exp(Long)` instead.
    `String[]` | `getAudience()`
    `TokenCategory` | `getCategory()`
    `Long` | `getExp()`
    `int` | `getExpiration()` Deprecated. int will overflow with values after 2038. Use `getExp()` instead.
    `Long` | `getIat()`
    `String` | `getId()`
    `int` | `getIssuedAt()` Deprecated. int will overflow with values after 2038. Use `getIat()` instead.
    `String` | `getIssuedFor()` OAuth client the token was issued for.
    `String` | `getIssuer()`
    `Long` | `getNbf()`
    `int` | `getNotBefore()` Deprecated. int will overflow with values after 2038. Use `getNbf()` instead.
    `Map<String,Object>` | `getOtherClaims()` This is a map of any other claims and data that might be in the IDToken.
    `String` | `getSubject()`
    `String` | `getType()`
    `boolean` | `hasAudience(String audience)`
    `JsonWebToken` | `iat(Long iat)`
    `JsonWebToken` | `id(String id)`
    `boolean` | `isActive()` Tests that the token is not expired and is not-before.
    `boolean` | `isActive(int allowedTimeSkew)`
    `boolean` | `isExpired()`
    `boolean` | `isIssuedBeforeSessionStart(long sessionStarted)`
    `boolean` | `isNotBefore(int allowedTimeSkew)`
    `JsonWebToken` | `issuedAt(int issuedAt)` Deprecated. int will overflow with values after 2038. Use `iat(Long)` ()} instead.
    `JsonWebToken` | `issuedFor(String issuedFor)`
    `JsonWebToken` | `issuedNow()` Set issuedAt to the current time
    `JsonWebToken` | `issuer(String issuer)`
    `JsonWebToken` | `nbf(Long nbf)`
    `JsonWebToken` | `notBefore(int notBefore)` Deprecated. int will overflow with values after 2038. Use `nbf(Long)` instead.
    `void` | `setOtherClaims(String name, Object value)`
    `void` | `setSubject(String subject)`
    `JsonWebToken` | `subject(String subject)`
    `JsonWebToken` | `type(String type)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### id

          protected String id

    - #### exp

          protected Long exp

    - #### nbf

          protected Long nbf

    - #### iat

          protected Long iat

    - #### issuer

          protected String issuer

    - #### audience

          protected String[] audience

    - #### subject

          protected String subject

    - #### type

          protected String type

    - #### issuedFor

          public String issuedFor

    - #### otherClaims

          protected Map<String,Object> otherClaims

  - ### Constructor Detail

    - #### JsonWebToken

          public JsonWebToken()

  - ### Method Detail

    - #### getId

          public String getId()

    - #### id

          public JsonWebToken id(String id)

    - #### getExp

          public Long getExp()

    - #### getExpiration

          @Deprecated
          public int getExpiration()

      Deprecated. int will overflow with values after 2038. Use `getExp()` instead.

    - #### exp

          public JsonWebToken exp(Long exp)

    - #### expiration

          public JsonWebToken expiration(int expiration)

      Deprecated. int will overflow with values after 2038. Use `exp(Long)` instead.

    - #### isExpired

          public boolean isExpired()

    - #### getNbf

          public Long getNbf()

    - #### getNotBefore

          @Deprecated
          public int getNotBefore()

      Deprecated. int will overflow with values after 2038. Use `getNbf()` instead.

    - #### nbf

          public JsonWebToken nbf(Long nbf)

    - #### notBefore

          @Deprecated
          public JsonWebToken notBefore(int notBefore)

      Deprecated. int will overflow with values after 2038. Use `nbf(Long)` instead.

    - #### isNotBefore

          public boolean isNotBefore(int allowedTimeSkew)

    - #### isActive

          public boolean isActive()

      Tests that the token is not expired and is not-before.
      Returns:

    - #### isActive

          public boolean isActive(int allowedTimeSkew)

    - #### isIssuedBeforeSessionStart

          public boolean isIssuedBeforeSessionStart(long sessionStarted)

      Parameters:
        `sessionStarted` - Time in seconds
      Returns:
        true if the particular token was issued before the given session start time. Which means that token cannot be issued by the particular session

    - #### getIat

          public Long getIat()

    - #### getIssuedAt

          @Deprecated
          public int getIssuedAt()

      Deprecated. int will overflow with values after 2038. Use `getIat()` instead.

    - #### issuedNow

          public JsonWebToken issuedNow()

      Set issuedAt to the current time

    - #### iat

          public JsonWebToken iat(Long iat)

    - #### issuedAt

          @Deprecated
          public JsonWebToken issuedAt(int issuedAt)

      Deprecated. int will overflow with values after 2038. Use `iat(Long)` ()} instead.

    - #### getIssuer

          public String getIssuer()

    - #### issuer

          public JsonWebToken issuer(String issuer)

    - #### getAudience

          public String[] getAudience()

    - #### hasAudience

          public boolean hasAudience(String audience)

    - #### audience

          public JsonWebToken audience(String... audience)

    - #### addAudience

          public JsonWebToken addAudience(String audience)

    - #### getSubject

          public String getSubject()

    - #### subject

          public JsonWebToken subject(String subject)

    - #### setSubject

          public void setSubject(String subject)

    - #### getType

          public String getType()

    - #### type

          public JsonWebToken type(String type)

    - #### getIssuedFor

          public String getIssuedFor()

      OAuth client the token was issued for.
      Returns:

    - #### issuedFor

          public JsonWebToken issuedFor(String issuedFor)

    - #### getOtherClaims

          public Map<String,Object> getOtherClaims()

      This is a map of any other claims and data that might be in the IDToken. Could be custom claims set up by the auth server
      Returns:

    - #### setOtherClaims

          public void setOtherClaims(String name,
                                     Object value)

    - #### getCategory

          public TokenCategory getCategory()

      Specified by:
        `getCategory` in interface `Token`

Copyright © 2021 JBoss by Red Hat. All rights reserved.