com.unboundid.directory.sdk.broker.types
Class AccessToken

java.lang.Object
  extended by com.unboundid.directory.sdk.broker.types.Token
      extended by com.unboundid.directory.sdk.broker.types.AccessToken

@NotExtensible
@Mutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class AccessToken
extends Token

This class provides a data structure for working with OAuth2 access tokens.


Constructor Summary
AccessToken(java.lang.String username, java.util.Set<java.lang.String> authorities, java.lang.String applicationId, java.util.Date generateTimestamp, long maxValiditySeconds, java.util.Set<java.lang.String> scopeIds)
          Construct a new access token instance.
 
Method Summary
 boolean equals(java.lang.Object o)
          Indicates whether the provided object is equal to this access token.
 java.util.Set<java.lang.String> getAuthorities()
          Retrieves the authorities of the resource owner.
 RefreshToken getRefreshToken()
          Retrieves the refresh token associated with this access token.
 java.util.Set<java.lang.String> getScopeIds()
          Retrieves the set of scope IDs for which the client has been authorized.
 java.lang.String getUsername()
          Retrieves the username of the resource owner this access token is associated with.
 int hashCode()
          Retrieves a hash code for this access token.
 void setRefreshToken(RefreshToken refreshToken)
          Sets the refresh token associated with this access token.
protected  void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this access token to the provided buffer.
 
Methods inherited from class com.unboundid.directory.sdk.broker.types.Token
getApplicationId, getGenerateTimestamp, getMaxValiditySeconds, getValue, isExpired, setValue, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AccessToken

public AccessToken(java.lang.String username,
                   java.util.Set<java.lang.String> authorities,
                   java.lang.String applicationId,
                   java.util.Date generateTimestamp,
                   long maxValiditySeconds,
                   java.util.Set<java.lang.String> scopeIds)
Construct a new access token instance.

Parameters:
username - The username of the resource owner this access token is associated with or null if resource owner authentication was not performed.
authorities - The authorities of the resource owner or empty if resource owner authentication was not performed. Must not be null.
applicationId - The application ID with which this token is associated. Must not be null.
generateTimestamp - The time that this token was generated. Must not be null.
maxValiditySeconds - The maximum length of time in seconds that this token will be considered valid. Must not be null and must not be negative.
scopeIds - The set of scopes for which the client has been authorized. Must not be null.
Method Detail

getUsername

public java.lang.String getUsername()
Retrieves the username of the resource owner this access token is associated with. Some grant types don't require resource owner involvement (ie. client_credentials), the username may be null.

Returns:
The username of the resource owner this access token is associated with or null if resource owner authentication was not performed.

getAuthorities

public java.util.Set<java.lang.String> getAuthorities()
Retrieves the authorities of the resource owner. Some grant types don't require resource owner involvement (ie. client_credentials), the authorities may be empty.

Returns:
The authorities of the resource owner or empty if resource owner authentication was not performed.

getScopeIds

public java.util.Set<java.lang.String> getScopeIds()
Retrieves the set of scope IDs for which the client has been authorized.

Returns:
The set of scope IDs for which the client has been authorized.

getRefreshToken

public RefreshToken getRefreshToken()
Retrieves the refresh token associated with this access token.

Returns:
The refresh token associated with this access token or null if there is no associated refresh token.

setRefreshToken

public void setRefreshToken(RefreshToken refreshToken)
Sets the refresh token associated with this access token.

Parameters:
refreshToken - The refresh token associated with this access token.

hashCode

public int hashCode()
Retrieves a hash code for this access token.

Overrides:
hashCode in class Token
Returns:
A hash code for this access token.

equals

public boolean equals(java.lang.Object o)
Indicates whether the provided object is equal to this access token.

Overrides:
equals in class Token
Parameters:
o - The object for which to make the determination.
Returns:
true if the provided object is equal to this authorization code, or false if not.

toString

protected void toString(java.lang.StringBuilder buffer)
Appends a string representation of this access token to the provided buffer.

Specified by:
toString in class Token
Parameters:
buffer - The buffer to which the string representation should be appended.