Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1919,7 +1919,8 @@ private FSDataInputStream executeOpen(
.withCallbacks(createInputStreamCallbacks(auditSpan))
.withContext(readContext.build())
.withObjectAttributes(createObjectAttributes(path, fileStatus))
.withStreamStatistics(inputStreamStats);
.withStreamStatistics(inputStreamStats)
.withEncryptionSecrets(getEncryptionSecrets());
return new FSDataInputStream(getStore().readObject(parameters));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import java.util.function.IntFunction;
import java.util.Optional;

import org.apache.hadoop.fs.s3a.S3AEncryptionMethods;
import org.apache.hadoop.fs.s3a.auth.delegation.EncryptionSecretOperations;
import software.amazon.s3.analyticsaccelerator.S3SeekableInputStreamFactory;
import software.amazon.s3.analyticsaccelerator.S3SeekableInputStream;
import software.amazon.s3.analyticsaccelerator.common.ObjectRange;
import software.amazon.s3.analyticsaccelerator.request.EncryptionSecrets;
import software.amazon.s3.analyticsaccelerator.request.ObjectMetadata;
import software.amazon.s3.analyticsaccelerator.util.InputPolicy;
import software.amazon.s3.analyticsaccelerator.util.OpenStreamInformation;
Expand Down Expand Up @@ -253,6 +257,12 @@ private OpenStreamInformation buildOpenStreamInformation(ObjectReadParameters pa
.etag(parameters.getObjectAttributes().getETag()).build());
}

if (parameters.getEncryptionSecrets().getEncryptionMethod() == S3AEncryptionMethods.SSE_C) {
EncryptionSecretOperations.getSSECustomerKey(parameters.getEncryptionSecrets())
.ifPresent(base64customerKey -> openStreamInformationBuilder.encryptionSecrets(
EncryptionSecrets.builder().sseCustomerKey(Optional.of(base64customerKey)).build()));
}

return openStreamInformationBuilder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.hadoop.fs.LocalDirAllocator;
import org.apache.hadoop.fs.s3a.S3AReadOpContext;
import org.apache.hadoop.fs.s3a.S3ObjectAttributes;
import org.apache.hadoop.fs.s3a.auth.delegation.EncryptionSecrets;
import org.apache.hadoop.fs.s3a.statistics.S3AInputStreamStatistics;

import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -69,6 +70,29 @@ public final class ObjectReadParameters {
*/
private LocalDirAllocator directoryAllocator;

/**
* Encryption secrets for this stream.
*/
private EncryptionSecrets encryptionSecrets;

/**
* Getter.
* @return Encryption secrets.
*/
public EncryptionSecrets getEncryptionSecrets() {
return encryptionSecrets;
}

/**
* Set encryption secrets.
* @param value new value
* @return the builder
*/
public ObjectReadParameters withEncryptionSecrets(final EncryptionSecrets value) {
encryptionSecrets = value;
return this;
}

/**
* @return Read operation context.
*/
Expand Down Expand Up @@ -185,6 +209,7 @@ public ObjectReadParameters validate() {
requireNonNull(directoryAllocator, "directoryAllocator");
requireNonNull(objectAttributes, "objectAttributes");
requireNonNull(streamStatistics, "streamStatistics");
requireNonNull(encryptionSecrets, "encryptionSecrets");
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@

import java.io.IOException;
import java.nio.file.AccessDeniedException;
import java.util.Arrays;
import java.util.Collection;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedClass;
import org.junit.jupiter.params.provider.MethodSource;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
Expand All @@ -42,10 +46,10 @@
import static org.apache.hadoop.fs.s3a.Constants.SERVER_SIDE_ENCRYPTION_KEY;

import static org.apache.hadoop.fs.s3a.S3ATestUtils.assumeStoreAwsHosted;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.enableAnalyticsAccelerator;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.getTestBucketName;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.maybeSkipRootTests;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.removeBaseAndBucketOverrides;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.skipIfAnalyticsAcceleratorEnabled;
import static org.apache.hadoop.test.LambdaTestUtils.intercept;

/**
Expand All @@ -56,6 +60,8 @@
* Equally "vexing" has been the optimizations of getFileStatus(), wherein
* LIST comes before HEAD path + /
*/
@ParameterizedClass(name="analytics-accelerator-enabled-{0}")
@MethodSource("params")
public class ITestS3AEncryptionSSEC extends AbstractTestS3AEncryption {

private static final String SERVICE_AMAZON_S3_STATUS_CODE_403
Expand All @@ -75,6 +81,19 @@ public class ITestS3AEncryptionSSEC extends AbstractTestS3AEncryption {
*/
private S3AFileSystem fsKeyB;

private final boolean analyticsAcceleratorEnabled;

public static Collection<Object[]> params() {
return Arrays.asList(new Object[][]{
{true},
{false}
});
}

public ITestS3AEncryptionSSEC (final boolean analyticsAcceleratorEnabled) {
this.analyticsAcceleratorEnabled = analyticsAcceleratorEnabled;
}


@SuppressWarnings("deprecation")
@Override
Expand All @@ -92,15 +111,18 @@ protected Configuration createConfiguration() {
getSSEAlgorithm().getMethod());
conf.set(S3_ENCRYPTION_KEY, KEY_1);
conf.setBoolean(ETAG_CHECKSUM_ENABLED, true);

if (analyticsAcceleratorEnabled) {
enableAnalyticsAccelerator(conf);
}

return conf;
}

@BeforeEach
@Override
public void setup() throws Exception {
super.setup();
skipIfAnalyticsAcceleratorEnabled(getConfiguration(),
"Analytics Accelerator currently does not support SSE-C");
assumeEnabled();
// although not a root dir test, this confuses paths enough it shouldn't be run in
// parallel with other jobs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import static org.apache.hadoop.fs.s3a.Constants.SERVER_SIDE_ENCRYPTION_ALGORITHM;
import static org.apache.hadoop.fs.s3a.Constants.SERVER_SIDE_ENCRYPTION_KEY;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.removeBaseAndBucketOverrides;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.skipIfAnalyticsAcceleratorEnabled;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.skipIfEncryptionTestsDisabled;

/**
Expand All @@ -60,8 +59,6 @@ public class ITestS3AHugeFilesSSECDiskBlocks
public void setup() throws Exception {
try {
super.setup();
skipIfAnalyticsAcceleratorEnabled(getConfiguration(),
"Analytics Accelerator currently does not support SSE-C");
} catch (AccessDeniedException | AWSUnsupportedFeatureException e) {
skip("Bucket does not allow " + S3AEncryptionMethods.SSE_C + " encryption method");
}
Expand Down