Package com.adobe.testing.s3mock.util
Class AwsChecksumInputStream
java.lang.Object
java.io.InputStream
com.adobe.testing.s3mock.util.AwsChecksumInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
AwsChunkedDecodingChecksumInputStream
Reads checksum from incoming stream.
When the AWS client sends a checksum in the request, it's embedded into the request body and
surrounds the payload.
The stream looks like this:
24 ## sample test file ## demo=content 0 x-amz-checksum-sha1:+AXXQmKfnxMv0B57SJutbNpZBww=The format is this:
[hex-encoded-number-of-bytes-in-payload][crlf] [payload-bytes] 0[crlf] [amazon-checksum-header]:[checksum][crlf]
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChecksumAlgorithmprotected Stringprotected static final byte[]protected static final byte[]protected static final byte[]protected longprotected final InputStream -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected booleanendsWith(ByteBuffer buffer, byte[] endSequence) protected voidintread()protected byte[]readUntil(byte[] endSequence) Reads this stream until the byte sequence was found.protected voidsetPayloadLength(byte[] hexLengthBytes) Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
CHECKSUM_HEADER
protected static final byte[] CHECKSUM_HEADER -
checksum
-
algorithm
-
CRLF
protected static final byte[] CRLF -
DELIMITER
protected static final byte[] DELIMITER -
source
-
payloadLength
protected long payloadLength
-
-
Constructor Details
-
AwsChecksumInputStream
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
extractAlgorithmAndChecksum
- Throws:
IOException
-
getChecksum
-
getAlgorithm
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
readUntil
Reads this stream until the byte sequence was found.- Parameters:
endSequence- The byte sequence to look for in the stream. The source stream is read until the last bytes read are equal to this sequence.- Returns:
- The bytes read before the end sequence started.
- Throws:
IOException
-
endsWith
-
setPayloadLength
protected void setPayloadLength(byte[] hexLengthBytes)
-