Class HttpChecksumUtils

java.lang.Object
software.amazon.awssdk.core.internal.util.HttpChecksumUtils

public final class HttpChecksumUtils extends Object
  • Method Details

    • 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(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(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(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<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.
      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)