Class AccessToken

java.lang.Object
com.iizix.server.oauth.AccessToken

public class AccessToken extends Object
The access token wrapper for OAuth 2.0 and OAuth 1.0a access tokens.
Author:
Christopher Mindus
  • Constructor Summary

    Constructors
    Constructor
    Description
    AccessToken(com.github.scribejava.core.model.OAuth1AccessToken accessToken1, com.github.scribejava.core.model.OAuth1RequestToken requestToken)
    Constructs the access token for OAuth 1.0a.
    AccessToken(com.github.scribejava.core.model.OAuth2AccessToken accessToken2)
    Constructs the access token for OAuth 2.0.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns if two access tokens are equal.
    Returns the access token.
    long
    Gets the expiry date.
    int
    Gets the hash code.
    boolean
    isValid(long additionalTime)
    Checks if the access token would expire within the requested additional time, e.g.
    Gets a String.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AccessToken

      public AccessToken(com.github.scribejava.core.model.OAuth2AccessToken accessToken2)
      Constructs the access token for OAuth 2.0.
      Parameters:
      accessToken2 - The access token.
      Throws:
      NullPointerException - If the {code accessToken2} parameter is null.
    • AccessToken

      public AccessToken(com.github.scribejava.core.model.OAuth1AccessToken accessToken1, com.github.scribejava.core.model.OAuth1RequestToken requestToken)
      Constructs the access token for OAuth 1.0a.
      Parameters:
      accessToken1 - The access token.
      requestToken - The request token used to get the access token.
      Throws:
      NullPointerException - If the {code accessToken1} or {code requestToken} parameter is null.
  • Method Details

    • isValid

      public boolean isValid(long additionalTime)
      Checks if the access token would expire within the requested additional time, e.g. 20_000 ms (20 seconds) that an operation would require to run.
      Returns:
      true If the access token has expired or would expire, false if it's OK to use it.
    • getExpiresTime

      public long getExpiresTime()
      Gets the expiry date.
      Returns:
      The access token expiry time in milliseconds since the epoch, zero if unknown.
    • getAccessToken

      public String getAccessToken()
      Returns the access token.
      Returns:
      The access token String.
    • hashCode

      public int hashCode()
      Gets the hash code.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code.
    • equals

      public boolean equals(Object obj)
      Returns if two access tokens are equal.
      Overrides:
      equals in class Object
      Parameters:
      obj - The other object to compare with.
      Returns:
      The equality flag.
    • toString

      public String toString()
      Gets a String.
      Overrides:
      toString in class Object
      Returns:
      The string.