Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class AccessToken

  1. Object
  2. AccessToken

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.

Constructors

public AccessToken(String tokenValue, String tokenType, long expiresAtMillis, Set<String> scopes)

Methods

public String getTokenValue()
public String getTokenType()
public long getExpiresAtMillis()
public Set<String> getScopes()
public boolean isExpired(long nowMillis)True once nowMillis has reached the expiry.
public String toAuthorizationHeader()The value of an Authorization header that presents this token.
public String toString()Returns a string representation of the object.

Inherited methods

Constructor details

AccessToken

public AccessToken(String tokenValue, String tokenType, long expiresAtMillis, Set<String> scopes)

Parameters

tokenValue String
the token, as the endpoint issued it
tokenType String
the type the endpoint named, normally Bearer
expiresAtMillis long
when it stops being accepted, in epoch milliseconds
scopes Set<String>
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()
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())