Class HttpStorageRpcHasherHelper

java.lang.Object
com.google.cloud.storage.HttpStorageRpcHasherHelper

@InternalApi public final class HttpStorageRpcHasherHelper extends Object
Internal utility class to perform client-side CRC32C checksum validation on downloaded data specifically for the HttpStorageRpc transport layer.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    shouldValidate(com.google.api.client.http.HttpResponse response)
    Determines if client-side validation should be performed on the downloaded object.
    void
    validate(com.google.api.client.http.HttpResponse response, OutputStream activeStream)
    Validates the downloaded output stream against GCS's expected base64-encoded value in response headers.
    void
    validateCrc32c(String expectedCrc32cBase64, byte[] content)
    Validates a downloaded raw byte array against GCS's expected base64-encoded value.
    void
    validateCrc32c(String expectedCrc32cBase64, int calculatedCrc32c)
    Validates a calculated CRC32C value against GCS's expected base64-encoded value.
    wrap(OutputStream out, boolean isChecksumValidationEnabled)
    Returns a wrapping output stream that hashes the written content if validation is enabled, or the original output stream otherwise.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • wrap

      public OutputStream wrap(OutputStream out, boolean isChecksumValidationEnabled)
      Returns a wrapping output stream that hashes the written content if validation is enabled, or the original output stream otherwise.
    • validate

      public void validate(com.google.api.client.http.HttpResponse response, OutputStream activeStream) throws IOException
      Validates the downloaded output stream against GCS's expected base64-encoded value in response headers.
      Throws:
      IOException - if the checksums do not match.
    • shouldValidate

      public boolean shouldValidate(com.google.api.client.http.HttpResponse response)
      Determines if client-side validation should be performed on the downloaded object.
    • validateCrc32c

      public void validateCrc32c(String expectedCrc32cBase64, int calculatedCrc32c) throws IOException
      Validates a calculated CRC32C value against GCS's expected base64-encoded value.
      Throws:
      IOException - if the checksums do not match.
    • validateCrc32c

      public void validateCrc32c(String expectedCrc32cBase64, byte[] content) throws IOException
      Validates a downloaded raw byte array against GCS's expected base64-encoded value.
      Throws:
      IOException - if the checksums do not match.