public abstract class AWS4SignerBase
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ALGORITHM |
protected java.text.SimpleDateFormat |
dateStampFormat |
static java.lang.String |
DateStringFormat |
protected java.text.SimpleDateFormat |
dateTimeFormat |
static java.lang.String |
EMPTY_BODY_SHA256
SHA256 hash of an empty request body *
|
protected java.net.URL |
endpointUrl |
protected java.lang.String |
httpMethod |
static java.lang.String |
ISO8601BasicFormat
format strings for the date/time and date stamps required during signing *
|
protected java.lang.String |
regionName |
static java.lang.String |
SCHEME |
protected java.lang.String |
serviceName |
static java.lang.String |
TERMINATOR |
Constructor and Description |
---|
AWS4SignerBase(java.net.URL endpointUrl,
java.lang.String httpMethod,
java.lang.String serviceName,
java.lang.String regionName)
Create a new AWS V4 signer.
|
Modifier and Type | Method and Description |
---|---|
protected static java.lang.String |
getCanonicalizedHeaderString(java.util.Map<java.lang.String,java.lang.String> headers)
Computes the canonical headers with values for the request.
|
static java.lang.String |
getCanonicalizedQueryString(java.util.Map<java.lang.String,java.lang.String> parameters)
Examines the specified query string parameters and returns a
canonicalized form.
|
protected static java.lang.String |
getCanonicalizedResourcePath(java.net.URL endpoint)
Returns the canonicalized resource path for the service endpoint.
|
protected static java.lang.String |
getCanonicalizeHeaderNames(java.util.Map<java.lang.String,java.lang.String> headers)
Returns the canonical collection of header names that will be included in
the signature.
|
protected static java.lang.String |
getCanonicalRequest(java.net.URL endpoint,
java.lang.String httpMethod,
java.lang.String queryParameters,
java.lang.String canonicalizedHeaderNames,
java.lang.String canonicalizedHeaders,
java.lang.String bodyHash)
Returns the canonical request string to go into the signer process; this
consists of several canonical sub-parts.
|
protected static java.lang.String |
getStringToSign(java.lang.String scheme,
java.lang.String algorithm,
java.lang.String dateTime,
java.lang.String scope,
java.lang.String canonicalRequest) |
static byte[] |
hash(byte[] data)
Hashes the byte array using the SHA-256 algorithm.
|
static byte[] |
hash(java.lang.String text)
Hashes the string contents (assumed to be UTF-8) using the SHA-256
algorithm.
|
protected static byte[] |
sign(java.lang.String stringData,
byte[] key,
java.lang.String algorithm) |
public static final java.lang.String EMPTY_BODY_SHA256
public static final java.lang.String SCHEME
public static final java.lang.String ALGORITHM
public static final java.lang.String TERMINATOR
public static final java.lang.String ISO8601BasicFormat
public static final java.lang.String DateStringFormat
protected java.net.URL endpointUrl
protected java.lang.String httpMethod
protected java.lang.String serviceName
protected java.lang.String regionName
protected final java.text.SimpleDateFormat dateTimeFormat
protected final java.text.SimpleDateFormat dateStampFormat
public AWS4SignerBase(java.net.URL endpointUrl, java.lang.String httpMethod, java.lang.String serviceName, java.lang.String regionName)
endpointUrl
- The service endpoint, including the path to any resource.httpMethod
- The HTTP verb for the request, e.g. GET.serviceName
- The signing name of the service, e.g. 's3'.regionName
- The system name of the AWS region associated with the
endpoint, e.g. us-east-1.protected static java.lang.String getCanonicalizeHeaderNames(java.util.Map<java.lang.String,java.lang.String> headers)
protected static java.lang.String getCanonicalizedHeaderString(java.util.Map<java.lang.String,java.lang.String> headers)
protected static java.lang.String getCanonicalRequest(java.net.URL endpoint, java.lang.String httpMethod, java.lang.String queryParameters, java.lang.String canonicalizedHeaderNames, java.lang.String canonicalizedHeaders, java.lang.String bodyHash)
protected static java.lang.String getCanonicalizedResourcePath(java.net.URL endpoint)
public static java.lang.String getCanonicalizedQueryString(java.util.Map<java.lang.String,java.lang.String> parameters)
The canonicalized query string is formed by first sorting all the query string parameters, then URI encoding both the key and value and then joining them, in order, separating key value pairs with an '&'.
parameters
- The query string parameters to be canonicalized.protected static java.lang.String getStringToSign(java.lang.String scheme, java.lang.String algorithm, java.lang.String dateTime, java.lang.String scope, java.lang.String canonicalRequest)
public static byte[] hash(java.lang.String text)
public static byte[] hash(byte[] data)
protected static byte[] sign(java.lang.String stringData, byte[] key, java.lang.String algorithm)