Skip to content

Commit e7a5a87

Browse files
authored
Azure: Avoid depending on KeyWrapAlgorithm in AzureProperties (#16186)
* Azure: Avoid depending on KeyWrapAlgorithm in AzureProperties * fixup! Azure: Avoid depending on KeyWrapAlgorithm in AzureProperties
1 parent 9b8bde4 commit e7a5a87

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

azure/src/main/java/org/apache/iceberg/azure/AzureProperties.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.azure.core.credential.AccessToken;
2222
import com.azure.core.credential.TokenCredential;
2323
import com.azure.core.credential.TokenRequestContext;
24-
import com.azure.security.keyvault.keys.cryptography.models.KeyWrapAlgorithm;
2524
import com.azure.storage.common.StorageSharedKeyCredential;
2625
import com.azure.storage.file.datalake.DataLakeFileSystemClientBuilder;
2726
import java.io.Serializable;
@@ -53,6 +52,9 @@ public class AzureProperties implements Serializable {
5352
public static final String AZURE_KEYVAULT_KEY_WRAP_ALGORITHM =
5453
"azure.keyvault.key-wrap-algorithm";
5554

55+
// Must match KeyWrapAlgorithm.RSA_OAEP_256.getValue() from azure-security-keyvault-keys
56+
private static final String DEFAULT_KEY_WRAP_ALGORITHM = "RSA-OAEP-256";
57+
5658
/**
5759
* Configure the ADLS token credential provider used to get {@link TokenCredential}. A fully
5860
* qualified concrete class with package that implements the {@link AdlsTokenCredentialProvider}
@@ -136,8 +138,7 @@ public AzureProperties(Map<String, String> properties) {
136138

137139
this.keyWrapAlgorithm =
138140
properties.getOrDefault(
139-
AzureProperties.AZURE_KEYVAULT_KEY_WRAP_ALGORITHM,
140-
KeyWrapAlgorithm.RSA_OAEP_256.getValue());
141+
AzureProperties.AZURE_KEYVAULT_KEY_WRAP_ALGORITHM, DEFAULT_KEY_WRAP_ALGORITHM);
141142
}
142143

143144
public Optional<Integer> adlsReadBlockSize() {
@@ -204,8 +205,8 @@ public Mono<AccessToken> getToken(TokenRequestContext request) {
204205
}
205206
}
206207

207-
public KeyWrapAlgorithm keyWrapAlgorithm() {
208-
return KeyWrapAlgorithm.fromString(this.keyWrapAlgorithm);
208+
public String keyWrapAlgorithm() {
209+
return this.keyWrapAlgorithm;
209210
}
210211

211212
public Optional<String> keyVaultUrl() {

azure/src/main/java/org/apache/iceberg/azure/keymanagement/AzureKeyManagementClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ private ClientState state() {
8080
keyClientBuilder
8181
.credential(AdlsTokenCredentialProviders.from(allProperties).credential())
8282
.buildClient();
83-
KeyWrapAlgorithm keyWrapAlgorithm = azureProperties.keyWrapAlgorithm();
83+
KeyWrapAlgorithm keyWrapAlgorithm =
84+
KeyWrapAlgorithm.fromString(azureProperties.keyWrapAlgorithm());
8485
state = new ClientState(keyClient, keyWrapAlgorithm);
8586
}
8687
}

0 commit comments

Comments
 (0)