public class EncryptRequest extends AmazonWebServiceRequest implements java.io.Serializable
Encrypts plaintext into ciphertext by using a customer master key. The
Encrypt
function has two primary use cases:
You can encrypt up to 4 KB of arbitrary data such as an RSA key, a database password, or other sensitive customer information.
If you are moving encrypted data from one region to another, you can use this API 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.
Unless you are moving encrypted data from one region to another, you don't
use this function to encrypt a generated data key within a region. You
retrieve data keys already encrypted by calling the GenerateDataKey or
GenerateDataKeyWithoutPlaintext function. Data keys don't need to be
encrypted again by calling Encrypt
.
If you want to encrypt data locally in your application, you can use the
GenerateDataKey
function to return a plaintext data encryption
key and a copy of the key encrypted under the customer master key (CMK) of
your choosing.
Constructor and Description |
---|
EncryptRequest() |
Modifier and Type | Method and Description |
---|---|
EncryptRequest |
addEncryptionContextEntry(java.lang.String key,
java.lang.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(java.lang.Object obj) |
java.util.Map<java.lang.String,java.lang.String> |
getEncryptionContext()
Name-value pair that specifies the encryption context to be used for
authenticated encryption.
|
java.util.List<java.lang.String> |
getGrantTokens()
A list of grant tokens.
|
java.lang.String |
getKeyId()
A unique identifier for the customer master key.
|
java.nio.ByteBuffer |
getPlaintext()
Data to be encrypted.
|
int |
hashCode() |
void |
setEncryptionContext(java.util.Map<java.lang.String,java.lang.String> encryptionContext)
Name-value pair that specifies the encryption context to be used for
authenticated encryption.
|
void |
setGrantTokens(java.util.Collection<java.lang.String> grantTokens)
A list of grant tokens.
|
void |
setKeyId(java.lang.String keyId)
A unique identifier for the customer master key.
|
void |
setPlaintext(java.nio.ByteBuffer plaintext)
Data to be encrypted.
|
java.lang.String |
toString()
Returns a string representation of this object; useful for testing and
debugging.
|
EncryptRequest |
withEncryptionContext(java.util.Map<java.lang.String,java.lang.String> encryptionContext)
Name-value pair that specifies the encryption context to be used for
authenticated encryption.
|
EncryptRequest |
withGrantTokens(java.util.Collection<java.lang.String> grantTokens)
A list of grant tokens.
|
EncryptRequest |
withGrantTokens(java.lang.String... grantTokens)
A list of grant tokens.
|
EncryptRequest |
withKeyId(java.lang.String keyId)
A unique identifier for the customer master key.
|
EncryptRequest |
withPlaintext(java.nio.ByteBuffer plaintext)
Data to be encrypted.
|
clone, getCloneRoot, getCloneSource, getGeneralProgressListener, getRequestClientOptions, getRequestCredentials, getRequestMetricCollector, setGeneralProgressListener, setRequestCredentials, setRequestMetricCollector, withGeneralProgressListener, withRequestMetricCollector
public java.lang.String getKeyId()
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/".
Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234 -1234-123456789012
Alias ARN Example - arn:aws:kms:us-east-1:123456789012:alias/MyAliasName
Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
Alias Name Example - alias/MyAliasName
Constraints:
Length: 1 - 256
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/".
Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678- 1234-1234-1234-123456789012
Alias ARN Example - arn:aws:kms:us-east-1:123456789012:alias/MyAliasName
Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
Alias Name Example - alias/MyAliasName
public void setKeyId(java.lang.String 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/".
Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234 -1234-123456789012
Alias ARN Example - arn:aws:kms:us-east-1:123456789012:alias/MyAliasName
Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
Alias Name Example - alias/MyAliasName
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/".
Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678 -1234-1234-1234-123456789012
Alias ARN Example - arn:aws:kms:us-east-1:123456789012:alias/MyAliasName
Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
Alias Name Example - alias/MyAliasName
public EncryptRequest withKeyId(java.lang.String 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/".
Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234 -1234-123456789012
Alias ARN Example - arn:aws:kms:us-east-1:123456789012:alias/MyAliasName
Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
Alias Name Example - alias/MyAliasName
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/".
Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678 -1234-1234-1234-123456789012
Alias ARN Example - arn:aws:kms:us-east-1:123456789012:alias/MyAliasName
Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
Alias Name Example - alias/MyAliasName
public java.nio.ByteBuffer getPlaintext()
Data to be encrypted.
Constraints:
Length: 1 - 4096
Data to be encrypted.
public void setPlaintext(java.nio.ByteBuffer plaintext)
Data to be encrypted.
Constraints:
Length: 1 - 4096
plaintext
- Data to be encrypted.
public EncryptRequest withPlaintext(java.nio.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 java.util.Map<java.lang.String,java.lang.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(java.util.Map<java.lang.String,java.lang.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(java.util.Map<java.lang.String,java.lang.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(java.lang.String key, java.lang.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 java.util.List<java.lang.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(java.util.Collection<java.lang.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(java.lang.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(java.util.Collection<java.lang.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 java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.