Skip to content

Commit 8a51e07

Browse files
committed
Revert "Encryption integration and test (apache#13066)"
This reverts commit 30ca573.
1 parent 30ca573 commit 8a51e07

File tree

8 files changed

+10
-606
lines changed

8 files changed

+10
-606
lines changed

core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ protected void refreshFromMetadataLocation(
214214
this.shouldRefresh = false;
215215
}
216216

217-
protected String metadataFileLocation(TableMetadata metadata, String filename) {
217+
private String metadataFileLocation(TableMetadata metadata, String filename) {
218218
String metadataLocation = metadata.properties().get(TableProperties.WRITE_METADATA_LOCATION);
219219

220220
if (metadataLocation != null) {

core/src/main/java/org/apache/iceberg/encryption/EncryptionUtil.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static KeyManagementClient createKmsClient(Map<String, String> catalogPro
7575
return kmsClient;
7676
}
7777

78-
public static EncryptionManager createEncryptionManager(
78+
static EncryptionManager createEncryptionManager(
7979
List<EncryptedKey> keys, Map<String, String> tableProperties, KeyManagementClient kmsClient) {
8080
Preconditions.checkArgument(kmsClient != null, "Invalid KMS client: null");
8181
String tableKeyId = tableProperties.get(TableProperties.ENCRYPTION_TABLE_KEY);
@@ -96,7 +96,7 @@ public static EncryptionManager createEncryptionManager(
9696
"Invalid data key length: %s (must be 16, 24, or 32)",
9797
dataKeyLength);
9898

99-
return new StandardEncryptionManager(keys, tableKeyId, dataKeyLength, kmsClient);
99+
return new StandardEncryptionManager(tableKeyId, dataKeyLength, kmsClient);
100100
}
101101

102102
public static EncryptedOutputFile plainAsEncryptedOutput(OutputFile encryptingOutputFile) {
@@ -128,14 +128,6 @@ public static ByteBuffer decryptManifestListKeyMetadata(
128128
return ByteBuffer.wrap(decryptedKeyMetadata);
129129
}
130130

131-
public static Map<String, EncryptedKey> encryptionKeys(EncryptionManager em) {
132-
Preconditions.checkState(
133-
em instanceof StandardEncryptionManager,
134-
"Retrieving encryption keys requires a StandardEncryptionManager");
135-
StandardEncryptionManager sem = (StandardEncryptionManager) em;
136-
return sem.encryptionKeys();
137-
}
138-
139131
/**
140132
* Encrypts the key metadata for a manifest list.
141133
*

core/src/main/java/org/apache/iceberg/encryption/StandardEncryptionManager.java

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.nio.ByteBuffer;
2424
import java.security.SecureRandom;
2525
import java.util.Base64;
26-
import java.util.List;
2726
import java.util.Map;
2827
import java.util.concurrent.TimeUnit;
2928
import org.apache.iceberg.TableProperties;
@@ -47,19 +46,9 @@ private class TransientEncryptionState {
4746
private final Map<String, EncryptedKey> encryptionKeys;
4847
private final LoadingCache<String, ByteBuffer> unwrappedKeyCache;
4948

50-
private TransientEncryptionState(KeyManagementClient kmsClient, List<EncryptedKey> keys) {
49+
private TransientEncryptionState(KeyManagementClient kmsClient) {
5150
this.kmsClient = kmsClient;
5251
this.encryptionKeys = Maps.newLinkedHashMap();
53-
54-
if (keys != null) {
55-
for (EncryptedKey key : keys) {
56-
encryptionKeys.put(
57-
key.keyId(),
58-
new BaseEncryptedKey(
59-
key.keyId(), key.encryptedKeyMetadata(), key.encryptedById(), key.properties()));
60-
}
61-
}
62-
6352
this.unwrappedKeyCache =
6453
Caffeine.newBuilder()
6554
.expireAfterWrite(1, TimeUnit.HOURS)
@@ -75,33 +64,20 @@ private TransientEncryptionState(KeyManagementClient kmsClient, List<EncryptedKe
7564
private transient volatile SecureRandom lazyRNG = null;
7665

7766
/**
78-
* @deprecated will be removed in 2.0.
79-
*/
80-
@Deprecated
81-
public StandardEncryptionManager(
82-
String tableKeyId, int dataKeyLength, KeyManagementClient kmsClient) {
83-
this(List.of(), tableKeyId, dataKeyLength, kmsClient);
84-
}
85-
86-
/**
87-
* @param keys encryption keys from table metadata
8867
* @param tableKeyId table encryption key id
8968
* @param dataKeyLength length of data encryption key (16/24/32 bytes)
9069
* @param kmsClient Client of KMS used to wrap/unwrap keys in envelope encryption
9170
*/
9271
public StandardEncryptionManager(
93-
List<EncryptedKey> keys,
94-
String tableKeyId,
95-
int dataKeyLength,
96-
KeyManagementClient kmsClient) {
72+
String tableKeyId, int dataKeyLength, KeyManagementClient kmsClient) {
9773
Preconditions.checkNotNull(tableKeyId, "Invalid encryption key ID: null");
9874
Preconditions.checkArgument(
9975
dataKeyLength == 16 || dataKeyLength == 24 || dataKeyLength == 32,
10076
"Invalid data key length: %s (must be 16, 24, or 32)",
10177
dataKeyLength);
10278
Preconditions.checkNotNull(kmsClient, "Invalid KMS client: null");
10379
this.tableKeyId = tableKeyId;
104-
this.transientState = new TransientEncryptionState(kmsClient, keys);
80+
this.transientState = new TransientEncryptionState(kmsClient);
10581
this.dataKeyLength = dataKeyLength;
10682
}
10783

@@ -158,14 +134,6 @@ public ByteBuffer unwrapKey(ByteBuffer wrappedSecretKey) {
158134
return transientState.kmsClient.unwrapKey(wrappedSecretKey, tableKeyId);
159135
}
160136

161-
Map<String, EncryptedKey> encryptionKeys() {
162-
if (transientState == null) {
163-
throw new IllegalStateException("Cannot return the encryption keys after serialization");
164-
}
165-
166-
return transientState.encryptionKeys;
167-
}
168-
169137
private String keyEncryptionKeyID() {
170138
if (transientState == null) {
171139
throw new IllegalStateException("Cannot return the current key after serialization");

hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package org.apache.iceberg.hive;
2020

21-
import java.io.IOException;
2221
import java.util.List;
2322
import java.util.Map;
2423
import java.util.Set;
@@ -46,8 +45,6 @@
4645
import org.apache.iceberg.catalog.Namespace;
4746
import org.apache.iceberg.catalog.SupportsNamespaces;
4847
import org.apache.iceberg.catalog.TableIdentifier;
49-
import org.apache.iceberg.encryption.EncryptionUtil;
50-
import org.apache.iceberg.encryption.KeyManagementClient;
5148
import org.apache.iceberg.exceptions.NamespaceNotEmptyException;
5249
import org.apache.iceberg.exceptions.NoSuchIcebergViewException;
5350
import org.apache.iceberg.exceptions.NoSuchNamespaceException;
@@ -91,7 +88,6 @@ public class HiveCatalog extends BaseMetastoreViewCatalog
9188
private String name;
9289
private Configuration conf;
9390
private FileIO fileIO;
94-
private KeyManagementClient keyManagementClient;
9591
private ClientPool<IMetaStoreClient, TException> clients;
9692
private boolean listAllTables = false;
9793
private Map<String, String> catalogProperties;
@@ -126,10 +122,6 @@ public void initialize(String inputName, Map<String, String> properties) {
126122
? new HadoopFileIO(conf)
127123
: CatalogUtil.loadFileIO(fileIOImpl, properties, conf);
128124

129-
if (catalogProperties.containsKey(CatalogProperties.ENCRYPTION_KMS_IMPL)) {
130-
this.keyManagementClient = EncryptionUtil.createKmsClient(properties);
131-
}
132-
133125
this.clients = new CachedClientPool(conf, properties);
134126
}
135127

@@ -694,8 +686,7 @@ private boolean isValidateNamespace(Namespace namespace) {
694686
public TableOperations newTableOps(TableIdentifier tableIdentifier) {
695687
String dbName = tableIdentifier.namespace().level(0);
696688
String tableName = tableIdentifier.name();
697-
return new HiveTableOperations(
698-
conf, clients, fileIO, keyManagementClient, name, dbName, tableName);
689+
return new HiveTableOperations(conf, clients, fileIO, name, dbName, tableName);
699690
}
700691

701692
@Override
@@ -825,15 +816,6 @@ protected Map<String, String> properties() {
825816
return catalogProperties == null ? ImmutableMap.of() : catalogProperties;
826817
}
827818

828-
@Override
829-
public void close() throws IOException {
830-
super.close();
831-
832-
if (keyManagementClient != null) {
833-
keyManagementClient.close();
834-
}
835-
}
836-
837819
@VisibleForTesting
838820
void setListAllTables(boolean listAllTables) {
839821
this.listAllTables = listAllTables;

0 commit comments

Comments
 (0)