public class EncryptRequest extends AmazonWebServiceRequest implements Serializable
Encrypts plaintext into ciphertext by using a customer master key (CMK). The
Encrypt operation has two primary use cases:
You can encrypt up to 4 kilobytes (4096 bytes) of arbitrary data such as an RSA key, a database password, or other sensitive information.
To move encrypted data from one AWS region to another, you can use this operation to encrypt in the new region the plaintext data key that was used to encrypt the data in the original region. This provides you with an encrypted copy of the data key that can be decrypted in the new region and used there to decrypt the encrypted data.
To perform this operation on a CMK in a different AWS account, specify the key ARN or alias ARN in the value of the KeyId parameter.
Unless you are moving encrypted data from one region to another, you don't
use this operation to encrypt a generated data key within a region. To get
data keys that are already encrypted, call the GenerateDataKey or
GenerateDataKeyWithoutPlaintext operation. Data keys don't need to be
encrypted again by calling Encrypt.
To encrypt data locally in your application, use the GenerateDataKey operation to return a plaintext data encryption key and a copy of the key encrypted under the CMK of your choosing.
The result of this operation varies with the key state of the CMK. For details, see How Key State Affects Use of a Customer Master Key in the AWS Key Management Service Developer Guide.
| Constructor and Description |
|---|
EncryptRequest() |
| Modifier and Type | Method and Description |
|---|---|
EncryptRequest |
addEncryptionContextEntry(String key,
String value)
Name-value pair that specifies the encryption context to be used for
authenticated encryption.
|
EncryptRequest |
clearEncryptionContextEntries()
Removes all the entries added into EncryptionContext.
|
boolean |
equals(Object obj) |
Map<String,String> |
getEncryptionContext()
Name-value pair that specifies the encryption context to be used for
authenticated encryption.
|
List<String> |
getGrantTokens()
A list of grant tokens.
|
String |
getKeyId()
A unique identifier for the customer master key (CMK).
|
ByteBuffer |
getPlaintext()
Data to be encrypted.
|
int |
hashCode() |
void |
setEncryptionContext(Map<String,String> encryptionContext)
Name-value pair that specifies the encryption context to be used for
authenticated encryption.
|
void |
setGrantTokens(Collection<String> grantTokens)
A list of grant tokens.
|
void |
setKeyId(String keyId)
A unique identifier for the customer master key (CMK).
|
void |
setPlaintext(ByteBuffer plaintext)
Data to be encrypted.
|
String |
toString()
Returns a string representation of this object; useful for testing and
debugging.
|
EncryptRequest |
withEncryptionContext(Map<String,String> encryptionContext)
Name-value pair that specifies the encryption context to be used for
authenticated encryption.
|
EncryptRequest |
withGrantTokens(Collection<String> grantTokens)
A list of grant tokens.
|
EncryptRequest |
withGrantTokens(String... grantTokens)
A list of grant tokens.
|
EncryptRequest |
withKeyId(String keyId)
A unique identifier for the customer master key (CMK).
|
EncryptRequest |
withPlaintext(ByteBuffer plaintext)
Data to be encrypted.
|
clone, copyBaseTo, getCloneRoot, getCloneSource, getGeneralProgressListener, getRequestClientOptions, getRequestCredentials, getRequestMetricCollector, setGeneralProgressListener, setRequestCredentials, setRequestMetricCollector, withGeneralProgressListener, withRequestMetricCollectorpublic String getKeyId()
A unique identifier for the customer master key (CMK).
To specify a CMK, use its key ID, Amazon Resource Name (ARN), alias name, or alias ARN. When using an alias name, prefix it with "alias/". To specify a CMK in a different AWS account, you must use the key ARN or alias ARN.
For example:
Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
Alias name: alias/ExampleAlias
Alias ARN:
arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias
To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.
Constraints:
Length: 1 - 2048
A unique identifier for the customer master key (CMK).
To specify a CMK, use its key ID, Amazon Resource Name (ARN), alias name, or alias ARN. When using an alias name, prefix it with "alias/". To specify a CMK in a different AWS account, you must use the key ARN or alias ARN.
For example:
Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
Alias name: alias/ExampleAlias
Alias ARN:
arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias
To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.
public void setKeyId(String keyId)
A unique identifier for the customer master key (CMK).
To specify a CMK, use its key ID, Amazon Resource Name (ARN), alias name, or alias ARN. When using an alias name, prefix it with "alias/". To specify a CMK in a different AWS account, you must use the key ARN or alias ARN.
For example:
Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
Alias name: alias/ExampleAlias
Alias ARN:
arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias
To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.
Constraints:
Length: 1 - 2048
keyId - A unique identifier for the customer master key (CMK).
To specify a CMK, use its key ID, Amazon Resource Name (ARN), alias name, or alias ARN. When using an alias name, prefix it with "alias/". To specify a CMK in a different AWS account, you must use the key ARN or alias ARN.
For example:
Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
Alias name: alias/ExampleAlias
Alias ARN:
arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias
To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.
public EncryptRequest withKeyId(String keyId)
A unique identifier for the customer master key (CMK).
To specify a CMK, use its key ID, Amazon Resource Name (ARN), alias name, or alias ARN. When using an alias name, prefix it with "alias/". To specify a CMK in a different AWS account, you must use the key ARN or alias ARN.
For example:
Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
Alias name: alias/ExampleAlias
Alias ARN:
arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias
To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.
Returns a reference to this object so that method calls can be chained together.
Constraints:
Length: 1 - 2048
keyId - A unique identifier for the customer master key (CMK).
To specify a CMK, use its key ID, Amazon Resource Name (ARN), alias name, or alias ARN. When using an alias name, prefix it with "alias/". To specify a CMK in a different AWS account, you must use the key ARN or alias ARN.
For example:
Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
Alias name: alias/ExampleAlias
Alias ARN:
arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias
To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.
public ByteBuffer getPlaintext()
Data to be encrypted.
Constraints:
Length: 1 - 4096
Data to be encrypted.
public void setPlaintext(ByteBuffer plaintext)
Data to be encrypted.
Constraints:
Length: 1 - 4096
plaintext - Data to be encrypted.
public EncryptRequest withPlaintext(ByteBuffer plaintext)
Data to be encrypted.
Returns a reference to this object so that method calls can be chained together.
Constraints:
Length: 1 - 4096
plaintext - Data to be encrypted.
public Map<String,String> getEncryptionContext()
Name-value pair that specifies the encryption context to be used for
authenticated encryption. If used here, the same value must be supplied
to the Decrypt API or decryption will fail. For more
information, see Encryption Context.
Name-value pair that specifies the encryption context to be used
for authenticated encryption. If used here, the same value must
be supplied to the Decrypt API or decryption will
fail. For more information, see Encryption Context.
public void setEncryptionContext(Map<String,String> encryptionContext)
Name-value pair that specifies the encryption context to be used for
authenticated encryption. If used here, the same value must be supplied
to the Decrypt API or decryption will fail. For more
information, see Encryption Context.
encryptionContext -
Name-value pair that specifies the encryption context to be
used for authenticated encryption. If used here, the same
value must be supplied to the Decrypt API or
decryption will fail. For more information, see Encryption Context.
public EncryptRequest withEncryptionContext(Map<String,String> encryptionContext)
Name-value pair that specifies the encryption context to be used for
authenticated encryption. If used here, the same value must be supplied
to the Decrypt API or decryption will fail. For more
information, see Encryption Context.
Returns a reference to this object so that method calls can be chained together.
encryptionContext -
Name-value pair that specifies the encryption context to be
used for authenticated encryption. If used here, the same
value must be supplied to the Decrypt API or
decryption will fail. For more information, see Encryption Context.
public EncryptRequest addEncryptionContextEntry(String key, String value)
Name-value pair that specifies the encryption context to be used for
authenticated encryption. If used here, the same value must be supplied
to the Decrypt API or decryption will fail. For more
information, see Encryption Context.
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 EncryptRequest clearEncryptionContextEntries()
Returns a reference to this object so that method calls can be chained together.
public List<String> getGrantTokens()
A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
public void setGrantTokens(Collection<String> grantTokens)
A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
grantTokens - A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
public EncryptRequest withGrantTokens(String... grantTokens)
A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
Returns a reference to this object so that method calls can be chained together.
grantTokens - A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
public EncryptRequest withGrantTokens(Collection<String> grantTokens)
A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
Returns a reference to this object so that method calls can be chained together.
grantTokens - A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
public String toString()
toString in class ObjectObject.toString()Copyright © 2019. All rights reserved.