com.nimbusds.oauth2.sdk.token
Class Token

java.lang.Object
  extended by com.nimbusds.oauth2.sdk.id.Identifier
      extended by com.nimbusds.oauth2.sdk.token.Token
All Implemented Interfaces:
net.minidev.json.JSONAware
Direct Known Subclasses:
AccessToken, RefreshToken

public abstract class Token
extends Identifier

The base abstract class for access and refresh tokens.

Related specifications:

Version:
$version$ (2014-01-18)
Author:
Vladimir Dzhuvinov

Constructor Summary
protected Token()
          Creates a new token with a randomly generated value.
protected Token(int length)
          Creates a new token with a randomly generated value of the specified length.
protected Token(String value)
          Creates a new token with the specified value.
 
Method Summary
abstract  net.minidev.json.JSONObject toJSONObject()
          Returns the token parameters as a JSON object, as required for the composition of an access token response.
 
Methods inherited from class com.nimbusds.oauth2.sdk.id.Identifier
equals, getValue, hashCode, toJSONString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Token

protected Token(String value)
Creates a new token with the specified value.

Parameters:
value - The token value. Must not be null or empty string.

Token

protected Token(int length)
Creates a new token with a randomly generated value of the specified length. The value will be made up of mixed-case alphanumeric ASCII characters.

Parameters:
length - The number of characters. Must be a positive integer.

Token

protected Token()
Creates a new token with a randomly generated value. The value will be made up of 32 mixed-case alphanumeric ASCII characters.

Method Detail

toJSONObject

public abstract net.minidev.json.JSONObject toJSONObject()
Returns the token parameters as a JSON object, as required for the composition of an access token response. See OAuth 2.0 (RFC 6749), section 5.1.

Note that JSONObject implements Map<String,Object>.

Example:

 {
   "access_token"      : "2YotnFZFEjr1zCsicMWpAA",
   "token_type"        : "example",
   "expires_in"        : 3600,
   "example_parameter" : "example_value"
 }
 

Returns:
The token parameters as a JSON object.


Copyright © 2013 NimbusDS. All Rights Reserved.