Class AwsKmsMrkAwareMasterKeyProvider
- java.lang.Object
-
- com.amazonaws.encryptionsdk.MasterKeyProvider<AwsKmsMrkAwareMasterKey>
-
- com.amazonaws.encryptionsdk.kmssdkv2.AwsKmsMrkAwareMasterKeyProvider
-
public final class AwsKmsMrkAwareMasterKeyProvider extends MasterKeyProvider<AwsKmsMrkAwareMasterKey>
Represents a list Aws KMS keys and is used to encrypt/decrypt data withAwsCrypto. Some of these keys may be multi region keys, in which case this component is able to recognize different regional replicas of this multi region key as the same.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAwsKmsMrkAwareMasterKeyProvider.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AwsKmsMrkAwareMasterKeyProvider.Builderbuilder()DataKey<AwsKmsMrkAwareMasterKey>decryptDataKey(CryptoAlgorithm algorithm, Collection<? extends EncryptedDataKey> encryptedDataKeys, Map<String,String> encryptionContext)Iterates throughencryptedDataKeysand returns the first one which can be successfully decrypted.StringgetDefaultProviderId()Returns "aws-kms"List<String>getGrantTokens()AwsKmsMrkAwareMasterKeygetMasterKey(String providerId, String requestedKeyArn)Added flexibility in matching multi-Region keys from different regions.List<AwsKmsMrkAwareMasterKey>getMasterKeysForEncryption(MasterKeyRequest request)Returns all CMKs provided to the constructor of this object.AwsKmsMrkAwareMasterKeyProviderwithGrantTokens(String... grantTokens)Returns a newAwsKmsMrkAwareMasterKeyProviderthat is configured identically to this one, except with the given list of grant tokens.AwsKmsMrkAwareMasterKeyProviderwithGrantTokens(List<String> grantTokens)Returns a newAwsKmsMrkAwareMasterKeyProviderthat 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 Detail
-
builder
public static AwsKmsMrkAwareMasterKeyProvider.Builder builder()
-
getDefaultProviderId
public String getDefaultProviderId()
Returns "aws-kms"- Specified by:
getDefaultProviderIdin classMasterKeyProvider<AwsKmsMrkAwareMasterKey>
-
getMasterKey
public AwsKmsMrkAwareMasterKey getMasterKey(String providerId, String requestedKeyArn) throws UnsupportedProviderException, NoSuchMasterKeyException
Added flexibility in matching multi-Region keys from different regions.- Specified by:
getMasterKeyin classMasterKeyProvider<AwsKmsMrkAwareMasterKey>- Returns:
- Throws:
UnsupportedProviderException- if this object cannot returnMasterKeys associated with the given providerNoSuchMasterKeyException- if this object cannot find (and thus construct) theMasterKeyassociated withkeyId- See Also:
MasterKey.getMasterKey(String, String)
-
getMasterKeysForEncryption
public List<AwsKmsMrkAwareMasterKey> getMasterKeysForEncryption(MasterKeyRequest request)
Returns all CMKs provided to the constructor of this object.- Specified by:
getMasterKeysForEncryptionin classMasterKeyProvider<AwsKmsMrkAwareMasterKey>- See Also:
MasterKey.getMasterKeysForEncryption(MasterKeyRequest)
-
decryptDataKey
public DataKey<AwsKmsMrkAwareMasterKey> decryptDataKey(CryptoAlgorithm algorithm, Collection<? extends EncryptedDataKey> encryptedDataKeys, Map<String,String> encryptionContext) throws AwsCryptoException
Description copied from class:MasterKeyProviderIterates throughencryptedDataKeysand returns the first one which can be successfully decrypted.- Specified by:
decryptDataKeyin classMasterKeyProvider<AwsKmsMrkAwareMasterKey>- Returns:
- a DataKey if one can be decrypted, otherwise returns
null - Throws:
AwsCryptoExceptionUnsupportedProviderException- if theencryptedDataKeyis associated with an unsupported providerCannotUnwrapDataKeyException- if theencryptedDataKeycannot be decrypted- See Also:
KmsMasterKey.decryptDataKey(CryptoAlgorithm, Collection, Map)
-
withGrantTokens
public AwsKmsMrkAwareMasterKeyProvider withGrantTokens(List<String> grantTokens)
Returns a newAwsKmsMrkAwareMasterKeyProviderthat 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).
-
withGrantTokens
public AwsKmsMrkAwareMasterKeyProvider withGrantTokens(String... grantTokens)
Returns a newAwsKmsMrkAwareMasterKeyProviderthat 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).
-
-