public abstract class AbstractAWSSigner extends java.lang.Object implements Signer
Not intended to be sub-classed by developers.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EMPTY_STRING_SHA256_HEX
Empty sha256 hex.
|
Constructor and Description |
---|
AbstractAWSSigner() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addSessionCredentials(Request<?> request,
AWSSessionCredentials credentials)
Adds session credentials to the request given.
|
protected byte[] |
getBinaryRequestPayload(Request<?> request)
Returns the request's payload as binary data.
|
protected java.io.InputStream |
getBinaryRequestPayloadStream(Request<?> request) |
protected java.io.InputStream |
getBinaryRequestPayloadStreamWithoutQueryParams(Request<?> request) |
protected byte[] |
getBinaryRequestPayloadWithoutQueryParams(Request<?> request)
Returns the request's payload contents as binary data, without processing
any query string params (i.e.
|
protected java.lang.String |
getCanonicalizedEndpoint(java.net.URI endpoint) |
protected 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 java.lang.String |
getCanonicalizedQueryString(Request<?> request) |
protected java.lang.String |
getCanonicalizedResourcePath(java.lang.String resourcePath) |
protected java.lang.String |
getCanonicalizedResourcePath(java.lang.String resourcePath,
boolean urlEncode) |
protected java.lang.String |
getRequestPayload(Request<?> request)
Returns the request's payload as a String.
|
protected java.lang.String |
getRequestPayloadWithoutQueryParams(Request<?> request)
Returns the request's payload contents as a String, without processing
any query string params (i.e.
|
protected java.util.Date |
getSignatureDate(long timeOffset) |
protected long |
getTimeOffset(Request<?> request) |
byte[] |
hash(byte[] data)
Hashes the binary data using the SHA-256 algorithm.
|
protected byte[] |
hash(java.io.InputStream input) |
byte[] |
hash(java.lang.String text)
Hashes the string contents (assumed to be UTF-8) using the SHA-256
algorithm.
|
protected java.lang.String |
newString(byte[] bytes)
Safely converts a UTF-8 encoded byte array into a String.
|
protected AWSCredentials |
sanitizeCredentials(AWSCredentials credentials)
Loads the individual access key ID and secret key from the specified
credentials, ensuring that access to the credentials is synchronized on
the credentials object itself, and trimming any extra whitespace from the
credentials.
|
protected byte[] |
sign(byte[] data,
byte[] key,
SigningAlgorithm algorithm) |
byte[] |
sign(java.lang.String stringData,
byte[] key,
SigningAlgorithm algorithm)
Signs using the given signing algorithm.
|
protected java.lang.String |
signAndBase64Encode(byte[] data,
java.lang.String key,
SigningAlgorithm algorithm)
Computes an RFC 2104-compliant HMAC signature for an array of bytes and
returns the result as a Base64 encoded string.
|
protected java.lang.String |
signAndBase64Encode(java.lang.String data,
java.lang.String key,
SigningAlgorithm algorithm)
Computes an RFC 2104-compliant HMAC signature and returns the result as a
Base64 encoded string.
|
public static final java.lang.String EMPTY_STRING_SHA256_HEX
protected java.lang.String signAndBase64Encode(java.lang.String data, java.lang.String key, SigningAlgorithm algorithm)
protected java.lang.String signAndBase64Encode(byte[] data, java.lang.String key, SigningAlgorithm algorithm)
public byte[] sign(java.lang.String stringData, byte[] key, SigningAlgorithm algorithm)
stringData
- the data.key
- the key in bytes.algorithm
- the signing algorithm.protected byte[] sign(byte[] data, byte[] key, SigningAlgorithm algorithm)
public byte[] hash(java.lang.String text)
text
- The string to hash.protected byte[] hash(java.io.InputStream input)
public byte[] hash(byte[] data)
data
- The binary data to hash.AmazonClientException
- If the hash cannot be computed.protected 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 java.lang.String getCanonicalizedQueryString(Request<?> request)
protected byte[] getBinaryRequestPayload(Request<?> request)
request
- The requestprotected java.lang.String getRequestPayload(Request<?> request)
request
- The requestprotected java.lang.String getRequestPayloadWithoutQueryParams(Request<?> request)
request
- The requestprotected byte[] getBinaryRequestPayloadWithoutQueryParams(Request<?> request)
request
- The requestprotected java.io.InputStream getBinaryRequestPayloadStream(Request<?> request)
protected java.io.InputStream getBinaryRequestPayloadStreamWithoutQueryParams(Request<?> request)
protected java.lang.String getCanonicalizedResourcePath(java.lang.String resourcePath)
protected java.lang.String getCanonicalizedResourcePath(java.lang.String resourcePath, boolean urlEncode)
protected java.lang.String getCanonicalizedEndpoint(java.net.URI endpoint)
protected AWSCredentials sanitizeCredentials(AWSCredentials credentials)
Returns either a BasicSessionCredentials
or a
BasicAWSCredentials
object, depending on the input type.
credentials
- protected java.lang.String newString(byte[] bytes)
bytes
- UTF-8 encoded binary character data.protected java.util.Date getSignatureDate(long timeOffset)
protected long getTimeOffset(Request<?> request)
protected abstract void addSessionCredentials(Request<?> request, AWSSessionCredentials credentials)
request
- The request to add session credentials information tocredentials
- The session credentials to add to the request