org.springframework.security.oauth2.common
Class DefaultOAuth2AccessToken

java.lang.Object
  extended by org.springframework.security.oauth2.common.DefaultOAuth2AccessToken
All Implemented Interfaces:
Serializable, OAuth2AccessToken

public class DefaultOAuth2AccessToken
extends Object
implements Serializable, OAuth2AccessToken

Basic access token for OAuth 2.

Author:
Ryan Heaton, Dave Syer, Rob Winch
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.springframework.security.oauth2.common.OAuth2AccessToken
ACCESS_TOKEN, BEARER_TYPE, EXPIRES_IN, OAUTH2_TYPE, REFRESH_TOKEN, SCOPE, TOKEN_TYPE
 
Constructor Summary
DefaultOAuth2AccessToken(OAuth2AccessToken accessToken)
          Copy constructor for access token.
DefaultOAuth2AccessToken(String value)
          Create an access token from the value provided.
 
Method Summary
 boolean equals(Object obj)
           
 Map<String,Object> getAdditionalInformation()
          Additional information that token granters would like to add to the token, e.g. to support new token types.
 Date getExpiration()
          The instant the token expires.
 int getExpiresIn()
           
 OAuth2RefreshToken getRefreshToken()
          The refresh token associated with the access token, if any.
 Set<String> getScope()
          The scope of the token.
 String getTokenType()
          The token type, as introduced in draft 11 of the OAuth 2 spec.
 String getValue()
          The token value.
 int hashCode()
           
 boolean isExpired()
          Convenience method for checking expiration
 void setAdditionalInformation(Map<String,Object> additionalInformation)
          Additional information that token granters would like to add to the token, e.g. to support new token types.
 void setExpiration(Date expiration)
          The instant the token expires.
protected  void setExpiresIn(int delta)
           
 void setRefreshToken(OAuth2RefreshToken refreshToken)
          The refresh token associated with the access token, if any.
 void setScope(Set<String> scope)
          The scope of the token.
 void setTokenType(String tokenType)
          The token type, as introduced in draft 11 of the OAuth 2 spec.
 DefaultOAuth2AccessToken setValue(String value)
           
 String toString()
           
static OAuth2AccessToken valueOf(Map<String,String> tokenParams)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultOAuth2AccessToken

public DefaultOAuth2AccessToken(String value)
Create an access token from the value provided.


DefaultOAuth2AccessToken

public DefaultOAuth2AccessToken(OAuth2AccessToken accessToken)
Copy constructor for access token.

Parameters:
accessToken -
Method Detail

setValue

public DefaultOAuth2AccessToken setValue(String value)

getValue

public String getValue()
The token value.

Specified by:
getValue in interface OAuth2AccessToken
Returns:
The token value.

getExpiresIn

public int getExpiresIn()
Specified by:
getExpiresIn in interface OAuth2AccessToken

setExpiresIn

protected void setExpiresIn(int delta)

getExpiration

public Date getExpiration()
The instant the token expires.

Specified by:
getExpiration in interface OAuth2AccessToken
Returns:
The instant the token expires.

setExpiration

public void setExpiration(Date expiration)
The instant the token expires.

Parameters:
expiration - The instant the token expires.

isExpired

public boolean isExpired()
Convenience method for checking expiration

Specified by:
isExpired in interface OAuth2AccessToken
Returns:
true if the expiration is befor ethe current time

getTokenType

public String getTokenType()
The token type, as introduced in draft 11 of the OAuth 2 spec. The spec doesn't define (yet) that the valid token types are, but says it's required so the default will just be "undefined".

Specified by:
getTokenType in interface OAuth2AccessToken
Returns:
The token type, as introduced in draft 11 of the OAuth 2 spec.

setTokenType

public void setTokenType(String tokenType)
The token type, as introduced in draft 11 of the OAuth 2 spec.

Parameters:
tokenType - The token type, as introduced in draft 11 of the OAuth 2 spec.

getRefreshToken

public OAuth2RefreshToken getRefreshToken()
The refresh token associated with the access token, if any.

Specified by:
getRefreshToken in interface OAuth2AccessToken
Returns:
The refresh token associated with the access token, if any.

setRefreshToken

public void setRefreshToken(OAuth2RefreshToken refreshToken)
The refresh token associated with the access token, if any.

Parameters:
refreshToken - The refresh token associated with the access token, if any.

getScope

public Set<String> getScope()
The scope of the token.

Specified by:
getScope in interface OAuth2AccessToken
Returns:
The scope of the token.

setScope

public void setScope(Set<String> scope)
The scope of the token.

Parameters:
scope - The scope of the token.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

valueOf

public static OAuth2AccessToken valueOf(Map<String,String> tokenParams)

getAdditionalInformation

public Map<String,Object> getAdditionalInformation()
Additional information that token granters would like to add to the token, e.g. to support new token types.

Specified by:
getAdditionalInformation in interface OAuth2AccessToken
Returns:
the additional information (default empty)

setAdditionalInformation

public void setAdditionalInformation(Map<String,Object> additionalInformation)
Additional information that token granters would like to add to the token, e.g. to support new token types. If the values in the map are primitive then remote communication is going to always work. It should also be safe to use maps (nested if desired), or something that is explicitly serializable by Jackson.

Parameters:
additionalInformation - the additional information to set


Copyright © 2012. All Rights Reserved.