Class HttpChecksumUtils
java.lang.Object
software.amazon.awssdk.core.internal.util.HttpChecksumUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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<ChecksumAlgorithm, 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 booleanhasLegacyChecksumRequiredTrait(ExecutionAttributes executionAttributes) static StringhttpChecksumHeader(String algorithmName) static booleanisHeaderBasedSigningAuth(SigningMethod signingMethodUsed, String protocol) static booleanisHttpChecksumCalculationNeeded(SdkHttpFullRequest.Builder request, ExecutionAttributes executionAttributes) HTTP checksum calculation is needed if one of the following conditions is met: 1.static booleanisHttpChecksumPresent(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(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, SdkHttpRequest httpRequest, ClientType clientType, ChecksumSpecs checksumSpecs, boolean hasRequestBody, boolean isContentSteaming) static booleanisTrailerBasedFlexibleChecksumComputed(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) static AlgorithmtoLegacyChecksumAlgorithm(ChecksumAlgorithm checksumAlgorithm) static ChecksumAlgorithmtoNewChecksumAlgorithm(Algorithm checksumAlgorithm)
-
Method Details
-
toLegacyChecksumAlgorithm
-
toNewChecksumAlgorithm
-
httpChecksumHeader
-
isStreamingUnsignedPayload
public 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. - - HeaderChecksumSpecs are defined. - Unsigned Payload request. -
isHeaderBasedSigningAuth
-
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
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(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
-
hasLegacyChecksumRequiredTrait
-
isHttpChecksumCalculationNeeded
public static boolean isHttpChecksumCalculationNeeded(SdkHttpFullRequest.Builder request, ExecutionAttributes executionAttributes) HTTP checksum calculation is needed if one of the following conditions is met: 1. checksum is required per legacy httpRequired trait or the new HttpChecksum trait OR 2. user has specified a checksum algorithm OR 3. checksum is optional per new HttpChecksum trait AND RequestChecksumCalculation == when_supported HTTP checksum calculation is not needed if one of the following conditions is met: 1. the operation does not have legacy httpRequired trait or the new HttpChecksum trait OR 2. user has provided a checksum value (any header prefixed with "x-amz-checksum-") OR 3. checksum is not required AND RequestChecksumCalculation == when_required -
isTrailerBasedFlexibleChecksumComputed
public 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. - Streaming Unsigned Payload defined. - Unsigned Payload request. -
isTrailerBasedChecksumForClientType
public static boolean isTrailerBasedChecksumForClientType(ExecutionAttributes executionAttributes, 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 Pair<ChecksumAlgorithm,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.- 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
- Parameters:
resolvedChecksumSpecs- Resolved checksum specification for the operation.- Returns:
- True is Response is to be validated for checksum checks.
-
longToByte
-