List of usage examples for com.amazonaws.auth AbstractAWSSigner EMPTY_STRING_SHA256_HEX
String EMPTY_STRING_SHA256_HEX
To view the source code for com.amazonaws.auth AbstractAWSSigner EMPTY_STRING_SHA256_HEX.
Click Source Link
From source file:com.ibm.og.s3.v4.AwsChunkedEncodingInputStream.java
License:Open Source License
private byte[] createSignedChunk(final byte[] chunkData) { final StringBuilder chunkHeader = new StringBuilder(); // chunk-size chunkHeader.append(Integer.toHexString(chunkData.length)); byte[] chunkDigest; if (this.digestCache != null) { try {//from www. j a v a2s . c o m chunkDigest = this.digestCache.get((long) chunkData.length); } catch (final ExecutionException e) { throw new RuntimeException(e); } } else { chunkDigest = this.sha256.digest(chunkData); } // sig-extension final String chunkStringToSign = CHUNK_STRING_TO_SIGN_PREFIX + "\n" + this.dateTime + "\n" + this.keyPath + "\n" + this.priorChunkSignature + "\n" + AbstractAWSSigner.EMPTY_STRING_SHA256_HEX + "\n" + BinaryUtils.toHex(chunkDigest); final String chunkSignature = BinaryUtils .toHex(this.aws4Signer.signWithMac(chunkStringToSign, this.hmacSha256)); this.priorChunkSignature = chunkSignature; chunkHeader.append(CHUNK_SIGNATURE_HEADER).append(chunkSignature).append(CRLF); try { final byte[] header = chunkHeader.toString().getBytes(UTF8); final byte[] trailer = CRLF.getBytes(UTF8); final byte[] signedChunk = new byte[header.length + chunkData.length + trailer.length]; System.arraycopy(header, 0, signedChunk, 0, header.length); System.arraycopy(chunkData, 0, signedChunk, header.length, chunkData.length); System.arraycopy(trailer, 0, signedChunk, header.length + chunkData.length, trailer.length); return signedChunk; } catch (final Exception e) { throw new AmazonClientException("Unable to sign the chunked data. " + e.getMessage(), e); } }