Skip to content

Commit 3db992c

Browse files
author
Bryan Donlan
committed
Add a builder API for constructing KMS MKPs
The current KMS MKP constructors use legacy (@deprecated) KMS client constructors, and are likely to break at some point in the future. In addition, they also mutate the client that is passed in, and have an unfortunate combinatorial explosion of argument types. This change introduces a new builder API for constructing KMS MKPs, and deprecates the old one. In addition, it adds support for decrypting KMS keys from multiple regions with the same MKP, bringing us to feature parity with the Python SDK. For now, the semantics of code using the old constructors is unchanged, but it's likely that we'll want to remove these constructors the next time we make a breaking change to our APIs.
1 parent d77d255 commit 3db992c

File tree

11 files changed

+855
-172
lines changed

11 files changed

+855
-172
lines changed

src/main/java/com/amazonaws/encryptionsdk/kms/KmsMasterKey.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@
1313

1414
package com.amazonaws.encryptionsdk.kms;
1515

16+
import javax.crypto.SecretKey;
17+
import javax.crypto.spec.SecretKeySpec;
1618
import java.nio.ByteBuffer;
1719
import java.nio.charset.StandardCharsets;
1820
import java.util.ArrayList;
1921
import java.util.Collection;
2022
import java.util.List;
2123
import java.util.Map;
2224

23-
import javax.crypto.SecretKey;
24-
import javax.crypto.spec.SecretKeySpec;
25-
2625
import com.amazonaws.AmazonServiceException;
2726
import com.amazonaws.auth.AWSCredentials;
2827
import com.amazonaws.auth.AWSCredentialsProvider;
@@ -52,10 +51,20 @@ public final class KmsMasterKey extends MasterKey<KmsMasterKey> implements KmsMe
5251
private final String id_;
5352
private final List<String> grantTokens_ = new ArrayList<>();
5453

54+
/**
55+
*
56+
* @deprecated Use a {@link KmsMasterKeyProvider} to obtain {@link KmsMasterKey}s.
57+
*/
58+
@Deprecated
5559
public static KmsMasterKey getInstance(final AWSCredentials creds, final String keyId) {
5660
return new KmsMasterKeyProvider(creds, keyId).getMasterKey(keyId);
5761
}
5862

63+
/**
64+
*
65+
* @deprecated Use a {@link KmsMasterKeyProvider} to obtain {@link KmsMasterKey}s.
66+
*/
67+
@Deprecated
5968
public static KmsMasterKey getInstance(final AWSCredentialsProvider creds, final String keyId) {
6069
return new KmsMasterKeyProvider(creds, keyId).getMasterKey(keyId);
6170
}
@@ -65,12 +74,6 @@ static KmsMasterKey getInstance(final AWSKMS kms, final String id,
6574
return new KmsMasterKey(kms, id, provider);
6675
}
6776

68-
private KmsMasterKey(final AWSKMS kms, final String id) {
69-
kms_ = kms;
70-
id_ = id;
71-
sourceProvider_ = this;
72-
}
73-
7477
private KmsMasterKey(final AWSKMS kms, final String id, final MasterKeyProvider<KmsMasterKey> provider) {
7578
kms_ = kms;
7679
id_ = id;

0 commit comments

Comments
 (0)