java.lang.Object
com.developer.nefarious.zjoule.plugin.models.AccessToken

public class AccessToken extends Object
Represents an OAuth2 access token along with its metadata and expiration details.

The AccessToken class is used to store information about an OAuth2 access token, including the token string, its type, expiration time, scope, and additional metadata. It also tracks the time the token was received, allowing for validation of its validity based on the expiration time.

  • Constructor Details

    • AccessToken

      public AccessToken()
      Default constructor that initializes the receivedAt field to the current time.

      The receivedAt field is used to calculate the token's validity duration based on its expiresIn value.

  • Method Details

    • getAccessToken

      public String getAccessToken()
      Retrieves the access token string.
      Returns:
      the access token string.
    • getExpiresIn

      public long getExpiresIn()
      Retrieves the expiration time in seconds.
      Returns:
      the expiration time in seconds.
    • getJti

      public String getJti()
      Retrieves the unique token identifier.
      Returns:
      the token's unique identifier.
    • getReceivedAt

      public Date getReceivedAt()
      Retrieves the time the token was received.
      Returns:
      the Date when the token was received.
    • getScope

      public String getScope()
      Retrieves the scope of the token.
      Returns:
      the token's scope.
    • getTokenType

      public String getTokenType()
      Retrieves the token type (e.g., Bearer).
      Returns:
      the token type.
    • isValid

      public Boolean isValid()
      Checks if the access token is still valid based on its expiration time and the time it was received.
      Returns:
      true if the token is still valid; false otherwise.
    • setAccessToken

      public void setAccessToken(String accessToken)
      Sets the access token string.
      Parameters:
      accessToken - the access token string to set.
    • setExpiresIn

      public void setExpiresIn(long expiresIn)
      Sets the expiration time in seconds.
      Parameters:
      expiresIn - the expiration time in seconds to set.
    • setJti

      public void setJti(String jti)
      Sets the unique token identifier.
      Parameters:
      jti - the token's unique identifier to set.
    • setReceivedAt

      public void setReceivedAt(Date receivedAt)
      Sets the time the token was received.
      Parameters:
      receivedAt - the Date when the token was received.
    • setScope

      public void setScope(String scope)
      Sets the scope of the token.
      Parameters:
      scope - the token's scope to set.
    • setTokenType

      public void setTokenType(String tokenType)
      Sets the token type (e.g., Bearer).
      Parameters:
      tokenType - the token type to set.