Class AccessTokenResponse

java.lang.Object
org.openhab.core.auth.client.oauth2.AccessTokenResponse
All Implemented Interfaces:
Serializable, Cloneable

@NonNullByDefault public final class AccessTokenResponse extends Object implements Serializable, Cloneable
This is the Access Token Response, a simple value-object that holds the result of the from an Access Token Request, as listed in RFC 6749: 4.1.4 - Authorization Code grant - Access Token Response, 4.2.2 - Implicit Grant - Access Token Response, 4.3.3 - Resource Owner Password Credentials Grant - Access Token Response 4.4.3 - Client Credentials Grant - Access Token Response
Author:
Michael Bock - Initial contribution, Gary Tse - Adaptation for Eclipse SmartHome
See Also:
  • Constructor Details

    • AccessTokenResponse

      public AccessTokenResponse()
  • Method Details

    • getExtraFields

      public Map<String,String> getExtraFields()
      Returns the additional provider-specific fields from the token response.

      Note: the returned map may contain sensitive information in non-standard fields. Callers MUST take care not to log, persist, or expose these values without first ensuring that doing so is appropriate in their security context.

      Returns:
      a map of additional fields as provided by the authorization server
    • setExtraFields

      public void setExtraFields(Map<String,String> extraFields)
    • isExpired

      public boolean isExpired(Instant givenTime, int tokenExpiresInBuffer)
      Calculate if the token is expired against the given time. It also returns true even if the token is not initialized (i.e. object newly created).
      Parameters:
      givenTime - To calculate if the token is expired against the givenTime.
      tokenExpiresInBuffer - A positive integer in seconds to act as additional buffer to the calculation. This causes the OAuthToken to expire earlier then the stated expiry-time given by the authorization server.
      Returns:
      true if object is not-initialized, or expired, or expired early due to buffer
    • getAccessToken

      public @Nullable String getAccessToken()
    • setAccessToken

      public void setAccessToken(@Nullable String accessToken)
    • getTokenType

      public @Nullable String getTokenType()
    • setTokenType

      public void setTokenType(@Nullable String tokenType)
    • getExpiresIn

      public long getExpiresIn()
    • setExpiresIn

      public void setExpiresIn(long expiresIn)
    • getRefreshToken

      public @Nullable String getRefreshToken()
    • setRefreshToken

      public void setRefreshToken(@Nullable String refreshToken)
    • getScope

      public @Nullable String getScope()
    • setScope

      public void setScope(@Nullable String scope)
    • getState

      public @Nullable String getState()
    • setState

      public void setState(@Nullable String state)
    • getCreatedOn

      public @Nullable Instant getCreatedOn()
    • setCreatedOn

      public void setCreatedOn(@Nullable Instant createdOn)
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object thatAuthTokenObj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object