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 voidaddDateHeader(SdkHttpRequest.Builder requestBuilder, String dateTime) Add a date header using a datetime stringstatic voidaddHostHeader(SdkHttpRequest.Builder requestBuilder) Add the host header based on parameters of a requeststatic longcomputeAndMoveContentLength(SdkHttpRequest.Builder request, ContentStreamProvider contentStreamProvider) Move `Content-Length` to `x-amz-decoded-content-length` if not already present.static 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 StringformatDate(Instant instant) Returns a string representation of the given datetime in yyyyMMdd format.static StringformatDateTime(Instant instant) Returns a string representation of the given datetime in yyyyMMdd'T'HHmmss'Z' format.static InputStreamgetBinaryRequestPayloadStream(ContentStreamProvider streamProvider) static StringgetContentHash(SdkHttpRequest.Builder requestBuilder) static byte[]hash(byte[] data) static byte[]hash(InputStream input) static byte[]static byte[]hash(ByteBuffer input) static StringhashCanonicalRequest(String canonicalRequestString) Create a hash of the canonical request stringstatic CompletableFuture<Pair<SdkHttpRequest.Builder, Optional<org.reactivestreams.Publisher<ByteBuffer>>>> moveContentLength(SdkHttpRequest.Builder request, org.reactivestreams.Publisher<ByteBuffer> contentPublisher) 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
-
formatDateTime
-
hashCanonicalRequest
-
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 -
computeAndMoveContentLength
public static long computeAndMoveContentLength(SdkHttpRequest.Builder request, ContentStreamProvider contentStreamProvider) 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. -
moveContentLength
public static CompletableFuture<Pair<SdkHttpRequest.Builder,Optional<org.reactivestreams.Publisher<ByteBuffer>>>> moveContentLength(SdkHttpRequest.Builder request, org.reactivestreams.Publisher<ByteBuffer> contentPublisher) Move Content-Length` to `x-amz-decoded-content-length` if not already present. If `Content-Length` is not present, the future is completed exceptionally. Note: this behavior differs from the sync versioncomputeAndMoveContentLength(SdkHttpRequest.Builder, ContentStreamProvider)as the sync version reads the entire stream to compute the length if the header is not present. The async version was introduced after the sync version; moving forward, requests that have an unknown content length should be done through chunked transfer encoding. -
getBinaryRequestPayloadStream
-
hash
-
hash
-
hash
public static byte[] hash(byte[] data) -
hash
-
getContentHash
-