| Modifier and Type | Field and Description |
|---|---|
| private static final String | ALGORITHM
AWS version 4 signing algorithm (for authorization header). |
| private static final DateTimeFormatter | AMZ_DATE_FORMAT
Date format for the 'x-amz-date' header. |
| private static final String | EMPTY_BODY_SHA256
SHA-256 hash of an empty request body. |
| private static final String | MAC_ALGORITHM
Java Message Authentication Code (MAC) algorithm name. |
| private static final String | SCHEME
AWS version 4 signing scheme. |
| private static final DateTimeFormatter | SCOPE_DATE_FORMAT
Date format for the string-to-sign's scope. |
| private static final String | TERMINATOR
AWS version 4 terminator string. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static String | Returns: Hex-encoded SHA-256 hash of the provided byte array.Byte array to hash data)Calculates the hex-encoded SHA-256 hash of the provided byte array. |
| private static String | Returns: The canonical headers with values for the request.Map containing all request headers. headers)Constructs the canonical header string for a request. |
| public static String | Returns: The canonicalized query string for the request.The query parameters in the request. queryParameters)Constructs the canonicalized query string for a request. |
| private static String | Returns: The canonicalized resource path for the AWS service endpoint.The AWS service endpoint URL, including the path to any
resource. url)Constructs the canonicalized resource path for an AWS service endpoint. |
| private static String | Returns: String that lists all request headers in sorted case-insensitive order, separated by a ';'.Map containing all request headers. headers)Construct a string listing all request headers in sorted case-insensitive order, separated by a ';'. |
| public static byte[] | Returns: Hashed string contents of the provided byte array.The byte array to hash. data)Hashes the provided byte array using the SHA-256 algorithm. |
| public static void | sign(HttpURLConnection
The request to sign. httpURLConnection, Map<String, String> The query parameters being sent in the request. queryParameters, long The content length of the data being sent in the request contentLength, String Hex-encoded SHA-256 hash of the data being sent in the request bodyHash, String The signing name of the AWS service (e.g. "s3"). serviceName, String The name of the AWS region that will handle the request (e.g.
"us-east-1"). regionName, String The user's AWS Access Key. awsAccessKey, char[] The user's AWS Secret Key. awsSecretKey)Sign the provided request with an AWS4 signature as the 'Authorization' header. |
| private static byte[] | Returns: Signed string data.The string data to sign. stringToSign, byte[] The key material of the secret key. key)Signs the provided string data using the specified key. |
| ALGORITHM | back to summary |
|---|---|
| private static final String ALGORITHM AWS version 4 signing algorithm (for authorization header). | |
| AMZ_DATE_FORMAT | back to summary |
|---|---|
| private static final DateTimeFormatter AMZ_DATE_FORMAT Date format for the 'x-amz-date' header. | |
| EMPTY_BODY_SHA256 | back to summary |
|---|---|
| private static final String EMPTY_BODY_SHA256 SHA-256 hash of an empty request body. | |
| MAC_ALGORITHM | back to summary |
|---|---|
| private static final String MAC_ALGORITHM Java Message Authentication Code (MAC) algorithm name. | |
| SCHEME | back to summary |
|---|---|
| private static final String SCHEME AWS version 4 signing scheme. | |
| SCOPE_DATE_FORMAT | back to summary |
|---|---|
| private static final DateTimeFormatter SCOPE_DATE_FORMAT Date format for the string-to-sign's scope. | |
| TERMINATOR | back to summary |
|---|---|
| private static final String TERMINATOR AWS version 4 terminator string. | |
| AwsRequestSignerV4 | back to summary |
|---|---|
| private AwsRequestSignerV4() | |
| calculateBodyHash | back to summary |
|---|---|
| public static String calculateBodyHash(final byte[] data) Calculates the hex-encoded SHA-256 hash of the provided byte array.
| |
| getCanonicalizedHeaderString | back to summary |
|---|---|
| private static String getCanonicalizedHeaderString(Map<String, String> headers) Constructs the canonical header string for a request. | |
| getCanonicalizedQueryString | back to summary |
|---|---|
| public static String getCanonicalizedQueryString(Map<String, String> queryParameters) Constructs the canonicalized query string for a request. | |
| getCanonicalizedResourcePath | back to summary |
|---|---|
| private static String getCanonicalizedResourcePath(URL url) Constructs the canonicalized resource path for an AWS service endpoint. | |
| getCanonicalizeHeaderNames | back to summary |
|---|---|
| private static String getCanonicalizeHeaderNames(Map<String, String> headers) Construct a string listing all request headers in sorted case-insensitive order, separated by a ';'. | |
| hash | back to summary |
|---|---|
| public static byte[] hash(byte[] data) Hashes the provided byte array using the SHA-256 algorithm.
| |
| sign | back to summary |
|---|---|
| public static void sign(HttpURLConnection httpURLConnection, Map<String, String> queryParameters, long contentLength, String bodyHash, String serviceName, String regionName, String awsAccessKey, char[] awsSecretKey) Sign the provided request with an AWS4 signature as the 'Authorization' header.
| |
| signStringWithKey | back to summary |
|---|---|
| private static byte[] signStringWithKey(String stringToSign, byte[] key) Signs the provided string data using the specified key.
| |