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 AccessTokenTypeDetermines the access token type from anAuthorizationHTTP request header.static voidparseAndEnsureTypeFromJSONObject(net.minidev.json.JSONObject jsonObject, AccessTokenType type) Parses atoken_typefrom a JSON object and ensures it matches the specified.static List<AuthorizationDetail>parseAuthorizationDetailsFromJSONObject(net.minidev.json.JSONObject jsonObject) Parses anauthorization_detailsparameter from a JSON object.static TokenTypeURIparseIssuedTokenTypeFromJSONObject(net.minidev.json.JSONObject jsonObject) Parses anissued_token_typeparameter from a JSON object.static longparseLifetimeFromJSONObject(net.minidev.json.JSONObject jsonObject) Parses an access tokenexpires_inparameter from a JSON object.static ScopeparseScopeFromJSONObject(net.minidev.json.JSONObject jsonObject) Parses ascopeparameter from a JSON object.static StringparseValueFromAuthorizationHeader(String header, AccessTokenType type) Parses an access token value from anAuthorizationHTTP request header.static StringparseValueFromJSONObject(net.minidev.json.JSONObject params) Parses an {code access_token} value from a JSON object.static StringparseValueFromQueryParameters(Map<String, List<String>> parameters) Parses anaccess_tokenvalue from a query or form parameters.static StringparseValueFromQueryParameters(Map<String, List<String>> parameters, AccessTokenType type) Parses anaccess_tokenvalues from a query or form parameters.
-
Method Details
-
parseAndEnsureTypeFromJSONObject
public static void parseAndEnsureTypeFromJSONObject(net.minidev.json.JSONObject jsonObject, AccessTokenType type) throws ParseException Parses atoken_typefrom 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_inparameter 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 ascopeparameter from a JSON object.- Parameters:
jsonObject- The JSON object. Must not benull.- Returns:
- The scope,
nullif not specified. - Throws:
ParseException- If parsing failed.
-
parseAuthorizationDetailsFromJSONObject
public static List<AuthorizationDetail> parseAuthorizationDetailsFromJSONObject(net.minidev.json.JSONObject jsonObject) throws ParseException Parses anauthorization_detailsparameter from a JSON object.- Parameters:
jsonObject- The JSON object. Must not benull.- Returns:
- The authorisation details,
nullif not specified. - Throws:
ParseException- If parsing failed.
-
parseIssuedTokenTypeFromJSONObject
public static TokenTypeURI parseIssuedTokenTypeFromJSONObject(net.minidev.json.JSONObject jsonObject) throws ParseException Parses anissued_token_typeparameter from a JSON object.- Parameters:
jsonObject- The JSON object. Must not benull.- Returns:
- The issued token type,
nullif not specified. - Throws:
ParseException- If parsing failed.
-
parseValueFromAuthorizationHeader
public static String parseValueFromAuthorizationHeader(String header, AccessTokenType type) throws ParseException Parses an access token value from anAuthorizationHTTP request header.- Parameters:
header- TheAuthorizationheader value,nullif not specified.type- The expected access token type, such asAccessTokenType.BEARERorAccessTokenType.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_tokenvalues from a query or form parameters.- Parameters:
parameters- The parameters. Must not benull.type- The expected access token type, such asAccessTokenType.BEARERorAccessTokenType.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_tokenvalue 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 anAuthorizationHTTP request header.- Parameters:
header- TheAuthorizationheader value. Must not benull.- Returns:
- The access token type.
- Throws:
ParseException- If parsing failed.
-