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 Decrypt operation.

Decrypts ciphertext. Ciphertext is plaintext that has been previously encrypted by using any of the following functions:

  • GenerateDataKey
  • GenerateDataKeyWithoutPlaintext
  • Encrypt

Note that if a caller has been granted access permissions to all keys (through, for example, IAM user policies that grant Decrypt permission on all resources), then ciphertext encrypted by using keys in other accounts where the key grants access to the caller can be decrypted. To remedy this, we recommend that you do not grant Decrypt access in an IAM user policy. Instead grant Decrypt access only in key policies. If you must grant Decrypt access in an IAM user policy, you should scope the resource to specific keys or to specific trusted accounts.

 
 public class DecryptRequest extends AmazonWebServiceRequest implements SerializableCloneable {

    
Ciphertext to be decrypted. The blob includes metadata.

Constraints:
Length: 1 - 6144

 
     private java.nio.ByteBuffer ciphertextBlob;

    
The encryption context. If this was specified in the Encrypt function, it must be specified here or the decryption operation will fail. For more information, see Encryption Context.
 
     private java.util.Map<String,StringencryptionContext;

    
For more information, see Grant Tokens.

Constraints:
Length: 0 - 10

 
Ciphertext to be decrypted. The blob includes metadata.

Constraints:
Length: 1 - 6144

Returns:
Ciphertext to be decrypted. The blob includes metadata.
 
     public java.nio.ByteBuffer getCiphertextBlob() {
         return ;
     }
    
    
Ciphertext to be decrypted. The blob includes metadata.

Constraints:
Length: 1 - 6144

Parameters:
ciphertextBlob Ciphertext to be decrypted. The blob includes metadata.
 
     public void setCiphertextBlob(java.nio.ByteBuffer ciphertextBlob) {
         this. = ciphertextBlob;
    }
    
    
Ciphertext to be decrypted. The blob includes metadata.

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

Constraints:
Length: 1 - 6144

Parameters:
ciphertextBlob Ciphertext to be decrypted. The blob includes metadata.
Returns:
A reference to this updated object so that method calls can be chained together.
    public DecryptRequest withCiphertextBlob(java.nio.ByteBuffer ciphertextBlob) {
        this. = ciphertextBlob;
        return this;
    }

    
The encryption context. If this was specified in the Encrypt function, it must be specified here or the decryption operation will fail. For more information, see Encryption Context.

Returns:
The encryption context. If this was specified in the Encrypt function, it must be specified here or the decryption operation will fail. For more information, see Encryption Context.
        
        if ( == null) {
             = new java.util.HashMap<String,String>();
        }
        return ;
    }
    
    
The encryption context. If this was specified in the Encrypt function, it must be specified here or the decryption operation will fail. For more information, see Encryption Context.

Parameters:
encryptionContext The encryption context. If this was specified in the Encrypt function, it must be specified here or the decryption operation will fail. For more information, see Encryption Context.
    public void setEncryptionContext(java.util.Map<String,StringencryptionContext) {
        this. = encryptionContext;
    }
    
    
The encryption context. If this was specified in the Encrypt function, it must be specified here or the decryption operation will fail. For more information, see Encryption Context.

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

Parameters:
encryptionContext The encryption context. If this was specified in the Encrypt function, it must be specified here or the decryption operation will fail. For more information, see Encryption Context.
Returns:
A reference to this updated object so that method calls can be chained together.
    public DecryptRequest withEncryptionContext(java.util.Map<String,StringencryptionContext) {
        setEncryptionContext(encryptionContext);
        return this;
    }

    
The encryption context. If this was specified in the Encrypt function, it must be specified here or the decryption operation 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.

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

  
Removes all the entries added into EncryptionContext.

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 DecryptRequest 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 DecryptRequest 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 (getEncryptionContext() != nullsb.append("EncryptionContext: " + getEncryptionContext() + ",");
        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 + ((getEncryptionContext() == null) ? 0 : getEncryptionContext().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 DecryptRequest == falsereturn false;
        DecryptRequest other = (DecryptRequest)obj;
        
        if (other.getCiphertextBlob() == null ^ this.getCiphertextBlob() == nullreturn false;
        if (other.getCiphertextBlob() != null && other.getCiphertextBlob().equals(this.getCiphertextBlob()) == falsereturn false
        if (other.getEncryptionContext() == null ^ this.getEncryptionContext() == nullreturn false;
        if (other.getEncryptionContext() != null && other.getEncryptionContext().equals(this.getEncryptionContext()) == 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 DecryptRequest clone() {
        
            return (DecryptRequestsuper.clone();
    }
}
    
New to GrepCode? Check out our FAQ X