Package com.nimbusds.oauth2.sdk.token
Class DPoPAccessToken
- java.lang.Object
-
- com.nimbusds.oauth2.sdk.id.Identifier
-
- com.nimbusds.oauth2.sdk.token.Token
-
- com.nimbusds.oauth2.sdk.token.AccessToken
-
- com.nimbusds.oauth2.sdk.token.DPoPAccessToken
-
- All Implemented Interfaces:
Serializable
,Comparable<Identifier>
,net.minidev.json.JSONAware
@Immutable public class DPoPAccessToken extends AccessToken
DPoP access token.Example DPoP access token serialised to JSON:
{ "access_token" : "aeniniu3oogh2quoot7Aipie9IeGh3te", "token_type" : "DPoP", "expires_in" : 3600, "scope" : "read write" }
The above example token serialised to a HTTP Authorization header:
Authorization: DPoP aeniniu3oogh2quoot7Aipie9IeGh3te
Related specifications:
- OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP) (draft-ietf-oauth-dpop-03)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.nimbusds.oauth2.sdk.id.Identifier
DEFAULT_BYTE_LENGTH, secureRandom
-
-
Constructor Summary
Constructors Constructor Description DPoPAccessToken(String value)
Creates a new minimal DPoP access token with the specified value.DPoPAccessToken(String value, long lifetime, Scope scope)
Creates a new DPoP access token with the specified value and optional lifetime and scope.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
static DPoPAccessToken
parse(HTTPRequest request)
Parses an HTTP request for a bearer access token.static DPoPAccessToken
parse(String header)
Parses an HTTP Authorization header for a DPoP access token.static DPoPAccessToken
parse(Map<String,List<String>> parameters)
Parses a query or form parameters map for a bearer access token.static DPoPAccessToken
parse(net.minidev.json.JSONObject jsonObject)
Parses a DPoP access token from a JSON object access token response.String
toAuthorizationHeader()
Returns the HTTP Authorization header value for this DPoP access token.-
Methods inherited from class com.nimbusds.oauth2.sdk.token.AccessToken
getLifetime, getParameterNames, getScope, getType, parse, toJSONObject, toJSONString
-
Methods inherited from class com.nimbusds.oauth2.sdk.id.Identifier
compareTo, getValue, hashCode, toString, toStringList
-
-
-
-
Constructor Detail
-
DPoPAccessToken
public DPoPAccessToken(String value)
Creates a new minimal DPoP access token with the specified value. The optional lifetime and scope are left undefined.- Parameters:
value
- The access token value. Must not benull
or empty string.
-
DPoPAccessToken
public DPoPAccessToken(String value, long lifetime, Scope scope)
Creates a new DPoP access token with the specified value and optional lifetime and scope.- Parameters:
value
- The access token value. Must not benull
or empty string.lifetime
- The lifetime in seconds, 0 if not specified.scope
- The scope,null
if not specified.
-
-
Method Detail
-
toAuthorizationHeader
public String toAuthorizationHeader()
Returns the HTTP Authorization header value for this DPoP access token.Example:
Authorization: DPoP aeniniu3oogh2quoot7Aipie9IeGh3te
- Specified by:
toAuthorizationHeader
in classAccessToken
- Returns:
- The HTTP Authorization header.
-
equals
public boolean equals(Object object)
- Overrides:
equals
in classIdentifier
-
parse
public static DPoPAccessToken parse(net.minidev.json.JSONObject jsonObject) throws ParseException
Parses a DPoP access token from a JSON object access token response.- Parameters:
jsonObject
- The JSON object to parse. Must not benull
.- Returns:
- The DPoP access token.
- Throws:
ParseException
- If the JSON object couldn't be parsed to a DPoP access token.
-
parse
public static DPoPAccessToken parse(String header) throws ParseException
Parses an HTTP Authorization header for a DPoP access token.- Parameters:
header
- The HTTP Authorization header value to parse. May benull
if the header is missing, in which case an exception will be thrown.- Returns:
- The DPoP access token.
- Throws:
ParseException
- If the HTTP Authorization header value couldn't be parsed to a DPoP access token.
-
parse
public static DPoPAccessToken parse(Map<String,List<String>> parameters) throws ParseException
Parses a query or form parameters map for a bearer access token.- Parameters:
parameters
- The query parameters. Must not benull
.- Returns:
- The bearer access token.
- Throws:
ParseException
- If a bearer access token wasn't found in the parameters.
-
parse
public static DPoPAccessToken parse(HTTPRequest request) throws ParseException
Parses an HTTP request for a bearer access token.- Parameters:
request
- The HTTP request to parse. Must not benull
.- Returns:
- The bearer access token.
- Throws:
ParseException
- If a bearer access token wasn't found in the HTTP request.
-
-