Class SignerUtils
java.lang.Object
software.amazon.awssdk.http.auth.aws.internal.signer.util.SignerUtils
Utility methods to be used by various AWS Signer implementations. This class is protected and subject to change.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addDateHeader
(SdkHttpRequest.Builder requestBuilder, String dateTime) Add a date header using a datetime stringstatic void
addHostHeader
(SdkHttpRequest.Builder requestBuilder) Add the host header based on parameters of a requeststatic byte[]
computeSignature
(String stringToSign, byte[] signingKey) Compute the signature of a string using a signing key.static byte[]
deriveSigningKey
(AwsCredentialsIdentity credentials, CredentialScope credentialScope) Get the signing key based on the given credentials and a credential-scopestatic String
formatDate
(Instant instant) Returns a string representation of the given datetime in yyyyMMdd format.static String
formatDateTime
(Instant instant) Returns a string representation of the given datetime in yyyyMMdd'T'HHmmss'Z' format.static InputStream
getBinaryRequestPayloadStream
(ContentStreamProvider streamProvider) static String
getContentHash
(SdkHttpRequest.Builder requestBuilder) static byte[]
hash
(byte[] data) static byte[]
hash
(InputStream input) static byte[]
static byte[]
hash
(ByteBuffer input) static String
hashCanonicalRequest
(String canonicalRequestString) Create a hash of the canonical request stringstatic long
moveContentLength
(SdkHttpRequest.Builder request, InputStream payload) Move `Content-Length` to `x-amz-decoded-content-length` if not already present.static byte[]
sign
(byte[] data, byte[] key, SigningAlgorithm algorithm) Sign given data using a key and a specific algorithmstatic byte[]
Sign given data using a key.
-
Method Details
-
formatDate
Returns a string representation of the given datetime in yyyyMMdd format. The date returned is in the UTC zone.For example, given an Instant with millis-value of 1416863450581, this method returns "20141124"
-
formatDateTime
Returns a string representation of the given datetime in yyyyMMdd'T'HHmmss'Z' format. The date returned is in the UTC zone.For example, given an Instant with millis-value of 1416863450581, this method returns "20141124T211050Z"
-
hashCanonicalRequest
Create a hash of the canonical request stringStep 2 of the AWS Signature version 4 calculation. Refer to https://docs.aws.amazon.com/IAM/latest/UserGuide/create-signed-request.html#create-canonical-request-hash.
-
deriveSigningKey
public static byte[] deriveSigningKey(AwsCredentialsIdentity credentials, CredentialScope credentialScope) Get the signing key based on the given credentials and a credential-scope -
sign
Sign given data using a key. -
sign
Sign given data using a key and a specific algorithm -
computeSignature
Compute the signature of a string using a signing key.Step 4 of the AWS Signature version 4 calculation. Refer to https://docs.aws.amazon.com/IAM/latest/UserGuide/create-signed-request.html#calculate-signature.
-
addHostHeader
Add the host header based on parameters of a request -
addDateHeader
Add a date header using a datetime string -
moveContentLength
Move `Content-Length` to `x-amz-decoded-content-length` if not already present. If `Content-Length` is not present, then the payload is read in its entirety to calculate the length. -
getBinaryRequestPayloadStream
-
hash
-
hash
-
hash
public static byte[] hash(byte[] data) -
hash
-
getContentHash
-