Package com.amazonaws.encryptionsdk
Class MasterKeyProvider<K extends MasterKey<K>>
- java.lang.Object
-
- com.amazonaws.encryptionsdk.MasterKeyProvider<K>
-
- Type Parameters:
K
- the type ofMasterKey
returned by this provider
- Direct Known Subclasses:
KeyStoreProvider
,KmsMasterKeyProvider
,MasterKey
public abstract class MasterKeyProvider<K extends MasterKey<K>> extends Object
Represents the logic necessary to select and constructMasterKey
s for encrypting and decrypting messages. This is an abstract class.
-
-
Constructor Summary
Constructors Constructor Description MasterKeyProvider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected AwsCryptoException
buildCannotDecryptDksException()
protected AwsCryptoException
buildCannotDecryptDksException(Throwable t)
protected AwsCryptoException
buildCannotDecryptDksException(List<? extends Throwable> t)
boolean
canProvide(String provider)
Returns true if this MasterKeyProvider can provide keys from the specified @{code provider}.abstract DataKey<K>
decryptDataKey(CryptoAlgorithm algorithm, Collection<? extends EncryptedDataKey> encryptedDataKeys, Map<String,String> encryptionContext)
Iterates throughencryptedDataKeys
and returns the first one which can be successfully decrypted.abstract String
getDefaultProviderId()
ProviderId used by this instance when no other is specified.K
getMasterKey(String keyId)
Equivalent to callinggetMasterKey(String, String)
usinggetDefaultProviderId()
as the provider.abstract K
getMasterKey(String provider, String keyId)
Returns the specifiedMasterKey
if possible.abstract List<K>
getMasterKeysForEncryption(MasterKeyRequest request)
Returns allMasterKey
s which should be used to protect the plaintext described byrequest
.
-
-
-
Method Detail
-
getDefaultProviderId
public abstract String getDefaultProviderId()
ProviderId used by this instance when no other is specified.
-
canProvide
public boolean canProvide(String provider)
Returns true if this MasterKeyProvider can provide keys from the specified @{code provider}.- Parameters:
provider
-- Returns:
-
getMasterKey
public K getMasterKey(String keyId) throws UnsupportedProviderException, NoSuchMasterKeyException
Equivalent to callinggetMasterKey(String, String)
usinggetDefaultProviderId()
as the provider.
-
getMasterKey
public abstract K getMasterKey(String provider, String keyId) throws UnsupportedProviderException, NoSuchMasterKeyException
Returns the specifiedMasterKey
if possible.- Parameters:
provider
-keyId
-- Returns:
- Throws:
UnsupportedProviderException
- if this object cannot returnMasterKey
s associated with the given providerNoSuchMasterKeyException
- if this object cannot find (and thus construct) theMasterKey
associated withkeyId
-
getMasterKeysForEncryption
public abstract List<K> getMasterKeysForEncryption(MasterKeyRequest request)
Returns allMasterKey
s which should be used to protect the plaintext described byrequest
.
-
decryptDataKey
public abstract DataKey<K> decryptDataKey(CryptoAlgorithm algorithm, Collection<? extends EncryptedDataKey> encryptedDataKeys, Map<String,String> encryptionContext) throws UnsupportedProviderException, AwsCryptoException
Iterates throughencryptedDataKeys
and returns the first one which can be successfully decrypted.- Returns:
- a DataKey if one can be decrypted, otherwise returns
null
- Throws:
UnsupportedProviderException
- if theencryptedDataKey
is associated with an unsupported providerCannotUnwrapDataKeyException
- if theencryptedDataKey
cannot be decryptedAwsCryptoException
-
buildCannotDecryptDksException
protected AwsCryptoException buildCannotDecryptDksException()
-
buildCannotDecryptDksException
protected AwsCryptoException buildCannotDecryptDksException(Throwable t)
-
buildCannotDecryptDksException
protected AwsCryptoException buildCannotDecryptDksException(List<? extends Throwable> t)
-
-