com.ibm.security.access.mobile.authentication

Class OAuthToken

  • java.lang.Object
    • com.ibm.security.access.mobile.authentication.OAuthToken
  • All Implemented Interfaces:
    java.io.Serializable


    public final class OAuthToken
    extends java.lang.Object
    implements java.io.Serializable
    Stores the access token and optional refresh token for requests to protected resources.
    Since:
    1.0.0
    Version:
    1.2.8
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.String createAuthorizationHeader()
      Returns authorization header from token type and access token.
      java.lang.String getAccessToken()
      Returns the access token issued by the authorization server.
      java.util.HashMap<java.lang.String,java.lang.String> getAdditionalData()
      Returns the HashMap of additional OAuth attributes.
      java.util.Date getCreatedOn()
      Returns the date the token was created.
      java.util.Date getExpiresOn()
      Returns a Date object, representing when the token expires.
      java.lang.String getRefreshToken()
      Returns the refresh token, which can be used to obtain new access tokens using the same authorization grant.
      java.lang.String[] getScope()
      Returns the scope that the token has authorized.
      java.lang.String getTokenType()
      Returns the type of token issued.
      boolean hasTokenExpired()
      Returns whether the access token has expired.
      static OAuthToken retrieve()
      Loads the OAuthToken object from SharedPreferences.
      boolean shouldRefresh()
      The flag to indicate if the access token should be refreshed.
      void store()
      Saves the OAuthToken object to SharedPreferences.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • retrieve

        public static OAuthToken retrieve()
        Loads the OAuthToken object from SharedPreferences.
        Returns:
        the OAuthToken object if one has been stored previously or otherwise null
      • store

        public void store()
        Saves the OAuthToken object to SharedPreferences.
      • getAccessToken

        public java.lang.String getAccessToken()
        Returns the access token issued by the authorization server.
        Returns:
        the access token issued by the authorization server
      • getRefreshToken

        public java.lang.String getRefreshToken()
        Returns the refresh token, which can be used to obtain new access tokens using the same authorization grant.
        Returns:
        the refresh token
      • getExpiresOn

        public java.util.Date getExpiresOn()
        Returns a Date object, representing when the token expires.
        Returns:
        Date object
      • getTokenType

        public java.lang.String getTokenType()
        Returns the type of token issued.
        Returns:
        the type of token issued
      • getScope

        public java.lang.String[] getScope()
        Returns the scope that the token has authorized.
        Returns:
        the scope that the token has authorized
      • getCreatedOn

        public java.util.Date getCreatedOn()
        Returns the date the token was created.
        Returns:
        the Date the token was created
      • hasTokenExpired

        public boolean hasTokenExpired()
        Returns whether the access token has expired.
        Returns:
        true if the Date represented by expiresOn was before, false otherwise
      • createAuthorizationHeader

        public java.lang.String createAuthorizationHeader()
        Returns authorization header from token type and access token.
        Returns:
        a String of the authorization header, e.g. Bearer ABCD1234
      • getAdditionalData

        public java.util.HashMap<java.lang.String,java.lang.String> getAdditionalData()
        Returns the HashMap of additional OAuth attributes.
        Returns:
        HashMap of additional OAuth attributes
      • shouldRefresh

        public boolean shouldRefresh()
        The flag to indicate if the access token should be refreshed.
        Returns:
        true if 90% of the token lifetime has elapsed since the token created date, otherwise false.