Class AccessToken

java.lang.Object
com.codename1.backend.security.oauth2.client.credentials.AccessToken

public final class AccessToken extends Object

An access token this server obtained to call another one.

The value is a credential: toString() never prints it, so a token that ends up in a log line or an exception message names its type, scopes and expiry and nothing anyone could replay.

  • Constructor Details

    • AccessToken

      public AccessToken(String tokenValue, String tokenType, long expiresAtMillis, Set<String> scopes)
      Parameters:
      tokenValue - the token, as the endpoint issued it
      tokenType - the type the endpoint named, normally Bearer
      expiresAtMillis - when it stops being accepted, in epoch milliseconds
      scopes - what it was issued for; empty when the endpoint did not say
  • Method Details

    • getTokenValue

      public String getTokenValue()
    • getTokenType

      public String getTokenType()
    • getExpiresAtMillis

      public long getExpiresAtMillis()
    • getScopes

      public Set<String> getScopes()
    • isExpired

      public boolean isExpired(long nowMillis)
      True once nowMillis has reached the expiry.
    • toAuthorizationHeader

      public String toAuthorizationHeader()
      The value of an Authorization header that presents this token.
    • toString

      public String toString()
      Description copied from class: Object
      Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
      Overrides:
      toString in class Object