Skip to content

Commit 55a2b22

Browse files
committed
Using AWS types in AwsProperties instead of Strings
1 parent 9405f3b commit 55a2b22

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

aws/src/main/java/org/apache/iceberg/aws/AwsProperties.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ public class AwsProperties implements Serializable {
211211
/** Encryption algorithm used to encrypt/decrypt master table keys */
212212
public static final String KMS_ENCRYPTION_ALGORITHM_SPEC = "kms.encryption-algorithm-spec";
213213

214-
public static final String KMS_ENCRYPTION_ALGORITHM_SPEC_DEFAULT =
215-
EncryptionAlgorithmSpec.SYMMETRIC_DEFAULT.toString();
214+
public static final EncryptionAlgorithmSpec KMS_ENCRYPTION_ALGORITHM_SPEC_DEFAULT =
215+
EncryptionAlgorithmSpec.SYMMETRIC_DEFAULT;
216216

217217
/** Length of data key generated by KMS */
218218
public static final String KMS_DATA_KEY_SPEC = "kms.data-key-spec";
219219

220-
public static final String KMS_DATA_KEY_SPEC_DEFAULT = DataKeySpec.AES_256.toString();
220+
public static final DataKeySpec KMS_DATA_KEY_SPEC_DEFAULT = DataKeySpec.AES_256;
221221

222222
private final Set<software.amazon.awssdk.services.sts.model.Tag> stsClientAssumeRoleTags;
223223

@@ -243,8 +243,8 @@ public class AwsProperties implements Serializable {
243243
private String restAccessKeyId;
244244
private String restSecretAccessKey;
245245
private String restSessionToken;
246-
private String kmsEncryptionAlgorithmSpec;
247-
private String kmsDataKeySpec;
246+
private EncryptionAlgorithmSpec kmsEncryptionAlgorithmSpec;
247+
private DataKeySpec kmsDataKeySpec;
248248

249249
public AwsProperties() {
250250
this.stsClientAssumeRoleTags = Sets.newHashSet();
@@ -313,9 +313,12 @@ public AwsProperties(Map<String, String> properties) {
313313
this.restSessionToken = properties.get(REST_SESSION_TOKEN);
314314

315315
this.kmsEncryptionAlgorithmSpec =
316-
properties.getOrDefault(
317-
KMS_ENCRYPTION_ALGORITHM_SPEC, KMS_ENCRYPTION_ALGORITHM_SPEC_DEFAULT);
318-
this.kmsDataKeySpec = properties.getOrDefault(KMS_DATA_KEY_SPEC, KMS_DATA_KEY_SPEC_DEFAULT);
316+
EncryptionAlgorithmSpec.fromValue(
317+
properties.getOrDefault(
318+
KMS_ENCRYPTION_ALGORITHM_SPEC, KMS_ENCRYPTION_ALGORITHM_SPEC_DEFAULT.toString()));
319+
this.kmsDataKeySpec =
320+
DataKeySpec.fromValue(
321+
properties.getOrDefault(KMS_DATA_KEY_SPEC, KMS_DATA_KEY_SPEC_DEFAULT.toString()));
319322
}
320323

321324
public Set<software.amazon.awssdk.services.sts.model.Tag> stsClientAssumeRoleTags() {
@@ -426,11 +429,11 @@ public AwsCredentialsProvider restCredentialsProvider() {
426429
}
427430

428431
public EncryptionAlgorithmSpec kmsEncryptionAlgorithmSpec() {
429-
return EncryptionAlgorithmSpec.fromValue(this.kmsEncryptionAlgorithmSpec);
432+
return this.kmsEncryptionAlgorithmSpec;
430433
}
431434

432435
public DataKeySpec kmsDataKeySpec() {
433-
return DataKeySpec.fromValue(this.kmsDataKeySpec);
436+
return this.kmsDataKeySpec;
434437
}
435438

436439
private Set<software.amazon.awssdk.services.sts.model.Tag> toStsTags(

0 commit comments

Comments
 (0)