Skip to content

Commit

Permalink
update snapshot producer
Browse files Browse the repository at this point in the history
  • Loading branch information
ggershinsky committed Mar 26, 2024
1 parent b7c6e9b commit d100dbc
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions core/src/main/java/org/apache/iceberg/SnapshotProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,31 @@ public Snapshot apply() {

OutputFile manifestList = manifestListPath();

EncryptionManager encryptionManager = ops.encryption();
EncryptedOutputFile encryptedManifestList = encryptionManager.encrypt(manifestList);
ByteBuffer manifestListEncryptionKey = encryptedManifestList.keyMetadata().encryptionKey();
String manifestListKeyMetadata = null;
if (manifestListEncryptionKey != null) {
Preconditions.checkArgument(
encryptionManager instanceof StandardEncryptionManager,
"Encryption manager for encrypted manifest list files can currently only be an instance of "
+ StandardEncryptionManager.class);
ByteBuffer wrappedEncryptionKey =
((StandardEncryptionManager) encryptionManager).wrapKey(manifestListEncryptionKey);

ByteBuffer manifestListAADPrefix = encryptedManifestList.keyMetadata().aadPrefix();
manifestListKeyMetadata =
Base64.getEncoder()
.encodeToString(
EncryptionUtil.createKeyMetadata(wrappedEncryptionKey, manifestListAADPrefix)
.buffer()
.array());
}

try (ManifestListWriter writer =
ManifestLists.write(
ops.current().formatVersion(),
manifestList,
encryptedManifestList.encryptingOutputFile(),
snapshotId(),
parentSnapshotId,
sequenceNumber)) {
Expand Down Expand Up @@ -269,7 +290,8 @@ public Snapshot apply() {
operation(),
summary(base),
base.currentSchemaId(),
manifestList.location());
manifestList.location(),
manifestListKeyMetadata);
}

protected abstract Map<String, String> summary();
Expand Down

0 comments on commit d100dbc

Please sign in to comment.