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

Attaches a policy to the specified key.

 
 public class PutKeyPolicyRequest extends AmazonWebServiceRequest implements SerializableCloneable {

    
A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key.
  • Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
  • Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012

Constraints:
Length: 1 - 256

 
     private String keyId;

    
Name of the policy to be attached. Currently, the only supported name is "default".

Constraints:
Length: 1 - 128
Pattern: [\w]+

 
     private String policyName;

    
The policy, in JSON format, to be attached to the key.

Constraints:
Length: 1 - 131072
Pattern: [\u0009\u000A\u000D\u0020-\u00FF]+

 
     private String policy;

    
A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key.
  • Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
  • Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012

Constraints:
Length: 1 - 256

Returns:
A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key.
  • Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
  • Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
 
     public String getKeyId() {
         return ;
     }
    
    
A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key.
  • Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
  • Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012

Constraints:
Length: 1 - 256

Parameters:
keyId A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key.
  • Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
  • Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
    public void setKeyId(String keyId) {
        this. = keyId;
    }
    
    
A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key.
  • Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
  • Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012

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

Constraints:
Length: 1 - 256

Parameters:
keyId A unique identifier for the customer master key. This value can be a globally unique identifier or the fully specified ARN to a key.
  • Key ARN Example - arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
  • Globally Unique Key ID Example - 12345678-1234-1234-1234-123456789012
Returns:
A reference to this updated object so that method calls can be chained together.
    public PutKeyPolicyRequest withKeyId(String keyId) {
        this. = keyId;
        return this;
    }

    
Name of the policy to be attached. Currently, the only supported name is "default".

Constraints:
Length: 1 - 128
Pattern: [\w]+

Returns:
Name of the policy to be attached. Currently, the only supported name is "default".
    public String getPolicyName() {
        return ;
    }
    
    
Name of the policy to be attached. Currently, the only supported name is "default".

Constraints:
Length: 1 - 128
Pattern: [\w]+

Parameters:
policyName Name of the policy to be attached. Currently, the only supported name is "default".
    public void setPolicyName(String policyName) {
        this. = policyName;
    }
    
    
Name of the policy to be attached. Currently, the only supported name is "default".

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

Constraints:
Length: 1 - 128
Pattern: [\w]+

Parameters:
policyName Name of the policy to be attached. Currently, the only supported name is "default".
Returns:
A reference to this updated object so that method calls can be chained together.
    public PutKeyPolicyRequest withPolicyName(String policyName) {
        this. = policyName;
        return this;
    }

    
The policy, in JSON format, to be attached to the key.

Constraints:
Length: 1 - 131072
Pattern: [\u0009\u000A\u000D\u0020-\u00FF]+

Returns:
The policy, in JSON format, to be attached to the key.
    public String getPolicy() {
        return ;
    }
    
    
The policy, in JSON format, to be attached to the key.

Constraints:
Length: 1 - 131072
Pattern: [\u0009\u000A\u000D\u0020-\u00FF]+

Parameters:
policy The policy, in JSON format, to be attached to the key.
    public void setPolicy(String policy) {
        this. = policy;
    }
    
    
The policy, in JSON format, to be attached to the key.

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

Constraints:
Length: 1 - 131072
Pattern: [\u0009\u000A\u000D\u0020-\u00FF]+

Parameters:
policy The policy, in JSON format, to be attached to the key.
Returns:
A reference to this updated object so that method calls can be chained together.
    public PutKeyPolicyRequest withPolicy(String policy) {
        this. = policy;
        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 (getKeyId() != nullsb.append("KeyId: " + getKeyId() + ",");
        if (getPolicyName() != nullsb.append("PolicyName: " + getPolicyName() + ",");
        if (getPolicy() != nullsb.append("Policy: " + getPolicy() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getKeyId() == null) ? 0 : getKeyId().hashCode()); 
        hashCode = prime * hashCode + ((getPolicyName() == null) ? 0 : getPolicyName().hashCode()); 
        hashCode = prime * hashCode + ((getPolicy() == null) ? 0 : getPolicy().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof PutKeyPolicyRequest == falsereturn false;
        PutKeyPolicyRequest other = (PutKeyPolicyRequest)obj;
        
        if (other.getKeyId() == null ^ this.getKeyId() == nullreturn false;
        if (other.getKeyId() != null && other.getKeyId().equals(this.getKeyId()) == falsereturn false
        if (other.getPolicyName() == null ^ this.getPolicyName() == nullreturn false;
        if (other.getPolicyName() != null && other.getPolicyName().equals(this.getPolicyName()) == falsereturn false
        if (other.getPolicy() == null ^ this.getPolicy() == nullreturn false;
        if (other.getPolicy() != null && other.getPolicy().equals(this.getPolicy()) == falsereturn false
        return true;
    }
    
    @Override
    public PutKeyPolicyRequest clone() {
        
            return (PutKeyPolicyRequestsuper.clone();
    }
}
    
New to GrepCode? Check out our FAQ X