Search in sources :

Example 1 with CreateGrantRequest

use of software.amazon.awssdk.services.kms.model.CreateGrantRequest in project aws-doc-sdk-examples by awsdocs.

the class CreateGrant method createGrant.

// snippet-start:[kms.java2_create_grant.main]
public static String createGrant(KmsClient kmsClient, String keyId, String granteePrincipal, String operation) {
    try {
        CreateGrantRequest grantRequest = CreateGrantRequest.builder().keyId(keyId).granteePrincipal(granteePrincipal).operationsWithStrings(operation).build();
        CreateGrantResponse response = kmsClient.createGrant(grantRequest);
        return response.grantId();
    } catch (KmsException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
    return "";
}
Also used : CreateGrantResponse(software.amazon.awssdk.services.kms.model.CreateGrantResponse) CreateGrantRequest(software.amazon.awssdk.services.kms.model.CreateGrantRequest) KmsException(software.amazon.awssdk.services.kms.model.KmsException)

Aggregations

CreateGrantRequest (software.amazon.awssdk.services.kms.model.CreateGrantRequest)1 CreateGrantResponse (software.amazon.awssdk.services.kms.model.CreateGrantResponse)1 KmsException (software.amazon.awssdk.services.kms.model.KmsException)1