kopia lustrzana https://github.com/gaul/s3proxy
rodzic
2473e6c309
commit
9329b161f2
|
@ -420,12 +420,16 @@ public class S3ProxyHandler {
|
|||
expectedSignature = createAuthorizationSignature(request,
|
||||
uri, credential);
|
||||
} else {
|
||||
String contentSha256 = request.getHeader(
|
||||
"x-amz-content-sha256");
|
||||
try {
|
||||
byte[] payload;
|
||||
if ("STREAMING-AWS4-HMAC-SHA256-PAYLOAD".equals(
|
||||
request.getHeader("x-amz-content-sha256"))) {
|
||||
contentSha256)) {
|
||||
payload = new byte[0];
|
||||
is = new ChunkedInputStream(is);
|
||||
} else if ("UNSIGNED-PAYLOAD".equals(contentSha256)) {
|
||||
payload = new byte[0];
|
||||
} else {
|
||||
// buffer the entire stream to calculate digest
|
||||
payload = ByteStreams.toByteArray(ByteStreams.limit(
|
||||
|
@ -2570,6 +2574,8 @@ public class S3ProxyHandler {
|
|||
String digest;
|
||||
if ("STREAMING-AWS4-HMAC-SHA256-PAYLOAD".equals(xAmzContentSha256)) {
|
||||
digest = "STREAMING-AWS4-HMAC-SHA256-PAYLOAD";
|
||||
} else if ("UNSIGNED-PAYLOAD".equals(xAmzContentSha256)) {
|
||||
digest = "UNSIGNED-PAYLOAD";
|
||||
} else {
|
||||
digest = getMessageDigest(payload, hashAlgorithm);
|
||||
}
|
||||
|
|
|
@ -199,6 +199,29 @@ public final class S3AwsSdkTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAwsV4SignaturePayloadUnsigned() throws Exception {
|
||||
client = AmazonS3ClientBuilder.standard()
|
||||
.withChunkedEncodingDisabled(true)
|
||||
.withPayloadSigningEnabled(false)
|
||||
.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
|
||||
.withEndpointConfiguration(s3EndpointConfig)
|
||||
.build();
|
||||
|
||||
ObjectMetadata metadata = new ObjectMetadata();
|
||||
metadata.setContentLength(BYTE_SOURCE.size());
|
||||
client.putObject(containerName, "foo",
|
||||
BYTE_SOURCE.openStream(), metadata);
|
||||
|
||||
S3Object object = client.getObject(containerName, "foo");
|
||||
assertThat(object.getObjectMetadata().getContentLength()).isEqualTo(
|
||||
BYTE_SOURCE.size());
|
||||
try (InputStream actual = object.getObjectContent();
|
||||
InputStream expected = BYTE_SOURCE.openStream()) {
|
||||
assertThat(actual).hasContentEqualTo(expected);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAwsV4SignatureBadIdentity() throws Exception {
|
||||
client = AmazonS3ClientBuilder.standard()
|
||||
|
|
Ładowanie…
Reference in New Issue