Skip to content

Commit 615af79

Browse files
committed
Revert "HADOOP-19197. S3A: Support AWS KMS Encryption Context (#7193)"
This reverts commit eb656c0. This was done because the writable/serializable class org.apache.hadoop.fs.s3a.auth.delegation.EncryptionSecrets is no longer wire-compatible once context attributes are included.
1 parent 5d11b3a commit 615af79

File tree

18 files changed

+30
-514
lines changed

18 files changed

+30
-514
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/CommonConfigurationKeysPublic.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,6 @@ public class CommonConfigurationKeysPublic {
10221022
"fs.s3a.*.server-side-encryption.key",
10231023
"fs.s3a.encryption.algorithm",
10241024
"fs.s3a.encryption.key",
1025-
"fs.s3a.encryption.context",
10261025
"fs.azure\\.account.key.*",
10271026
"credential$",
10281027
"oauth.*secret",

hadoop-common-project/hadoop-common/src/main/resources/core-default.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,6 @@
742742
fs.s3a.*.server-side-encryption.key
743743
fs.s3a.encryption.algorithm
744744
fs.s3a.encryption.key
745-
fs.s3a.encryption.context
746745
fs.s3a.secret.key
747746
fs.s3a.*.secret.key
748747
fs.s3a.session.key
@@ -1780,15 +1779,6 @@
17801779
</description>
17811780
</property>
17821781

1783-
<property>
1784-
<name>fs.s3a.encryption.context</name>
1785-
<description>Specific encryption context to use if fs.s3a.encryption.algorithm
1786-
has been set to 'SSE-KMS' or 'DSSE-KMS'. The value of this property is a set
1787-
of non-secret comma-separated key-value pairs of additional contextual
1788-
information about the data that are separated by equal operator (=).
1789-
</description>
1790-
</property>
1791-
17921782
<property>
17931783
<name>fs.s3a.signing-algorithm</name>
17941784
<description>Override the default signing algorithm so legacy

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/Constants.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -774,16 +774,6 @@ private Constants() {
774774
public static final String S3_ENCRYPTION_KEY =
775775
"fs.s3a.encryption.key";
776776

777-
/**
778-
* Set S3-SSE encryption context.
779-
* The value of this property is a set of non-secret comma-separated key-value pairs
780-
* of additional contextual information about the data that are separated by equal
781-
* operator (=).
782-
* value:{@value}
783-
*/
784-
public static final String S3_ENCRYPTION_CONTEXT =
785-
"fs.s3a.encryption.context";
786-
787777
/**
788778
* Client side encryption (CSE-CUSTOM) with custom cryptographic material manager class name.
789779
* Custom keyring class name for CSE-KMS.

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AUtils.java

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.apache.hadoop.fs.PathFilter;
3939
import org.apache.hadoop.fs.PathIOException;
4040
import org.apache.hadoop.fs.RemoteIterator;
41-
import org.apache.hadoop.fs.s3a.impl.S3AEncryption;
4241
import org.apache.hadoop.util.functional.RemoteIterators;
4342
import org.apache.hadoop.fs.s3a.auth.delegation.EncryptionSecrets;
4443
import org.apache.hadoop.fs.s3a.impl.MultiObjectDeleteException;
@@ -1325,7 +1324,7 @@ static void patchSecurityCredentialProviders(Configuration conf) {
13251324
* @throws IOException on any IO problem
13261325
* @throws IllegalArgumentException bad arguments
13271326
*/
1328-
public static String lookupBucketSecret(
1327+
private static String lookupBucketSecret(
13291328
String bucket,
13301329
Configuration conf,
13311330
String baseKey)
@@ -1471,8 +1470,6 @@ public static EncryptionSecrets buildEncryptionSecrets(String bucket,
14711470
int encryptionKeyLen =
14721471
StringUtils.isBlank(encryptionKey) ? 0 : encryptionKey.length();
14731472
String diagnostics = passwordDiagnostics(encryptionKey, "key");
1474-
String encryptionContext = S3AEncryption.getS3EncryptionContextBase64Encoded(bucket, conf,
1475-
encryptionMethod.requiresSecret());
14761473
switch (encryptionMethod) {
14771474
case SSE_C:
14781475
LOG.debug("Using SSE-C with {}", diagnostics);
@@ -1508,7 +1505,7 @@ public static EncryptionSecrets buildEncryptionSecrets(String bucket,
15081505
LOG.debug("Data is unencrypted");
15091506
break;
15101507
}
1511-
return new EncryptionSecrets(encryptionMethod, encryptionKey, encryptionContext);
1508+
return new EncryptionSecrets(encryptionMethod, encryptionKey);
15121509
}
15131510

15141511
/**
@@ -1701,21 +1698,6 @@ public static Map<String, String> getTrimmedStringCollectionSplitByEquals(
17011698
final Configuration configuration,
17021699
final String name) {
17031700
String valueString = configuration.get(name);
1704-
return getTrimmedStringCollectionSplitByEquals(valueString);
1705-
}
1706-
1707-
/**
1708-
* Get the equal op (=) delimited key-value pairs of the <code>name</code> property as
1709-
* a collection of pair of <code>String</code>s, trimmed of the leading and trailing whitespace
1710-
* after delimiting the <code>name</code> by comma and new line separator.
1711-
* If no such property is specified then empty <code>Map</code> is returned.
1712-
*
1713-
* @param valueString the string containing the key-value pairs.
1714-
* @return property value as a <code>Map</code> of <code>String</code>s, or empty
1715-
* <code>Map</code>.
1716-
*/
1717-
public static Map<String, String> getTrimmedStringCollectionSplitByEquals(
1718-
final String valueString) {
17191701
if (null == valueString) {
17201702
return new HashMap<>();
17211703
}

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/auth/delegation/EncryptionSecretOperations.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,4 @@ public static Optional<String> getSSEAwsKMSKey(final EncryptionSecrets secrets)
6161
return Optional.empty();
6262
}
6363
}
64-
65-
/**
66-
* Gets the SSE-KMS context if present, else don't set it in the S3 request.
67-
*
68-
* @param secrets source of the encryption secrets.
69-
* @return an optional AWS KMS encryption context to attach to a request.
70-
*/
71-
public static Optional<String> getSSEAwsKMSEncryptionContext(final EncryptionSecrets secrets) {
72-
if ((secrets.getEncryptionMethod() == S3AEncryptionMethods.SSE_KMS
73-
|| secrets.getEncryptionMethod() == S3AEncryptionMethods.DSSE_KMS)
74-
&& secrets.hasEncryptionContext()) {
75-
return Optional.of(secrets.getEncryptionContext());
76-
} else {
77-
return Optional.empty();
78-
}
79-
}
8064
}

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/auth/delegation/EncryptionSecrets.java

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ public class EncryptionSecrets implements Writable, Serializable {
6767
*/
6868
private String encryptionKey = "";
6969

70-
/**
71-
* Encryption context: base64-encoded UTF-8 string.
72-
*/
73-
private String encryptionContext = "";
74-
7570
/**
7671
* This field isn't serialized/marshalled; it is rebuilt from the
7772
* encryptionAlgorithm field.
@@ -89,28 +84,23 @@ public EncryptionSecrets() {
8984
* Create a pair of secrets.
9085
* @param encryptionAlgorithm algorithm enumeration.
9186
* @param encryptionKey key/key reference.
92-
* @param encryptionContext base64-encoded string with the encryption context key-value pairs.
9387
* @throws IOException failure to initialize.
9488
*/
9589
public EncryptionSecrets(final S3AEncryptionMethods encryptionAlgorithm,
96-
final String encryptionKey,
97-
final String encryptionContext) throws IOException {
98-
this(encryptionAlgorithm.getMethod(), encryptionKey, encryptionContext);
90+
final String encryptionKey) throws IOException {
91+
this(encryptionAlgorithm.getMethod(), encryptionKey);
9992
}
10093

10194
/**
10295
* Create a pair of secrets.
10396
* @param encryptionAlgorithm algorithm name
10497
* @param encryptionKey key/key reference.
105-
* @param encryptionContext base64-encoded string with the encryption context key-value pairs.
10698
* @throws IOException failure to initialize.
10799
*/
108100
public EncryptionSecrets(final String encryptionAlgorithm,
109-
final String encryptionKey,
110-
final String encryptionContext) throws IOException {
101+
final String encryptionKey) throws IOException {
111102
this.encryptionAlgorithm = encryptionAlgorithm;
112103
this.encryptionKey = encryptionKey;
113-
this.encryptionContext = encryptionContext;
114104
init();
115105
}
116106

@@ -124,7 +114,6 @@ public void write(final DataOutput out) throws IOException {
124114
new LongWritable(serialVersionUID).write(out);
125115
Text.writeString(out, encryptionAlgorithm);
126116
Text.writeString(out, encryptionKey);
127-
Text.writeString(out, encryptionContext);
128117
}
129118

130119
/**
@@ -143,7 +132,6 @@ public void readFields(final DataInput in) throws IOException {
143132
}
144133
encryptionAlgorithm = Text.readString(in, MAX_SECRET_LENGTH);
145134
encryptionKey = Text.readString(in, MAX_SECRET_LENGTH);
146-
encryptionContext = Text.readString(in);
147135
init();
148136
}
149137

@@ -176,10 +164,6 @@ public String getEncryptionKey() {
176164
return encryptionKey;
177165
}
178166

179-
public String getEncryptionContext() {
180-
return encryptionContext;
181-
}
182-
183167
/**
184168
* Does this instance have encryption options?
185169
* That is: is the algorithm non-null.
@@ -197,14 +181,6 @@ public boolean hasEncryptionKey() {
197181
return StringUtils.isNotEmpty(encryptionKey);
198182
}
199183

200-
/**
201-
* Does this instance have an encryption context?
202-
* @return true if there's an encryption context.
203-
*/
204-
public boolean hasEncryptionContext() {
205-
return StringUtils.isNotEmpty(encryptionContext);
206-
}
207-
208184
@Override
209185
public boolean equals(final Object o) {
210186
if (this == o) {
@@ -215,13 +191,12 @@ public boolean equals(final Object o) {
215191
}
216192
final EncryptionSecrets that = (EncryptionSecrets) o;
217193
return Objects.equals(encryptionAlgorithm, that.encryptionAlgorithm)
218-
&& Objects.equals(encryptionKey, that.encryptionKey)
219-
&& Objects.equals(encryptionContext, that.encryptionContext);
194+
&& Objects.equals(encryptionKey, that.encryptionKey);
220195
}
221196

222197
@Override
223198
public int hashCode() {
224-
return Objects.hash(encryptionAlgorithm, encryptionKey, encryptionContext);
199+
return Objects.hash(encryptionAlgorithm, encryptionKey);
225200
}
226201

227202
/**

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/RequestFactoryImpl.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,6 @@ protected void copyEncryptionParameters(HeadObjectResponse srcom,
298298
LOG.debug("Propagating SSE-KMS settings from source {}",
299299
sourceKMSId);
300300
copyObjectRequestBuilder.ssekmsKeyId(sourceKMSId);
301-
EncryptionSecretOperations.getSSEAwsKMSEncryptionContext(encryptionSecrets)
302-
.ifPresent(copyObjectRequestBuilder::ssekmsEncryptionContext);
303301
return;
304302
}
305303

@@ -312,15 +310,11 @@ protected void copyEncryptionParameters(HeadObjectResponse srcom,
312310
// Set the KMS key if present, else S3 uses AWS managed key.
313311
EncryptionSecretOperations.getSSEAwsKMSKey(encryptionSecrets)
314312
.ifPresent(copyObjectRequestBuilder::ssekmsKeyId);
315-
EncryptionSecretOperations.getSSEAwsKMSEncryptionContext(encryptionSecrets)
316-
.ifPresent(copyObjectRequestBuilder::ssekmsEncryptionContext);
317313
break;
318314
case DSSE_KMS:
319315
copyObjectRequestBuilder.serverSideEncryption(ServerSideEncryption.AWS_KMS_DSSE);
320316
EncryptionSecretOperations.getSSEAwsKMSKey(encryptionSecrets)
321317
.ifPresent(copyObjectRequestBuilder::ssekmsKeyId);
322-
EncryptionSecretOperations.getSSEAwsKMSEncryptionContext(encryptionSecrets)
323-
.ifPresent(copyObjectRequestBuilder::ssekmsEncryptionContext);
324318
break;
325319
case SSE_C:
326320
EncryptionSecretOperations.getSSECustomerKey(encryptionSecrets)
@@ -427,15 +421,11 @@ private void putEncryptionParameters(PutObjectRequest.Builder putObjectRequestBu
427421
// Set the KMS key if present, else S3 uses AWS managed key.
428422
EncryptionSecretOperations.getSSEAwsKMSKey(encryptionSecrets)
429423
.ifPresent(putObjectRequestBuilder::ssekmsKeyId);
430-
EncryptionSecretOperations.getSSEAwsKMSEncryptionContext(encryptionSecrets)
431-
.ifPresent(putObjectRequestBuilder::ssekmsEncryptionContext);
432424
break;
433425
case DSSE_KMS:
434426
putObjectRequestBuilder.serverSideEncryption(ServerSideEncryption.AWS_KMS_DSSE);
435427
EncryptionSecretOperations.getSSEAwsKMSKey(encryptionSecrets)
436428
.ifPresent(putObjectRequestBuilder::ssekmsKeyId);
437-
EncryptionSecretOperations.getSSEAwsKMSEncryptionContext(encryptionSecrets)
438-
.ifPresent(putObjectRequestBuilder::ssekmsEncryptionContext);
439429
break;
440430
case SSE_C:
441431
EncryptionSecretOperations.getSSECustomerKey(encryptionSecrets)
@@ -507,15 +497,11 @@ private void multipartUploadEncryptionParameters(
507497
// Set the KMS key if present, else S3 uses AWS managed key.
508498
EncryptionSecretOperations.getSSEAwsKMSKey(encryptionSecrets)
509499
.ifPresent(mpuRequestBuilder::ssekmsKeyId);
510-
EncryptionSecretOperations.getSSEAwsKMSEncryptionContext(encryptionSecrets)
511-
.ifPresent(mpuRequestBuilder::ssekmsEncryptionContext);
512500
break;
513501
case DSSE_KMS:
514502
mpuRequestBuilder.serverSideEncryption(ServerSideEncryption.AWS_KMS_DSSE);
515503
EncryptionSecretOperations.getSSEAwsKMSKey(encryptionSecrets)
516504
.ifPresent(mpuRequestBuilder::ssekmsKeyId);
517-
EncryptionSecretOperations.getSSEAwsKMSEncryptionContext(encryptionSecrets)
518-
.ifPresent(mpuRequestBuilder::ssekmsEncryptionContext);
519505
break;
520506
case SSE_C:
521507
EncryptionSecretOperations.getSSECustomerKey(encryptionSecrets)

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/S3AEncryption.java

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)