forked from apache/iceberg
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rdar://134867479 (Client Side Encryption is missing from Iceberg Rest…
… Catalog) (apache#1312) * (apple-internal) Support encryption/decryption in REST Catalog --------- Co-authored-by: huanghsiang_cheng <[email protected]>
- Loading branch information
1 parent
6f52a07
commit 90ef7e9
Showing
6 changed files
with
532 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
core/src/test/java/org/apache/iceberg/encryption/EncryptedLocalOutputFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.iceberg.encryption; | ||
|
||
import static org.apache.iceberg.Files.localOutput; | ||
|
||
import java.io.File; | ||
import org.apache.iceberg.io.InputFile; | ||
import org.apache.iceberg.io.OutputFile; | ||
import org.apache.iceberg.io.PositionOutputStream; | ||
|
||
public class EncryptedLocalOutputFile implements OutputFile, NativelyEncryptedFile { | ||
private OutputFile localOutputFile; | ||
private NativeFileCryptoParameters nativeEncryptionParameters; | ||
|
||
public EncryptedLocalOutputFile(File file) { | ||
localOutputFile = localOutput(file); | ||
} | ||
|
||
@Override | ||
public PositionOutputStream create() { | ||
return localOutputFile.create(); | ||
} | ||
|
||
@Override | ||
public PositionOutputStream createOrOverwrite() { | ||
return localOutputFile.createOrOverwrite(); | ||
} | ||
|
||
@Override | ||
public String location() { | ||
return localOutputFile.location(); | ||
} | ||
|
||
@Override | ||
public InputFile toInputFile() { | ||
return localOutputFile.toInputFile(); | ||
} | ||
|
||
@Override | ||
public NativeFileCryptoParameters nativeCryptoParameters() { | ||
return nativeEncryptionParameters; | ||
} | ||
|
||
@Override | ||
public void setNativeCryptoParameters(NativeFileCryptoParameters nativeCryptoParameters) { | ||
this.nativeEncryptionParameters = nativeCryptoParameters; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
core/src/test/java/org/apache/iceberg/encryption/kms/UnitestKMS.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.iceberg.encryption.kms; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.Map; | ||
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; | ||
|
||
public class UnitestKMS extends MemoryMockKMS { | ||
public static final String MASTER_KEY_NAME1 = "keyA"; | ||
public static final byte[] MASTER_KEY1 = "0123456789012345".getBytes(StandardCharsets.UTF_8); | ||
public static final String MASTER_KEY_NAME2 = "keyB"; | ||
public static final byte[] MASTER_KEY2 = "1123456789012345".getBytes(StandardCharsets.UTF_8); | ||
|
||
@Override | ||
public void initialize(Map<String, String> properties) { | ||
masterKeys = | ||
ImmutableMap.of( | ||
MASTER_KEY_NAME1, MASTER_KEY1, | ||
MASTER_KEY_NAME2, MASTER_KEY2); | ||
} | ||
} |
Oops, something went wrong.