public abstract class AccessToken extends Token
Related specifications:
DEFAULT_BYTE_LENGTH
Constructor and Description |
---|
AccessToken(AccessTokenType type)
Creates a new minimal access token with a randomly generated 256-bit
(32-byte) value, Base64URL-encoded.
|
AccessToken(AccessTokenType type,
int byteLength)
Creates a new minimal access token with a randomly generated value
of the specified byte length, Base64URL-encoded.
|
AccessToken(AccessTokenType type,
int byteLength,
long lifetime,
Scope scope)
Creates a new access token with a randomly generated value
of the specified byte length, Base64URL-encoded, and optional
lifetime and scope.
|
AccessToken(AccessTokenType type,
long lifetime,
Scope scope)
Creates a new access token with a randomly generated 256-bit
(32-byte) value, Base64URL-encoded.
|
AccessToken(AccessTokenType type,
String value)
Creates a new minimal access token with the specified value.
|
AccessToken(AccessTokenType type,
String value,
long lifetime,
Scope scope)
Creates a new access token with the specified value and optional
lifetime and scope.
|
Modifier and Type | Method and Description |
---|---|
long |
getLifetime()
Returns the lifetime of this access token.
|
Set<String> |
getParameterNames()
Returns the token parameter names included in the JSON object, as
required for the composition of an access token response.
|
Scope |
getScope()
Returns the scope of this access token.
|
AccessTokenType |
getType()
Returns the access token type.
|
static AccessToken |
parse(net.minidev.json.JSONObject jsonObject)
Parses an access token from a JSON object access token response.
|
static AccessToken |
parse(String header)
Parses an
Authorization HTTP request header value for an
access token. |
abstract String |
toAuthorizationHeader()
Returns the
Authorization HTTP request header value for this
access token. |
net.minidev.json.JSONObject |
toJSONObject()
Returns the token parameters as a JSON object, as required for the
composition of an access token response.
|
String |
toJSONString()
Returns the JSON string representation of this identifier.
|
public AccessToken(AccessTokenType type)
type
- The access token type. Must not be null
.public AccessToken(AccessTokenType type, int byteLength)
type
- The access token type. Must not be null
.byteLength
- The byte length of the value to generate. Must be
greater than one.public AccessToken(AccessTokenType type, long lifetime, Scope scope)
type
- The access token type. Must not be null
.lifetime
- The lifetime in seconds, 0 if not specified.scope
- The scope, null
if not specified.public AccessToken(AccessTokenType type, int byteLength, long lifetime, Scope scope)
type
- The access token type. Must not be null
.byteLength
- The byte length of the value to generate. Must be
greater than one.lifetime
- The lifetime in seconds, 0 if not specified.scope
- The scope, null
if not specified.public AccessToken(AccessTokenType type, String value)
type
- The access token type. Must not be null
.value
- The access token value. Must not be null
or
empty string.public AccessToken(AccessTokenType type, String value, long lifetime, Scope scope)
type
- The access token type. Must not be null
.value
- The access token value. Must not be null
or
empty string.lifetime
- The lifetime in seconds, 0 if not specified.scope
- The scope, null
if not specified.public AccessTokenType getType()
public long getLifetime()
public Scope getScope()
null
if not specified.public Set<String> getParameterNames()
Token
getParameterNames
in class Token
public net.minidev.json.JSONObject toJSONObject()
Token
Note that JSONObject implements Map<String,Object>.
Example:
{ "access_token" : "2YotnFZFEjr1zCsicMWpAA", "token_type" : "example", "expires_in" : 3600, "example_parameter" : "example_value" }
toJSONObject
in class Token
public String toJSONString()
Identifier
toJSONString
in interface net.minidev.json.JSONAware
toJSONString
in class Identifier
public abstract String toAuthorizationHeader()
Authorization
HTTP request header value for this
access token.Authorization
header value.public static AccessToken parse(net.minidev.json.JSONObject jsonObject) throws ParseException
jsonObject
- The JSON object to parse. Must not be
null
.ParseException
- If the JSON object couldn't be parsed to an
access token.public static AccessToken parse(String header) throws ParseException
Authorization
HTTP request header value for an
access token. Only bearer access token are supported.header
- The Authorization
header value to parse. Must
not be null
.ParseException
- If the Authorization
header value
couldn't be parsed to an access token.Copyright © 2016 Connect2id Ltd.. All rights reserved.