public final class HttpChecksumUtils extends Object
Modifier and Type | Method and Description |
---|---|
static Optional<ChecksumSpecs> |
checksumSpecWithRequestAlgorithm(ExecutionAttributes executionAttributes) |
static byte[] |
computeChecksum(InputStream is,
Algorithm algorithm)
Computes the Checksum of the data in the given input stream and returns it as an array of bytes.
|
static Pair<Algorithm,String> |
getAlgorithmChecksumValuePair(SdkHttpResponse sdkHttpResponse,
ChecksumSpecs resolvedChecksumSpecs)
Loops through the Supported list of checksum for the operation, and gets the Header value for the checksum header.
|
static String |
httpChecksumHeader(String algorithmName) |
static boolean |
isHeaderBasedSigningAuth(SigningMethod signingMethodUsed,
String protocol) |
static boolean |
isHttpChecksumPresent(SdkHttpRequest sdkHttpRequest,
ChecksumSpecs checksumSpec)
Checks if the request header is already updated with Calculated checksum.
|
static boolean |
isHttpChecksumValidationEnabled(ChecksumSpecs resolvedChecksumSpecs) |
static boolean |
isMd5ChecksumRequired(ExecutionAttributes executionAttributes) |
static boolean |
isStreamingUnsignedPayload(SdkHttpRequest sdkHttpRequest,
ExecutionAttributes executionAttributes,
ChecksumSpecs headerChecksumSpecs,
boolean isContentStreaming)
The header based Checksum is computed only if following criteria is met
- Flexible checksum is not already computed.
|
static boolean |
isTrailerBasedChecksumForClientType(ExecutionAttributes executionAttributes,
SdkHttpRequest httpRequest,
ClientType clientType,
ChecksumSpecs checksumSpecs,
boolean hasRequestBody,
boolean isContentSteaming) |
static boolean |
isTrailerBasedFlexibleChecksumComputed(SdkHttpRequest sdkHttpRequest,
ExecutionAttributes executionAttributes,
ChecksumSpecs checksumSpecs,
boolean hasRequestBody,
boolean isContentStreaming)
The trailer based Checksum is computed only if following criteria is met
- Flexible checksum is not already computed.
|
static boolean |
isUnsignedPayload(SigningMethod signingMethod,
String protocol,
boolean isContentStreaming) |
static byte[] |
longToByte(Long input) |
public static String httpChecksumHeader(String algorithmName)
algorithmName
- Checksum Algorithm Namepublic static boolean isStreamingUnsignedPayload(SdkHttpRequest sdkHttpRequest, ExecutionAttributes executionAttributes, ChecksumSpecs headerChecksumSpecs, boolean isContentStreaming)
public static boolean isHeaderBasedSigningAuth(SigningMethod signingMethodUsed, String protocol)
public static boolean isUnsignedPayload(SigningMethod signingMethod, String protocol, boolean isContentStreaming)
signingMethod
- Signing Method.protocol
- The http/https protocol.public static byte[] computeChecksum(InputStream is, Algorithm algorithm) throws IOException
is
- InputStream for which checksum needs to be calculated.algorithm
- algorithm that will be used to compute the checksum of input stream.IOException
- I/O errors while reading.public static Optional<ChecksumSpecs> checksumSpecWithRequestAlgorithm(ExecutionAttributes executionAttributes)
executionAttributes
- Execution attributes defined for the request.public static boolean isHttpChecksumPresent(SdkHttpRequest sdkHttpRequest, ChecksumSpecs checksumSpec)
sdkHttpRequest
- SdkHttpRequestpublic static boolean isMd5ChecksumRequired(ExecutionAttributes executionAttributes)
public static boolean isTrailerBasedFlexibleChecksumComputed(SdkHttpRequest sdkHttpRequest, ExecutionAttributes executionAttributes, ChecksumSpecs checksumSpecs, boolean hasRequestBody, boolean isContentStreaming)
public static boolean isTrailerBasedChecksumForClientType(ExecutionAttributes executionAttributes, SdkHttpRequest httpRequest, ClientType clientType, ChecksumSpecs checksumSpecs, boolean hasRequestBody, boolean isContentSteaming)
executionAttributes
- Execution attributes for the request.httpRequest
- Http Request.clientType
- Client Type for which the Trailer checksum is appended.checksumSpecs
- Checksum specs for the request.hasRequestBody
- Request body.public static Pair<Algorithm,String> getAlgorithmChecksumValuePair(SdkHttpResponse sdkHttpResponse, ChecksumSpecs resolvedChecksumSpecs)
sdkHttpResponse
- response from service.resolvedChecksumSpecs
- Resolved checksum specification for the operation.public static boolean isHttpChecksumValidationEnabled(ChecksumSpecs resolvedChecksumSpecs)
resolvedChecksumSpecs
- Resolved checksum specification for the operation.public static byte[] longToByte(Long input)
Copyright © 2022. All rights reserved.