Class OauthTokenImpl

java.lang.Object
org.refcodes.web.OauthTokenImpl
All Implemented Interfaces:
org.refcodes.mixin.Disposable, org.refcodes.mixin.Disposable.Disposedable, org.refcodes.mixin.DisposedAccessor, org.refcodes.mixin.ValidAccessor, OauthToken

public class OauthTokenImpl
extends Object
implements OauthToken
Implementation of the OauthToken interface.
  • Field Details

    • _accessToken

      protected String _accessToken
    • _refreshToken

      protected String _refreshToken
    • _tokenType

      protected String _tokenType
    • _expiresIn

      protected Integer _expiresIn
    • _refreshExpiresIn

      protected Integer _refreshExpiresIn
    • _scope

      protected String _scope
    • _notBeforePolicy

      protected String _notBeforePolicy
    • _sessionState

      protected String _sessionState
  • Constructor Details

    • OauthTokenImpl

      public OauthTokenImpl​(OauthToken aOauthToken)
      Creates a new instance of the OauthTokenImpl with the current time being stored for determining validity of the access token via isValid() as of getExpiresIn().
      Parameters:
      aOauthToken - The OAuth data to use.
    • OauthTokenImpl

      public OauthTokenImpl​(String aAccessToken, String aRefreshToken, String aTokenType, Integer aExpiresIn, String aScope)
      Creates a new instance of the OauthTokenImpl with the current time being stored for determining validity of the access token via isValid() as of getExpiresIn().
      Parameters:
      aAccessToken - The access token
      aRefreshToken - The refresh token
      aTokenType - The token type
      aExpiresIn - The expires-time in seconds
      aScope - The scope
    • OauthTokenImpl

      public OauthTokenImpl​(String aAccessToken, String aRefreshToken, String aTokenType, String aNotBeforePolicy, Integer aExpiresIn, Integer aRefreshExpiresIn, String aScope, String aSessionState)
      Creates a new instance of the OauthTokenImpl with the current time being stored for determining validity of the access token via isValid() as of getExpiresIn().
      Parameters:
      aAccessToken - The access token
      aRefreshToken - The refresh token
      aTokenType - The token type
      aNotBeforePolicy - The not-before-policy.
      aExpiresIn - The expires-time in seconds
      aRefreshExpiresIn - The refresh's expires-time in seconds
      aScope - The scope
      aSessionState - The session state.
    • OauthTokenImpl

      public OauthTokenImpl​(HttpBodyMap aOauthToken)
      Creates a new instance of the OauthTokenImpl with the current time being stored for determining validity of the access token via isValid() as of getExpiresIn().
      Parameters:
      aOauthToken - The HttpBodyMap containing the OauthToken data.
  • Method Details

    • dispose

      public void dispose()
      Specified by:
      dispose in interface org.refcodes.mixin.Disposable
    • isDisposed

      public boolean isDisposed()
      Specified by:
      isDisposed in interface org.refcodes.mixin.DisposedAccessor
    • getAccessToken

      public String getAccessToken()
      Returns the access token. "The access token string as issued by the authorization server." See "https://www.oauth.com/oauth2-servers/access-tokens/access-token-response"
      Specified by:
      getAccessToken in interface OauthToken
      Returns:
      the access token.
    • getRefreshToken

      public String getRefreshToken()
      Returns the refresh token. "The access token string as issued by the authorization server." See "https://www.oauth.com/oauth2-servers/access-tokens/access-token-response"
      Specified by:
      getRefreshToken in interface OauthToken
      Returns:
      the refresh token.
    • getScope

      public String getScope()
      Returns the OAuth scope. "If the scope the user granted is identical to the scope the app requested, this parameter is optional. If the granted scope is different from the requested scope, such as if the user modified the scope, then this parameter is required." See "https://www.oauth.com/oauth2-servers/access-tokens/access-token-response"
      Specified by:
      getScope in interface OauthToken
      Returns:
      the OAuth scope.
    • getTokenType

      public String getTokenType()
      Returns the token type. "The type of token this is, typically just the string bearer" See "https://www.oauth.com/oauth2-servers/access-tokens/access-token-response"
      Specified by:
      getTokenType in interface OauthToken
      Returns:
      the token type.
    • getExpiresIn

      public Integer getExpiresIn()
      Returns the time in seconds till the access token (OauthToken.getAccessToken()) expires. "If the access token expires, the server should reply with the duration of time the access token is granted for." See "https://www.oauth.com/oauth2-servers/access-tokens/access-token-response"
      Specified by:
      getExpiresIn in interface OauthToken
      Returns:
      the Expires-In time in seconds
    • getNotBeforePolicy

      public String getNotBeforePolicy()
      Returns the not-before-policy.
      Specified by:
      getNotBeforePolicy in interface OauthToken
      Returns:
      the not-before-policy.
    • getSessionState

      public String getSessionState()
      Returns the session state.
      Specified by:
      getSessionState in interface OauthToken
      Returns:
      the session state.
    • getRefreshExpiresIn

      public Integer getRefreshExpiresIn()
      Returns the time in seconds till the refresh token (OauthToken.getRefreshToken()) expires.
      Specified by:
      getRefreshExpiresIn in interface OauthToken
      Returns:
      the Expires-In time in seconds
    • isValid

      public boolean isValid()
      Returns always true if no "expires in" time (OauthToken.getExpiresIn()) has been set!
      Specified by:
      isValid in interface OauthToken
      Specified by:
      isValid in interface org.refcodes.mixin.ValidAccessor
    • fromHttpBodyMap

      protected void fromHttpBodyMap​(HttpBodyMap aOauthToken)
      Sets the internal fields with the data from the HttpBodyMap as of the OauthField definitions.
      Parameters:
      aOauthToken - The HttpBodyMap from which to gather the data.