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

Adds a grant to a key to specify who can access the key and under what conditions. Grants are alternate permission mechanisms to key policies. If absent, access to the key is evaluated based on IAM policies attached to the user. By default, grants do not expire. Grants can be listed, retired, or revoked as indicated by the following APIs. Typically, when you are finished using a grant, you retire it. When you want to end a grant immediately, revoke it. For more information about grants, see Grants .

  1. ListGrants
  2. RetireGrant
  3. RevokeGrant

 
 public class CreateGrantRequest extends AmazonWebServiceRequest implements SerializableCloneable {

    
A unique key identifier for a customer master key. This value can be a globally unique identifier, an ARN, or an alias.

Constraints:
Length: 1 - 256

 
     private String keyId;

    
Principal given permission by the grant to use the key identified by the keyId parameter.

Constraints:
Length: 1 - 256

 
     private String granteePrincipal;

    
Principal given permission to retire the grant. For more information, see RetireGrant.

Constraints:
Length: 1 - 256

 
     private String retiringPrincipal;

    
List of operations permitted by the grant. This can be any combination of one or more of the following values:
  1. Decrypt
  2. Encrypt
  3. GenerateDataKey
  4. GenerateDataKeyWithoutPlaintext
  5. ReEncryptFrom
  6. ReEncryptTo
  7. CreateGrant
 
Specifies the conditions under which the actions specified by the Operations parameter are allowed.
 
     private GrantConstraints constraints;

    
List of grant tokens.

Constraints:
Length: 0 - 10

 
A unique key identifier for a customer master key. This value can be a globally unique identifier, an ARN, or an alias.

Constraints:
Length: 1 - 256

Returns:
A unique key identifier for a customer master key. This value can be a globally unique identifier, an ARN, or an alias.
    public String getKeyId() {
        return ;
    }
    
    
A unique key identifier for a customer master key. This value can be a globally unique identifier, an ARN, or an alias.

Constraints:
Length: 1 - 256

Parameters:
keyId A unique key identifier for a customer master key. This value can be a globally unique identifier, an ARN, or an alias.
    public void setKeyId(String keyId) {
        this. = keyId;
    }
    
    
A unique key identifier for a customer master key. This value can be a globally unique identifier, an ARN, or an alias.

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

Constraints:
Length: 1 - 256

Parameters:
keyId A unique key identifier for a customer master key. This value can be a globally unique identifier, an ARN, or an alias.
Returns:
A reference to this updated object so that method calls can be chained together.
    public CreateGrantRequest withKeyId(String keyId) {
        this. = keyId;
        return this;
    }

    
Principal given permission by the grant to use the key identified by the keyId parameter.

Constraints:
Length: 1 - 256

Returns:
Principal given permission by the grant to use the key identified by the keyId parameter.
    public String getGranteePrincipal() {
        return ;
    }
    
    
Principal given permission by the grant to use the key identified by the keyId parameter.

Constraints:
Length: 1 - 256

Parameters:
granteePrincipal Principal given permission by the grant to use the key identified by the keyId parameter.
    public void setGranteePrincipal(String granteePrincipal) {
        this. = granteePrincipal;
    }
    
    
Principal given permission by the grant to use the key identified by the keyId parameter.

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

Constraints:
Length: 1 - 256

Parameters:
granteePrincipal Principal given permission by the grant to use the key identified by the keyId parameter.
Returns:
A reference to this updated object so that method calls can be chained together.
    public CreateGrantRequest withGranteePrincipal(String granteePrincipal) {
        this. = granteePrincipal;
        return this;
    }

    
Principal given permission to retire the grant. For more information, see RetireGrant.

Constraints:
Length: 1 - 256

Returns:
Principal given permission to retire the grant. For more information, see RetireGrant.
    public String getRetiringPrincipal() {
        return ;
    }
    
    
Principal given permission to retire the grant. For more information, see RetireGrant.

Constraints:
Length: 1 - 256

Parameters:
retiringPrincipal Principal given permission to retire the grant. For more information, see RetireGrant.
    public void setRetiringPrincipal(String retiringPrincipal) {
        this. = retiringPrincipal;
    }
    
    
Principal given permission to retire the grant. For more information, see RetireGrant.

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

Constraints:
Length: 1 - 256

Parameters:
retiringPrincipal Principal given permission to retire the grant. For more information, see RetireGrant.
Returns:
A reference to this updated object so that method calls can be chained together.
    public CreateGrantRequest withRetiringPrincipal(String retiringPrincipal) {
        this. = retiringPrincipal;
        return this;
    }

    
List of operations permitted by the grant. This can be any combination of one or more of the following values:
  1. Decrypt
  2. Encrypt
  3. GenerateDataKey
  4. GenerateDataKeyWithoutPlaintext
  5. ReEncryptFrom
  6. ReEncryptTo
  7. CreateGrant

Returns:
List of operations permitted by the grant. This can be any combination of one or more of the following values:
  1. Decrypt
  2. Encrypt
  3. GenerateDataKey
  4. GenerateDataKeyWithoutPlaintext
  5. ReEncryptFrom
  6. ReEncryptTo
  7. CreateGrant
    public java.util.List<StringgetOperations() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<String>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
List of operations permitted by the grant. This can be any combination of one or more of the following values:
  1. Decrypt
  2. Encrypt
  3. GenerateDataKey
  4. GenerateDataKeyWithoutPlaintext
  5. ReEncryptFrom
  6. ReEncryptTo
  7. CreateGrant

Parameters:
operations List of operations permitted by the grant. This can be any combination of one or more of the following values:
  1. Decrypt
  2. Encrypt
  3. GenerateDataKey
  4. GenerateDataKeyWithoutPlaintext
  5. ReEncryptFrom
  6. ReEncryptTo
  7. CreateGrant
    public void setOperations(java.util.Collection<Stringoperations) {
        if (operations == null) {
            this. = null;
            return;
        }
        operationsCopy.addAll(operations);
        this. = operationsCopy;
    }
    
    
List of operations permitted by the grant. This can be any combination of one or more of the following values:
  1. Decrypt
  2. Encrypt
  3. GenerateDataKey
  4. GenerateDataKeyWithoutPlaintext
  5. ReEncryptFrom
  6. ReEncryptTo
  7. CreateGrant

NOTE: This method appends the values to the existing list (if any). Use setOperations(java.util.Collection) or withOperations(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.

Parameters:
operations List of operations permitted by the grant. This can be any combination of one or more of the following values:
  1. Decrypt
  2. Encrypt
  3. GenerateDataKey
  4. GenerateDataKeyWithoutPlaintext
  5. ReEncryptFrom
  6. ReEncryptTo
  7. CreateGrant
Returns:
A reference to this updated object so that method calls can be chained together.
    public CreateGrantRequest withOperations(String... operations) {
        if (getOperations() == nullsetOperations(new java.util.ArrayList<String>(operations.length));
        for (String value : operations) {
            getOperations().add(value);
        }
        return this;
    }
    
    
List of operations permitted by the grant. This can be any combination of one or more of the following values:
  1. Decrypt
  2. Encrypt
  3. GenerateDataKey
  4. GenerateDataKeyWithoutPlaintext
  5. ReEncryptFrom
  6. ReEncryptTo
  7. CreateGrant

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

Parameters:
operations List of operations permitted by the grant. This can be any combination of one or more of the following values:
  1. Decrypt
  2. Encrypt
  3. GenerateDataKey
  4. GenerateDataKeyWithoutPlaintext
  5. ReEncryptFrom
  6. ReEncryptTo
  7. CreateGrant
Returns:
A reference to this updated object so that method calls can be chained together.
        if (operations == null) {
            this. = null;
        } else {
            com.amazonaws.internal.ListWithAutoConstructFlag<StringoperationsCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<String>(operations.size());
            operationsCopy.addAll(operations);
            this. = operationsCopy;
        }
        return this;
    }

    
List of operations permitted by the grant. This can be any combination of one or more of the following values:
  1. Decrypt
  2. Encrypt
  3. GenerateDataKey
  4. GenerateDataKeyWithoutPlaintext
  5. ReEncryptFrom
  6. ReEncryptTo
  7. CreateGrant

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

Parameters:
operations List of operations permitted by the grant. This can be any combination of one or more of the following values:
  1. Decrypt
  2. Encrypt
  3. GenerateDataKey
  4. GenerateDataKeyWithoutPlaintext
  5. ReEncryptFrom
  6. ReEncryptTo
  7. CreateGrant
Returns:
A reference to this updated object so that method calls can be chained together.
    public CreateGrantRequest withOperations(GrantOperation... operations) {
        java.util.ArrayList<StringoperationsCopy = new java.util.ArrayList<String>(operations.length);
        for (GrantOperation member : operations) {
            operationsCopy.add(member.toString());
        }
        if (getOperations() == null) {
            setOperations(operationsCopy);
        } else {
            getOperations().addAll(operationsCopy);
        }
        return this;
    }

    
Specifies the conditions under which the actions specified by the Operations parameter are allowed.

Returns:
Specifies the conditions under which the actions specified by the Operations parameter are allowed.
    public GrantConstraints getConstraints() {
        return ;
    }
    
    
Specifies the conditions under which the actions specified by the Operations parameter are allowed.

Parameters:
constraints Specifies the conditions under which the actions specified by the Operations parameter are allowed.
    public void setConstraints(GrantConstraints constraints) {
        this. = constraints;
    }
    
    
Specifies the conditions under which the actions specified by the Operations parameter are allowed.

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

Parameters:
constraints Specifies the conditions under which the actions specified by the Operations parameter are allowed.
Returns:
A reference to this updated object so that method calls can be chained together.
    public CreateGrantRequest withConstraints(GrantConstraints constraints) {
        this. = constraints;
        return this;
    }

    
List of grant tokens.

Constraints:
Length: 0 - 10

Returns:
List of grant tokens.
    public java.util.List<StringgetGrantTokens() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<String>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
List of grant tokens.

Constraints:
Length: 0 - 10

Parameters:
grantTokens List of grant tokens.
    public void setGrantTokens(java.util.Collection<StringgrantTokens) {
        if (grantTokens == null) {
            this. = null;
            return;
        }
        grantTokensCopy.addAll(grantTokens);
        this. = grantTokensCopy;
    }
    
    
List of 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 List of grant tokens.
Returns:
A reference to this updated object so that method calls can be chained together.
    public CreateGrantRequest withGrantTokens(String... grantTokens) {
        if (getGrantTokens() == nullsetGrantTokens(new java.util.ArrayList<String>(grantTokens.length));
        for (String value : grantTokens) {
            getGrantTokens().add(value);
        }
        return this;
    }
    
    
List of grant tokens.

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

Constraints:
Length: 0 - 10

Parameters:
grantTokens List of grant tokens.
Returns:
A reference to this updated object so that method calls can be chained together.
    public CreateGrantRequest 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 (getKeyId() != nullsb.append("KeyId: " + getKeyId() + ",");
        if (getGranteePrincipal() != nullsb.append("GranteePrincipal: " + getGranteePrincipal() + ",");
        if (getRetiringPrincipal() != nullsb.append("RetiringPrincipal: " + getRetiringPrincipal() + ",");
        if (getOperations() != nullsb.append("Operations: " + getOperations() + ",");
        if (getConstraints() != nullsb.append("Constraints: " + getConstraints() + ",");
        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 + ((getKeyId() == null) ? 0 : getKeyId().hashCode()); 
        hashCode = prime * hashCode + ((getGranteePrincipal() == null) ? 0 : getGranteePrincipal().hashCode()); 
        hashCode = prime * hashCode + ((getRetiringPrincipal() == null) ? 0 : getRetiringPrincipal().hashCode()); 
        hashCode = prime * hashCode + ((getOperations() == null) ? 0 : getOperations().hashCode()); 
        hashCode = prime * hashCode + ((getConstraints() == null) ? 0 : getConstraints().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 CreateGrantRequest == falsereturn false;
        CreateGrantRequest other = (CreateGrantRequest)obj;
        
        if (other.getKeyId() == null ^ this.getKeyId() == nullreturn false;
        if (other.getKeyId() != null && other.getKeyId().equals(this.getKeyId()) == falsereturn false
        if (other.getGranteePrincipal() == null ^ this.getGranteePrincipal() == nullreturn false;
        if (other.getGranteePrincipal() != null && other.getGranteePrincipal().equals(this.getGranteePrincipal()) == falsereturn false
        if (other.getRetiringPrincipal() == null ^ this.getRetiringPrincipal() == nullreturn false;
        if (other.getRetiringPrincipal() != null && other.getRetiringPrincipal().equals(this.getRetiringPrincipal()) == falsereturn false
        if (other.getOperations() == null ^ this.getOperations() == nullreturn false;
        if (other.getOperations() != null && other.getOperations().equals(this.getOperations()) == falsereturn false
        if (other.getConstraints() == null ^ this.getConstraints() == nullreturn false;
        if (other.getConstraints() != null && other.getConstraints().equals(this.getConstraints()) == 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 CreateGrantRequest clone() {
        
            return (CreateGrantRequestsuper.clone();
    }
}
    
New to GrepCode? Check out our FAQ X