Class OAuth2Utils
java.lang.Object
com.google.auth.oauth2.OAuth2Utils
Internal utilities for the com.google.auth.oauth2 namespace.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String(package private) static final int(package private) static final String(package private) static final com.google.api.client.http.HttpTransport(package private) static final HttpTransportFactory(package private) static final String(package private) static final String(package private) static final int(package private) static final com.google.api.client.json.JsonFactory(package private) static final double(package private) static final double(package private) static final String(package private) static final String(package private) static final String(package private) static final URI(package private) static final URI(package private) static final String(package private) static final String(package private) static final URIprivate static Stringprivate static String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static StringgenerateBasicAuthHeader(String username, String password) Generates a Basic Authentication header string for the provided username and password.(package private) static booleanheadersContainValue(com.google.api.client.http.HttpHeaders headers, String headerName, String value) Returns whether the headers contain the specified value as one of the entries in the specified header.(package private) static com.google.api.client.json.GenericJsonParses the specified JSON text.(package private) static PrivateKeyprivateKeyFromPkcs8(String privateKeyPkcs8) Helper to convert from a PKCS#8 String to an RSA private key(package private) static intReturn the specified integer from JSON or throw a helpful error message.(package private) static longReturn the specified long from JSON or throw a helpful error message.Return the specified map from JSON or throw a helpful error message.Return the specified list of strings from JSON or throw a helpful error message.(package private) static StringReturn the specified optional string from JSON or throw a helpful error message.(package private) static StringReturn the specified string from JSON or throw a helpful error message.(package private) static voidwriteInputStreamToFile(InputStream credentials, String filePath) Saves the end user credentials into the given file path.
-
Field Details
-
SIGNATURE_ALGORITHM
- See Also:
-
TOKEN_TYPE_ACCESS_TOKEN
- See Also:
-
TOKEN_TYPE_TOKEN_EXCHANGE
- See Also:
-
GRANT_TYPE_JWT_BEARER
- See Also:
-
IAM_ID_TOKEN_ENDPOINT_FORMAT
- See Also:
-
IAM_ACCESS_TOKEN_ENDPOINT_FORMAT
- See Also:
-
SIGN_BLOB_ENDPOINT_FORMAT
- See Also:
-
TOKEN_SERVER_URI
-
TOKEN_REVOKE_URI
-
USER_AUTH_URI
-
HTTP_TRANSPORT
static final com.google.api.client.http.HttpTransport HTTP_TRANSPORT -
HTTP_TRANSPORT_FACTORY
-
JSON_FACTORY
static final com.google.api.client.json.JsonFactory JSON_FACTORY -
VALUE_NOT_FOUND_MESSAGE
-
VALUE_WRONG_TYPE_MESSAGE
-
BEARER_PREFIX
- See Also:
-
TOKEN_RESPONSE_SCOPE
- See Also:
-
INITIAL_RETRY_INTERVAL_MILLIS
static final int INITIAL_RETRY_INTERVAL_MILLIS- See Also:
-
RETRY_RANDOMIZATION_FACTOR
static final double RETRY_RANDOMIZATION_FACTOR- See Also:
-
RETRY_MULTIPLIER
static final double RETRY_MULTIPLIER- See Also:
-
DEFAULT_NUMBER_OF_RETRIES
static final int DEFAULT_NUMBER_OF_RETRIES- See Also:
-
TOKEN_ENDPOINT_RETRYABLE_STATUS_CODES
-
-
Constructor Details
-
OAuth2Utils
private OAuth2Utils()
-
-
Method Details
-
headersContainValue
-
parseJson
Parses the specified JSON text.- Throws:
IOException
-
validateString
static String validateString(Map<String, Object> map, String key, String errorPrefix) throws IOExceptionReturn the specified string from JSON or throw a helpful error message.- Throws:
IOException
-
writeInputStreamToFile
Saves the end user credentials into the given file path.- Parameters:
credentials- InputStream containing user credentials in JSON formatfilePath- Path to file where to store the credentials- Throws:
IOException- An error saving the credentials.
-
validateOptionalString
static String validateOptionalString(Map<String, Object> map, String key, String errorPrefix) throws IOExceptionReturn the specified optional string from JSON or throw a helpful error message.- Throws:
IOException
-
validateOptionalListString
static List<String> validateOptionalListString(Map<String, Object> map, String key, String errorPrefix) throws IOExceptionReturn the specified list of strings from JSON or throw a helpful error message.- Throws:
IOException
-
validateInt32
Return the specified integer from JSON or throw a helpful error message.- Throws:
IOException
-
validateLong
Return the specified long from JSON or throw a helpful error message.- Throws:
IOException
-
validateMap
static Map<String,Object> validateMap(Map<String, Object> map, String key, String errorPrefix) throws IOExceptionReturn the specified map from JSON or throw a helpful error message.- Throws:
IOException
-
privateKeyFromPkcs8
Helper to convert from a PKCS#8 String to an RSA private key- Throws:
IOException
-
generateBasicAuthHeader
Generates a Basic Authentication header string for the provided username and password.This method constructs a Basic Authentication string using the provided username and password. The credentials are encoded in Base64 format and prefixed with the "Basic " scheme identifier.
- Parameters:
username- The username for authentication.password- The password for authentication.- Returns:
- The Basic Authentication header value.
- Throws:
IllegalArgumentException- if either username or password is null or empty.
-