public class AuthorizationHeaderAWS4Signer extends Object
| Modifier and Type | Field and Description |
|---|---|
private static String |
ALGORITHM |
private SimpleDateFormat |
dateTimeFormat |
private static String |
EMPTY_BODY_SHA256 |
private static String |
ISO8601BasicFormat |
private String |
regionName |
private static String |
SCHEME |
private String |
serviceName |
private static String |
TERMINATOR |
| Constructor and Description |
|---|
AuthorizationHeaderAWS4Signer(String serviceName,
String regionName) |
| Modifier and Type | Method and Description |
|---|---|
String |
computeSignature(HttpUtils.HttpRequest httpRequest,
AwsCredentials credentials)
Compute the request signature.
|
protected static String |
getCanonicalizedHeaderString(Map<String,String> headers)
Computes the canonical headers with values for the request.
|
static String |
getCanonicalizedQueryString(Map<String,String> parameters)
Examines the specified query string parameters and returns a
canonicalized form.
|
protected static String |
getCanonicalizedResourcePath(URL endpoint)
Returns the canonicalized resource path for the service endpoint.
|
protected static String |
getCanonicalizeHeaderNames(Map<String,String> headers)
Returns the canonical collection of header names that will be included in
the signature.
|
protected static String |
getCanonicalRequest(URL endpoint,
String httpMethod,
String queryParameters,
String canonicalizedHeaderNames,
String canonicalizedHeaders,
String bodyHash)
Returns the canonical request string to go into the signer process; this
consists of several canonical sub-parts.
|
private String |
getStringToSign(String dateTime,
String scope,
String canonicalRequest) |
byte[] |
hash(byte[] data)
Hashes the byte array using the SHA-256 algorithm.
|
private byte[] |
hash(String text)
Hashes the string contents (assumed to be UTF-8) using the SHA-256
algorithm.
|
String |
hashPayload(byte[] payload) |
void |
sign(HttpUtils.HttpRequest httpRequest,
AwsCredentials credentials)
Sign the request.
|
private byte[] |
sign(String stringData,
byte[] key,
String algorithm) |
private String |
toHex(byte[] data)
Converts byte data to a Hex-encoded string.
|
private static final String EMPTY_BODY_SHA256
private static final String SCHEME
private static final String ALGORITHM
private static final String TERMINATOR
private static final String ISO8601BasicFormat
private final String serviceName
private final String regionName
private final SimpleDateFormat dateTimeFormat
public void sign(HttpUtils.HttpRequest httpRequest, AwsCredentials credentials)
httpRequest - credentials - public String computeSignature(HttpUtils.HttpRequest httpRequest, AwsCredentials credentials)
httpRequest - credentials - protected static String getCanonicalizeHeaderNames(Map<String,String> headers)
headers - protected static String getCanonicalizedHeaderString(Map<String,String> headers)
headers - protected static String getCanonicalRequest(URL endpoint, String httpMethod, String queryParameters, String canonicalizedHeaderNames, String canonicalizedHeaders, String bodyHash)
endpoint - httpMethod - queryParameters - canonicalizedHeaderNames - canonicalizedHeaders - bodyHash - protected static String getCanonicalizedResourcePath(URL endpoint)
endpoint - public static String getCanonicalizedQueryString(Map<String,String> parameters)
parameters - The query string parameters to be canonicalized.private String getStringToSign(String dateTime, String scope, String canonicalRequest)
public String hashPayload(byte[] payload)
private byte[] hash(String text)
text - public byte[] hash(byte[] data)
data - private String toHex(byte[] data)
data - data to hex encode.Copyright © 2018. All rights reserved.