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 userId, 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.
 RefreshToken getRefreshToken()
          Retrieves the refresh token associated with this access token.
 java.lang.String getUserId()
          Retrieves the user ID 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, getScopeIds, 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 userId,
                   java.lang.String applicationId,
                   java.util.Date generateTimestamp,
                   long maxValiditySeconds,
                   java.util.Set<java.lang.String> scopeIds)
Construct a new access token instance.

Parameters:
userId - The user ID of the resource owner this access token is associated with or the application ID if resource owner authentication was not performed.
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

getUserId

public java.lang.String getUserId()
Retrieves the user ID of the resource owner this access token is associated with. Some grant types don't require resource owner involvement (ie. client_credentials), the userId may be equal to the application ID in such cases.

Returns:
The user ID of the resource owner this access token is associated with or equal to the application ID if resource owner authentication was not performed.

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.