Package com.nimbusds.oauth2.sdk.token
Class AccessTokenParseUtils
java.lang.Object
com.nimbusds.oauth2.sdk.token.AccessTokenParseUtils
Access token parse utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic AccessTokenType
Determines the access token type from anAuthorization
HTTP request header.static void
parseAndEnsureTypeFromJSONObject
(net.minidev.json.JSONObject jsonObject, AccessTokenType type) Parses atoken_type
from a JSON object and ensures it matches the specified.static List<AuthorizationDetail>
parseAuthorizationDetailsFromJSONObject
(net.minidev.json.JSONObject jsonObject) Parses anauthorization_details
parameter from a JSON object.static TokenTypeURI
parseIssuedTokenTypeFromJSONObject
(net.minidev.json.JSONObject jsonObject) Parses anissued_token_type
parameter from a JSON object.static long
parseLifetimeFromJSONObject
(net.minidev.json.JSONObject jsonObject) Parses an access tokenexpires_in
parameter from a JSON object.static Scope
parseScopeFromJSONObject
(net.minidev.json.JSONObject jsonObject) Parses ascope
parameter from a JSON object.static String
parseValueFromAuthorizationHeader
(String header, AccessTokenType type) Parses an access token value from anAuthorization
HTTP request header.static String
parseValueFromJSONObject
(net.minidev.json.JSONObject params) Parses an {code access_token} value from a JSON object.static String
parseValueFromQueryParameters
(Map<String, List<String>> parameters) Parses anaccess_token
value from a query or form parameters.static String
parseValueFromQueryParameters
(Map<String, List<String>> parameters, AccessTokenType type) Parses anaccess_token
values from a query or form parameters.
-
Method Details
-
parseAndEnsureTypeFromJSONObject
public static void parseAndEnsureTypeFromJSONObject(net.minidev.json.JSONObject jsonObject, AccessTokenType type) throws ParseException Parses atoken_type
from a JSON object and ensures it matches the specified.- Parameters:
jsonObject
- The JSON object. Must not benull
.type
- The expected token type. Must not benull
.- Throws:
ParseException
- If parsing failed.
-
parseValueFromJSONObject
public static String parseValueFromJSONObject(net.minidev.json.JSONObject params) throws ParseException Parses an {code access_token} value from a JSON object.- Parameters:
params
- The JSON object. Must not benull
.- Returns:
- The access token value.
- Throws:
ParseException
- If parsing failed.
-
parseLifetimeFromJSONObject
public static long parseLifetimeFromJSONObject(net.minidev.json.JSONObject jsonObject) throws ParseException Parses an access tokenexpires_in
parameter from a JSON object.- Parameters:
jsonObject
- The JSON object. Must not benull
.- Returns:
- The access token lifetime, in seconds, zero if not specified.
- Throws:
ParseException
- If parsing failed.
-
parseScopeFromJSONObject
public static Scope parseScopeFromJSONObject(net.minidev.json.JSONObject jsonObject) throws ParseException Parses ascope
parameter from a JSON object.- Parameters:
jsonObject
- The JSON object. Must not benull
.- Returns:
- The scope,
null
if not specified. - Throws:
ParseException
- If parsing failed.
-
parseAuthorizationDetailsFromJSONObject
public static List<AuthorizationDetail> parseAuthorizationDetailsFromJSONObject(net.minidev.json.JSONObject jsonObject) throws ParseException Parses anauthorization_details
parameter from a JSON object.- Parameters:
jsonObject
- The JSON object. Must not benull
.- Returns:
- The authorisation details,
null
if not specified. - Throws:
ParseException
- If parsing failed.
-
parseIssuedTokenTypeFromJSONObject
public static TokenTypeURI parseIssuedTokenTypeFromJSONObject(net.minidev.json.JSONObject jsonObject) throws ParseException Parses anissued_token_type
parameter from a JSON object.- Parameters:
jsonObject
- The JSON object. Must not benull
.- Returns:
- The issued token type,
null
if not specified. - Throws:
ParseException
- If parsing failed.
-
parseValueFromAuthorizationHeader
public static String parseValueFromAuthorizationHeader(String header, AccessTokenType type) throws ParseException Parses an access token value from anAuthorization
HTTP request header.- Parameters:
header
- TheAuthorization
header value,null
if not specified.type
- The expected access token type, such asAccessTokenType.BEARER
orAccessTokenType.DPOP
. Must not benull
.- Returns:
- The access token value.
- Throws:
ParseException
- If parsing failed.
-
parseValueFromQueryParameters
public static String parseValueFromQueryParameters(Map<String, List<String>> parameters, AccessTokenType type) throws ParseExceptionParses anaccess_token
values from a query or form parameters.- Parameters:
parameters
- The parameters. Must not benull
.type
- The expected access token type, such asAccessTokenType.BEARER
orAccessTokenType.DPOP
. Must not benull
.- Returns:
- The access token value.
- Throws:
ParseException
- If parsing failed.
-
parseValueFromQueryParameters
public static String parseValueFromQueryParameters(Map<String, List<String>> parameters) throws ParseExceptionParses anaccess_token
value from a query or form parameters.- Parameters:
parameters
- The query parameters. Must not benull
.- Returns:
- The access token value.
- Throws:
ParseException
- If parsing failed.
-
determineAccessTokenTypeFromAuthorizationHeader
public static AccessTokenType determineAccessTokenTypeFromAuthorizationHeader(String header) throws ParseException Determines the access token type from anAuthorization
HTTP request header.- Parameters:
header
- TheAuthorization
header value. Must not benull
.- Returns:
- The access token type.
- Throws:
ParseException
- If parsing failed.
-