Class HttpChecksumUtils
- java.lang.Object
-
- software.amazon.awssdk.core.internal.util.HttpChecksumUtils
-
public final class HttpChecksumUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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 software.amazon.awssdk.utils.Pair<Algorithm,String>getAlgorithmChecksumValuePair(software.amazon.awssdk.http.SdkHttpResponse sdkHttpResponse, ChecksumSpecs resolvedChecksumSpecs)Loops through the Supported list of checksum for the operation, and gets the Header value for the checksum header.static StringhttpChecksumHeader(String algorithmName)static booleanisHeaderBasedSigningAuth(SigningMethod signingMethodUsed, String protocol)static booleanisHttpChecksumPresent(software.amazon.awssdk.http.SdkHttpRequest sdkHttpRequest, ChecksumSpecs checksumSpec)Checks if the request header is already updated with Calculated checksum.static booleanisHttpChecksumValidationEnabled(ChecksumSpecs resolvedChecksumSpecs)static booleanisMd5ChecksumRequired(ExecutionAttributes executionAttributes)static booleanisStreamingUnsignedPayload(software.amazon.awssdk.http.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 booleanisTrailerBasedChecksumForClientType(ExecutionAttributes executionAttributes, software.amazon.awssdk.http.SdkHttpRequest httpRequest, ClientType clientType, ChecksumSpecs checksumSpecs, boolean hasRequestBody, boolean isContentSteaming)static booleanisTrailerBasedFlexibleChecksumComputed(software.amazon.awssdk.http.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 booleanisUnsignedPayload(SigningMethod signingMethod, String protocol, boolean isContentStreaming)static byte[]longToByte(Long input)
-
-
-
Method Detail
-
httpChecksumHeader
public static String httpChecksumHeader(String algorithmName)
- Parameters:
algorithmName- Checksum Algorithm Name- Returns:
- Http Checksum header for a given Algorithm.
-
isStreamingUnsignedPayload
public static boolean isStreamingUnsignedPayload(software.amazon.awssdk.http.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. - - HeaderChecksumSpecs are defined. - Unsigned Payload request.
-
isHeaderBasedSigningAuth
public static boolean isHeaderBasedSigningAuth(SigningMethod signingMethodUsed, String protocol)
-
isUnsignedPayload
public static boolean isUnsignedPayload(SigningMethod signingMethod, String protocol, boolean isContentStreaming)
- Parameters:
signingMethod- Signing Method.protocol- The http/https protocol.- Returns:
- true if Payload signing is resolved to Unsigned payload.
-
computeChecksum
public static byte[] computeChecksum(InputStream is, Algorithm algorithm) throws IOException
Computes the Checksum of the data in the given input stream and returns it as an array of bytes.- Parameters:
is- InputStream for which checksum needs to be calculated.algorithm- algorithm that will be used to compute the checksum of input stream.- Returns:
- Calculated checksum in bytes.
- Throws:
IOException- I/O errors while reading.
-
checksumSpecWithRequestAlgorithm
public static Optional<ChecksumSpecs> checksumSpecWithRequestAlgorithm(ExecutionAttributes executionAttributes)
- Parameters:
executionAttributes- Execution attributes defined for the request.- Returns:
- Optional ChecksumSpec if checksum Algorithm exist for the checksumSpec
-
isHttpChecksumPresent
public static boolean isHttpChecksumPresent(software.amazon.awssdk.http.SdkHttpRequest sdkHttpRequest, ChecksumSpecs checksumSpec)Checks if the request header is already updated with Calculated checksum.- Parameters:
sdkHttpRequest- SdkHttpRequest- Returns:
- True if the flexible checksum header was already updated.
-
isMd5ChecksumRequired
public static boolean isMd5ChecksumRequired(ExecutionAttributes executionAttributes)
-
isTrailerBasedFlexibleChecksumComputed
public static boolean isTrailerBasedFlexibleChecksumComputed(software.amazon.awssdk.http.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. - Streaming Unsigned Payload defined. - Unsigned Payload request.
-
isTrailerBasedChecksumForClientType
public static boolean isTrailerBasedChecksumForClientType(ExecutionAttributes executionAttributes, software.amazon.awssdk.http.SdkHttpRequest httpRequest, ClientType clientType, ChecksumSpecs checksumSpecs, boolean hasRequestBody, boolean isContentSteaming)
- Parameters:
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.- Returns:
- True if Trailer checksum needs to be calculated and appended.
-
getAlgorithmChecksumValuePair
public static software.amazon.awssdk.utils.Pair<Algorithm,String> getAlgorithmChecksumValuePair(software.amazon.awssdk.http.SdkHttpResponse sdkHttpResponse, ChecksumSpecs resolvedChecksumSpecs)
Loops through the Supported list of checksum for the operation, and gets the Header value for the checksum header.- Parameters:
sdkHttpResponse- response from service.resolvedChecksumSpecs- Resolved checksum specification for the operation.- Returns:
- Algorithm and its corresponding checksum value as sent by the service.
-
isHttpChecksumValidationEnabled
public static boolean isHttpChecksumValidationEnabled(ChecksumSpecs resolvedChecksumSpecs)
- Parameters:
resolvedChecksumSpecs- Resolved checksum specification for the operation.- Returns:
- True is Response is to be validated for checksum checks.
-
longToByte
public static byte[] longToByte(Long input)
-
-