Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   * 
   *  http://aws.amazon.com/apache2.0
   * 
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.kms.model;
 
 
Container for the parameters to the ReEncrypt operation.

Encrypts data on the server side with a new customer master key without exposing the plaintext of the data on the client side. The data is first decrypted and then encrypted. This operation can also be used to change the encryption context of a ciphertext.

Unlike other actions, ReEncrypt is authorized twice - once as ReEncryptFrom on the source key and once as ReEncryptTo on the destination key. We therefore recommend that you include the "action":"kms:ReEncrypt*" statement in your key policies to permit re-encryption from or to the key. The statement is included automatically when you authorize use of the key through the console but must be included manually when you set a policy by using the PutKeyPolicy function.

 
 public class ReEncryptRequest extends AmazonWebServiceRequest implements SerializableCloneable {

    
Ciphertext of the data to re-encrypt.

Constraints:
Length: 1 - 6144

 
     private java.nio.ByteBuffer ciphertextBlob;

    
Encryption context used to encrypt and decrypt the data specified in the CiphertextBlob parameter.
 
     private java.util.Map<String,StringsourceEncryptionContext;

    
A unique identifier for the customer master key used to re-encrypt the data. 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

 
     private String destinationKeyId;

    
Encryption context to be used when the data is re-encrypted.
 
For more information, see Grant Tokens.

Constraints:
Length: 0 - 10

 
Ciphertext of the data to re-encrypt.

Constraints:
Length: 1 - 6144

Returns:
Ciphertext of the data to re-encrypt.
 
     public java.nio.ByteBuffer getCiphertextBlob() {
         return ;
     }
    
    
Ciphertext of the data to re-encrypt.

Constraints:
Length: 1 - 6144

Parameters:
ciphertextBlob Ciphertext of the data to re-encrypt.
    public void setCiphertextBlob(java.nio.ByteBuffer ciphertextBlob) {
        this. = ciphertextBlob;
    }
    
    
Ciphertext of the data to re-encrypt.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 1 - 6144

Parameters:
ciphertextBlob Ciphertext of the data to re-encrypt.
Returns:
A reference to this updated object so that method calls can be chained together.
    public ReEncryptRequest withCiphertextBlob(java.nio.ByteBuffer ciphertextBlob) {
        this. = ciphertextBlob;
        return this;
    }

    
Encryption context used to encrypt and decrypt the data specified in the CiphertextBlob parameter.

Returns:
Encryption context used to encrypt and decrypt the data specified in the CiphertextBlob parameter.
        
        if ( == null) {
             = new java.util.HashMap<String,String>();
        }
        return ;
    }
    
    
Encryption context used to encrypt and decrypt the data specified in the CiphertextBlob parameter.

Parameters:
sourceEncryptionContext Encryption context used to encrypt and decrypt the data specified in the CiphertextBlob parameter.
    public void setSourceEncryptionContext(java.util.Map<String,StringsourceEncryptionContext) {
        this. = sourceEncryptionContext;
    }
    
    
Encryption context used to encrypt and decrypt the data specified in the CiphertextBlob parameter.

Returns a reference to this object so that method calls can be chained together.

Parameters:
sourceEncryptionContext Encryption context used to encrypt and decrypt the data specified in the CiphertextBlob parameter.
Returns:
A reference to this updated object so that method calls can be chained together.
    public ReEncryptRequest withSourceEncryptionContext(java.util.Map<String,StringsourceEncryptionContext) {
        setSourceEncryptionContext(sourceEncryptionContext);
        return this;
    }

    
Encryption context used to encrypt and decrypt the data specified in the CiphertextBlob parameter.

The method adds a new key-value pair into SourceEncryptionContext parameter, and returns a reference to this object so that method calls can be chained together.

Parameters:
key The key of the entry to be added into SourceEncryptionContext.
value The corresponding value of the entry to be added into SourceEncryptionContext.
    if (null == this.) {
    }
    if (this..containsKey(key))
      throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
    this..put(keyvalue);
    return this;
  }

  
Removes all the entries added into SourceEncryptionContext.

Returns a reference to this object so that method calls can be chained together.

    this. = null;
    return this;
  }
  
    
A unique identifier for the customer master key used to re-encrypt the data. 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

Returns:
A unique identifier for the customer master key used to re-encrypt the data. 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 String getDestinationKeyId() {
        return ;
    }
    
    
A unique identifier for the customer master key used to re-encrypt the data. 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

Parameters:
destinationKeyId A unique identifier for the customer master key used to re-encrypt the data. 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 setDestinationKeyId(String destinationKeyId) {
        this. = destinationKeyId;
    }
    
    
A unique identifier for the customer master key used to re-encrypt the data. 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

Parameters:
destinationKeyId A unique identifier for the customer master key used to re-encrypt the data. 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 updated object so that method calls can be chained together.
    public ReEncryptRequest withDestinationKeyId(String destinationKeyId) {
        this. = destinationKeyId;
        return this;
    }

    
Encryption context to be used when the data is re-encrypted.

Returns:
Encryption context to be used when the data is re-encrypted.
        
        if ( == null) {
             = new java.util.HashMap<String,String>();
        }
        return ;
    }
    
    
Encryption context to be used when the data is re-encrypted.

Parameters:
destinationEncryptionContext Encryption context to be used when the data is re-encrypted.
    public void setDestinationEncryptionContext(java.util.Map<String,StringdestinationEncryptionContext) {
        this. = destinationEncryptionContext;
    }
    
    
Encryption context to be used when the data is re-encrypted.

Returns a reference to this object so that method calls can be chained together.

Parameters:
destinationEncryptionContext Encryption context to be used when the data is re-encrypted.
Returns:
A reference to this updated object so that method calls can be chained together.
    public ReEncryptRequest withDestinationEncryptionContext(java.util.Map<String,StringdestinationEncryptionContext) {
        setDestinationEncryptionContext(destinationEncryptionContext);
        return this;
    }

    
Encryption context to be used when the data is re-encrypted.

The method adds a new key-value pair into DestinationEncryptionContext parameter, and returns a reference to this object so that method calls can be chained together.

Parameters:
key The key of the entry to be added into DestinationEncryptionContext.
value The corresponding value of the entry to be added into DestinationEncryptionContext.
    if (null == this.) {
    }
      throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
    this..put(keyvalue);
    return this;
  }

  
Removes all the entries added into DestinationEncryptionContext.

Returns a reference to this object so that method calls can be chained together.

    this. = null;
    return this;
  }
  
    
For more information, see Grant Tokens.

Constraints:
Length: 0 - 10

Returns:
For more information, see Grant Tokens.
    public java.util.List<StringgetGrantTokens() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<String>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
For more information, see Grant Tokens.

Constraints:
Length: 0 - 10

Parameters:
grantTokens For more information, see Grant Tokens.
    public void setGrantTokens(java.util.Collection<StringgrantTokens) {
        if (grantTokens == null) {
            this. = null;
            return;
        }
        grantTokensCopy.addAll(grantTokens);
        this. = grantTokensCopy;
    }
    
    
For more information, see Grant Tokens.

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

Parameters:
grantTokens For more information, see Grant Tokens.
Returns:
A reference to this updated object so that method calls can be chained together.
    public ReEncryptRequest withGrantTokens(String... grantTokens) {
        if (getGrantTokens() == nullsetGrantTokens(new java.util.ArrayList<String>(grantTokens.length));
        for (String value : grantTokens) {
            getGrantTokens().add(value);
        }
        return this;
    }
    
    
For more information, see Grant Tokens.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 0 - 10

Parameters:
grantTokens For more information, see Grant Tokens.
Returns:
A reference to this updated object so that method calls can be chained together.
    public ReEncryptRequest withGrantTokens(java.util.Collection<StringgrantTokens) {
        if (grantTokens == null) {
            this. = null;
        } else {
            com.amazonaws.internal.ListWithAutoConstructFlag<StringgrantTokensCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<String>(grantTokens.size());
            grantTokensCopy.addAll(grantTokens);
            this. = grantTokensCopy;
        }
        return this;
    }

    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getCiphertextBlob() != nullsb.append("CiphertextBlob: " + getCiphertextBlob() + ",");
        if (getSourceEncryptionContext() != nullsb.append("SourceEncryptionContext: " + getSourceEncryptionContext() + ",");
        if (getDestinationKeyId() != nullsb.append("DestinationKeyId: " + getDestinationKeyId() + ",");
        if (getDestinationEncryptionContext() != nullsb.append("DestinationEncryptionContext: " + getDestinationEncryptionContext() + ",");
        if (getGrantTokens() != nullsb.append("GrantTokens: " + getGrantTokens() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getCiphertextBlob() == null) ? 0 : getCiphertextBlob().hashCode()); 
        hashCode = prime * hashCode + ((getSourceEncryptionContext() == null) ? 0 : getSourceEncryptionContext().hashCode()); 
        hashCode = prime * hashCode + ((getDestinationKeyId() == null) ? 0 : getDestinationKeyId().hashCode()); 
        hashCode = prime * hashCode + ((getDestinationEncryptionContext() == null) ? 0 : getDestinationEncryptionContext().hashCode()); 
        hashCode = prime * hashCode + ((getGrantTokens() == null) ? 0 : getGrantTokens().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof ReEncryptRequest == falsereturn false;
        ReEncryptRequest other = (ReEncryptRequest)obj;
        
        if (other.getCiphertextBlob() == null ^ this.getCiphertextBlob() == nullreturn false;
        if (other.getCiphertextBlob() != null && other.getCiphertextBlob().equals(this.getCiphertextBlob()) == falsereturn false
        if (other.getSourceEncryptionContext() == null ^ this.getSourceEncryptionContext() == nullreturn false;
        if (other.getSourceEncryptionContext() != null && other.getSourceEncryptionContext().equals(this.getSourceEncryptionContext()) == falsereturn false
        if (other.getDestinationKeyId() == null ^ this.getDestinationKeyId() == nullreturn false;
        if (other.getDestinationKeyId() != null && other.getDestinationKeyId().equals(this.getDestinationKeyId()) == falsereturn false
        if (other.getDestinationEncryptionContext() == null ^ this.getDestinationEncryptionContext() == nullreturn false;
        if (other.getDestinationEncryptionContext() != null && other.getDestinationEncryptionContext().equals(this.getDestinationEncryptionContext()) == falsereturn false
        if (other.getGrantTokens() == null ^ this.getGrantTokens() == nullreturn false;
        if (other.getGrantTokens() != null && other.getGrantTokens().equals(this.getGrantTokens()) == falsereturn false
        return true;
    }
    
    @Override
    public ReEncryptRequest clone() {
        
            return (ReEncryptRequestsuper.clone();
    }
}
    
New to GrepCode? Check out our FAQ X