Package com.amazonaws.encryptionsdk.kms
Class KmsMasterKeyProvider
java.lang.Object
com.amazonaws.encryptionsdk.MasterKeyProvider<KmsMasterKey>
com.amazonaws.encryptionsdk.kms.KmsMasterKeyProvider
- All Implemented Interfaces:
KmsMethods
Provides
MasterKeys backed by the AWS Key Management Service. This object is regional and
if you want to use keys from multiple regions, you'll need multiple copies of this object.
This component is not multi-Region key aware, and will treat every AWS KMS identifier as regionally isolated.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGrantToken(String grantToken)Deprecated.This method is inherently not thread safe.static KmsMasterKeyProvider.Builderbuilder()decryptDataKey(CryptoAlgorithm algorithm, Collection<? extends EncryptedDataKey> encryptedDataKeys, Map<String,String> encryptionContext)Iterates throughencryptedDataKeysand returns the first one which can be successfully decrypted.Returns "aws-kms"Returns the grantTokens which this object sends to KMS when calling it.getMasterKey(String provider, String keyId)Returns the specifiedMasterKeyif possible.getMasterKeysForEncryption(MasterKeyRequest request)Returns all CMKs provided to the constructor of this object.voidsetGrantTokens(List<String> grantTokens)Deprecated.This method is inherently not thread safe.withGrantTokens(String... grantTokens)Returns a newKmsMasterKeyProviderthat is configured identically to this one, except with the given list of grant tokens.withGrantTokens(List<String> grantTokens)Returns a newKmsMasterKeyProviderthat is configured identically to this one, except with the given list of grant tokens.Methods inherited from class com.amazonaws.encryptionsdk.MasterKeyProvider
buildCannotDecryptDksException, buildCannotDecryptDksException, buildCannotDecryptDksException, canProvide, getMasterKey
-
Method Details
-
builder
-
getDefaultProviderId
Returns "aws-kms"- Specified by:
getDefaultProviderIdin classMasterKeyProvider<KmsMasterKey>
-
getMasterKey
public KmsMasterKey getMasterKey(String provider, String keyId) throws UnsupportedProviderException, NoSuchMasterKeyExceptionDescription copied from class:MasterKeyProviderReturns the specifiedMasterKeyif possible.- Specified by:
getMasterKeyin classMasterKeyProvider<KmsMasterKey>- Returns:
- Throws:
UnsupportedProviderException- if this object cannot returnMasterKeys associated with the given providerNoSuchMasterKeyException- if this object cannot find (and thus construct) theMasterKeyassociated withkeyId
-
getMasterKeysForEncryption
Returns all CMKs provided to the constructor of this object.- Specified by:
getMasterKeysForEncryptionin classMasterKeyProvider<KmsMasterKey>
-
decryptDataKey
public DataKey<KmsMasterKey> decryptDataKey(CryptoAlgorithm algorithm, Collection<? extends EncryptedDataKey> encryptedDataKeys, Map<String,String> encryptionContext) throws AwsCryptoExceptionDescription copied from class:MasterKeyProviderIterates throughencryptedDataKeysand returns the first one which can be successfully decrypted.- Specified by:
decryptDataKeyin classMasterKeyProvider<KmsMasterKey>- Returns:
- a DataKey if one can be decrypted, otherwise returns
null - Throws:
UnsupportedProviderException- if theencryptedDataKeyis associated with an unsupported providerCannotUnwrapDataKeyException- if theencryptedDataKeycannot be decryptedAwsCryptoException
-
setGrantTokens
Deprecated.This method is inherently not thread safe. UseKmsMasterKey.setGrantTokens(List)instead.KmsMasterKeyProviders constructed using the builder will throw an exception on attempts to modify the list of grant tokens.Description copied from interface:KmsMethodsSets thegrantTokenswhich should be submitted to KMS when calling it.- Specified by:
setGrantTokensin interfaceKmsMethods
-
getGrantTokens
Description copied from interface:KmsMethodsReturns the grantTokens which this object sends to KMS when calling it.- Specified by:
getGrantTokensin interfaceKmsMethods
-
addGrantToken
Deprecated.This method is inherently not thread safe. UsewithGrantTokens(List)orKmsMasterKey.setGrantTokens(List)instead.KmsMasterKeyProviders constructed using the builder will throw an exception on attempts to modify the list of grant tokens.Description copied from interface:KmsMethodsAddsgrantTokento the list of grantTokens sent to KMS when this class calls it.- Specified by:
addGrantTokenin interfaceKmsMethods
-
withGrantTokens
Returns a newKmsMasterKeyProviderthat is configured identically to this one, except with the given list of grant tokens. The grant token list in the returned provider is immutable (but can be further overridden by invoking withGrantTokens again).- Parameters:
grantTokens-- Returns:
-
withGrantTokens
Returns a newKmsMasterKeyProviderthat is configured identically to this one, except with the given list of grant tokens. The grant token list in the returned provider is immutable (but can be further overridden by invoking withGrantTokens again).- Parameters:
grantTokens-- Returns:
-