|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.nimbusds.oauth2.sdk.id.Identifier
com.nimbusds.oauth2.sdk.token.Token
com.nimbusds.oauth2.sdk.token.AccessToken
com.nimbusds.oauth2.sdk.token.BearerAccessToken
@Immutable public final class BearerAccessToken
Bearer access token. This class is immutable.
Example bearer access token serialised to JSON:
{ "access_token" : "2YotnFZFEjr1zCsicMWpAA", "token_type" : "bearer", "expires_in" : 3600, "scope" : "read write" }
The above example token serialised to a HTTP Authorization header:
Authorization: Bearer 2YotnFZFEjr1zCsicMWpAA
Related specifications:
Field Summary |
---|
Fields inherited from class com.nimbusds.oauth2.sdk.id.Identifier |
---|
DEFAULT_BYTE_LENGTH |
Constructor Summary | |
---|---|
BearerAccessToken()
Creates a new minimal bearer access token with a randomly generated value. |
|
BearerAccessToken(int length)
Creates a new minimal bearer access token with a randomly generated value of the specified length. |
|
BearerAccessToken(int length,
long lifetime,
Scope scope)
Creates a new bearer access token with a randomly generated value of the specified length and optional lifetime and scope. |
|
BearerAccessToken(long lifetime,
Scope scope)
Creates a new bearer access token with a randomly generated value and the specified optional lifetime and scope. |
|
BearerAccessToken(String value)
Creates a new minimal bearer access token with the specified value. |
|
BearerAccessToken(String value,
long lifetime,
Scope scope)
Creates a new bearer access token with the specified value and optional lifetime and scope. |
Method Summary | |
---|---|
boolean |
equals(Object object)
Overrides Object.equals() . |
static BearerAccessToken |
parse(HTTPRequest request)
Parses an HTTP request for a bearer access token. |
static BearerAccessToken |
parse(net.minidev.json.JSONObject jsonObject)
Parses a bearer access token from a JSON object access token response. |
static BearerAccessToken |
parse(String header)
Parses an HTTP Authorization header for a bearer access token. |
String |
toAuthorizationHeader()
Returns the HTTP Authorization header value for this bearer access token. |
Methods inherited from class com.nimbusds.oauth2.sdk.token.AccessToken |
---|
compareTo, getLifetime, getScope, getType, toJSONObject, toJSONString |
Methods inherited from class com.nimbusds.oauth2.sdk.id.Identifier |
---|
getValue, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BearerAccessToken()
public BearerAccessToken(int length)
length
- The number of characters. Must be a positive integer.public BearerAccessToken(long lifetime, Scope scope)
lifetime
- The lifetime in seconds, 0 if not specified.scope
- The scope, null
if not specified.public BearerAccessToken(int length, long lifetime, Scope scope)
length
- The number of characters. Must be a positive
integer.lifetime
- The lifetime in seconds, 0 if not specified.scope
- The scope, null
if not specified.public BearerAccessToken(String value)
value
- The access token value. Must not be null
or
empty string.public BearerAccessToken(String value, long lifetime, Scope scope)
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.Method Detail |
---|
public String toAuthorizationHeader()
Example:
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9
toAuthorizationHeader
in class AccessToken
public boolean equals(Object object)
Identifier
Object.equals()
.
equals
in class Identifier
object
- The object to compare to.
true
if the objects have the same value, otherwise
false
.public static BearerAccessToken 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 a
bearer access token.public static BearerAccessToken parse(String header) throws ParseException
header
- The HTTP Authorization header value to parse. Must not
be null
.
ParseException
- If the HTTP Authorization header value
couldn't be parsed to a bearer access token.public static BearerAccessToken parse(HTTPRequest request) throws ParseException
request
- The HTTP request to parse. Must be GET or POST, and
not null
.
ParseException
- If a bearer access token wasn't found in the
HTTP request.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |