public class GenerateDataKeyRequest extends AmazonWebServiceRequest implements Serializable, Cloneable
GenerateDataKey operation.
Generates a data key that you can use in your application to locally
encrypt data. This call returns a plaintext version of the key in the
Plaintext field of the response object and an encrypted
copy of the key in the CiphertextBlob field. The key is
encrypted by using the master key specified by the KeyId
field. To decrypt the encrypted key, pass it to the
Decrypt API.
We recommend that you use the following pattern to locally encrypt
data: call the GenerateDataKey API, use the key returned
in the Plaintext response field to locally encrypt data,
and then erase the plaintext data key from memory. Store the encrypted
data key (contained in the CiphertextBlob field)
alongside of the locally encrypted data.
NOTE:You should not call the Encrypt function to re-encrypt your data keys within a region. GenerateDataKey always returns the data key encrypted and tied to the customer master key that will be used to decrypt it. There is no need to decrypt it twice.
If you decide to use the optional EncryptionContext
parameter, you must also store the context in full or at least store
enough information along with the encrypted data to be able to
reconstruct the context when submitting the ciphertext to the
Decrypt API. It is a good practice to choose a context
that you can reconstruct on the fly to better secure the ciphertext.
For more information about how this parameter is used, see
Encryption Context
.
To decrypt data, pass the encrypted data key to the
Decrypt API. Decrypt uses the associated
master key to decrypt the encrypted data key and returns it as
plaintext. Use the plaintext data key to locally decrypt your data and
then erase the key from memory. You must specify the encryption
context, if any, that you specified when you generated the key. The
encryption context is logged by CloudTrail, and you can use this log
to help track the use of particular data.
NOOP| Constructor and Description |
|---|
GenerateDataKeyRequest() |
| Modifier and Type | Method and Description |
|---|---|
GenerateDataKeyRequest |
addEncryptionContextEntry(String key,
String value)
Name/value pair that contains additional data to be authenticated
during the encryption and decryption processes that use the key.
|
GenerateDataKeyRequest |
clearEncryptionContextEntries()
Removes all the entries added into EncryptionContext.
|
GenerateDataKeyRequest |
clone()
Creates a shallow clone of this request.
|
boolean |
equals(Object obj) |
Map<String,String> |
getEncryptionContext()
Name/value pair that contains additional data to be authenticated
during the encryption and decryption processes that use the key.
|
List<String> |
getGrantTokens()
For more information, see Grant
Tokens.
|
String |
getKeyId()
A unique identifier for the customer master key.
|
String |
getKeySpec()
Value that identifies the encryption algorithm and key size to
generate a data key for.
|
Integer |
getNumberOfBytes()
Integer that contains the number of bytes to generate.
|
int |
hashCode() |
void |
setEncryptionContext(Map<String,String> encryptionContext)
Name/value pair that contains additional data to be authenticated
during the encryption and decryption processes that use the key.
|
void |
setGrantTokens(Collection<String> grantTokens)
For more information, see Grant
Tokens.
|
void |
setKeyId(String keyId)
A unique identifier for the customer master key.
|
void |
setKeySpec(DataKeySpec keySpec)
Value that identifies the encryption algorithm and key size to
generate a data key for.
|
void |
setKeySpec(String keySpec)
Value that identifies the encryption algorithm and key size to
generate a data key for.
|
void |
setNumberOfBytes(Integer numberOfBytes)
Integer that contains the number of bytes to generate.
|
String |
toString()
Returns a string representation of this object; useful for testing and
debugging.
|
GenerateDataKeyRequest |
withEncryptionContext(Map<String,String> encryptionContext)
Name/value pair that contains additional data to be authenticated
during the encryption and decryption processes that use the key.
|
GenerateDataKeyRequest |
withGrantTokens(Collection<String> grantTokens)
For more information, see Grant
Tokens.
|
GenerateDataKeyRequest |
withGrantTokens(String... grantTokens)
For more information, see Grant
Tokens.
|
GenerateDataKeyRequest |
withKeyId(String keyId)
A unique identifier for the customer master key.
|
GenerateDataKeyRequest |
withKeySpec(DataKeySpec keySpec)
Value that identifies the encryption algorithm and key size to
generate a data key for.
|
GenerateDataKeyRequest |
withKeySpec(String keySpec)
Value that identifies the encryption algorithm and key size to
generate a data key for.
|
GenerateDataKeyRequest |
withNumberOfBytes(Integer numberOfBytes)
Integer that contains the number of bytes to generate.
|
copyBaseTo, getCustomRequestHeaders, getGeneralProgressListener, getReadLimit, getRequestClientOptions, getRequestCredentials, getRequestMetricCollector, putCustomRequestHeader, setGeneralProgressListener, setRequestCredentials, setRequestMetricCollector, withGeneralProgressListener, withRequestMetricCollectorpublic String getKeyId()
Constraints:
Length: 1 - 256
public void setKeyId(String keyId)
Constraints:
Length: 1 - 256
keyId - A unique identifier for the customer master key. This value can be a
globally unique identifier, a fully specified ARN to either an alias
or a key, or an alias name prefixed by "alias/". public GenerateDataKeyRequest withKeyId(String keyId)
Returns a reference to this object so that method calls can be chained together.
Constraints:
Length: 1 - 256
keyId - A unique identifier for the customer master key. This value can be a
globally unique identifier, a fully specified ARN to either an alias
or a key, or an alias name prefixed by "alias/". public Map<String,String> getEncryptionContext()
public void setEncryptionContext(Map<String,String> encryptionContext)
encryptionContext - Name/value pair that contains additional data to be authenticated
during the encryption and decryption processes that use the key. This
value is logged by AWS CloudTrail to provide context around the data
encrypted by the key.public GenerateDataKeyRequest withEncryptionContext(Map<String,String> encryptionContext)
Returns a reference to this object so that method calls can be chained together.
encryptionContext - Name/value pair that contains additional data to be authenticated
during the encryption and decryption processes that use the key. This
value is logged by AWS CloudTrail to provide context around the data
encrypted by the key.public GenerateDataKeyRequest addEncryptionContextEntry(String key, String value)
The method adds a new key-value pair into EncryptionContext parameter, and returns a reference to this object so that method calls can be chained together.
key - The key of the entry to be added into EncryptionContext.value - The corresponding value of the entry to be added into EncryptionContext.public GenerateDataKeyRequest clearEncryptionContextEntries()
Returns a reference to this object so that method calls can be chained together.
public Integer getNumberOfBytes()
KeySpec parameter instead.
Constraints:
Range: 1 - 1024
KeySpec parameter instead.public void setNumberOfBytes(Integer numberOfBytes)
KeySpec parameter instead.
Constraints:
Range: 1 - 1024
numberOfBytes - Integer that contains the number of bytes to generate. Common values
are 128, 256, 512, and 1024. 1024 is the current limit. We recommend
that you use the KeySpec parameter instead.public GenerateDataKeyRequest withNumberOfBytes(Integer numberOfBytes)
KeySpec parameter instead.
Returns a reference to this object so that method calls can be chained together.
Constraints:
Range: 1 - 1024
numberOfBytes - Integer that contains the number of bytes to generate. Common values
are 128, 256, 512, and 1024. 1024 is the current limit. We recommend
that you use the KeySpec parameter instead.public String getKeySpec()
Constraints:
Allowed Values: AES_256, AES_128
DataKeySpecpublic void setKeySpec(String keySpec)
Constraints:
Allowed Values: AES_256, AES_128
keySpec - Value that identifies the encryption algorithm and key size to
generate a data key for. Currently this can be AES_128 or AES_256.DataKeySpecpublic GenerateDataKeyRequest withKeySpec(String keySpec)
Returns a reference to this object so that method calls can be chained together.
Constraints:
Allowed Values: AES_256, AES_128
keySpec - Value that identifies the encryption algorithm and key size to
generate a data key for. Currently this can be AES_128 or AES_256.DataKeySpecpublic void setKeySpec(DataKeySpec keySpec)
Constraints:
Allowed Values: AES_256, AES_128
keySpec - Value that identifies the encryption algorithm and key size to
generate a data key for. Currently this can be AES_128 or AES_256.DataKeySpecpublic GenerateDataKeyRequest withKeySpec(DataKeySpec keySpec)
Returns a reference to this object so that method calls can be chained together.
Constraints:
Allowed Values: AES_256, AES_128
keySpec - Value that identifies the encryption algorithm and key size to
generate a data key for. Currently this can be AES_128 or AES_256.DataKeySpecpublic List<String> getGrantTokens()
Constraints:
Length: 0 - 10
public void setGrantTokens(Collection<String> grantTokens)
Constraints:
Length: 0 - 10
grantTokens - For more information, see Grant
Tokens.public GenerateDataKeyRequest withGrantTokens(String... grantTokens)
NOTE: This method appends the values to the existing list (if
any). Use setGrantTokens(java.util.Collection) or withGrantTokens(java.util.Collection) if you want to override the
existing values.
Returns a reference to this object so that method calls can be chained together.
Constraints:
Length: 0 - 10
grantTokens - For more information, see Grant
Tokens.public GenerateDataKeyRequest withGrantTokens(Collection<String> grantTokens)
Returns a reference to this object so that method calls can be chained together.
Constraints:
Length: 0 - 10
grantTokens - For more information, see Grant
Tokens.public String toString()
toString in class ObjectObject.toString()public GenerateDataKeyRequest clone()
AmazonWebServiceRequestclone in class AmazonWebServiceRequestObject.clone()Copyright © 2015. All rights reserved.