ListPermissions - AWS Certificate Manager Private Certificate Authority


The following Java sample shows how to use the ListPermissions operation.

This operation lists the permissions, if any, that your private CA has assigned. Permissions, including IssueCertificate, GetCertificate, and ListPermissions, can be assigned to an AWS service principal with the CreatePermission operation, and revoked with the DeletePermissions operation.

package com.amazonaws.samples; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.profile.ProfileCredentialsProvider; import com.amazonaws.client.builder.AwsClientBuilder; import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration; import com.amazonaws.auth.AWSStaticCredentialsProvider; import; import; import; import; import com.amazonaws.AmazonClientException; import; import; import; import; import; public class ListPermissions { public static void main(String[] args) throws Exception { // Retrieve your credentials from the C:\Users\name\.aws\credentials file // in Windows or the .aws/credentials file in Linux. AWSCredentials credentials = null; try { credentials = new ProfileCredentialsProvider("default").getCredentials(); } catch (Exception e) { throw new AmazonClientException("Cannot load your credentials from disk", e); } // Define the endpoint for your sample. String endpointRegion = "region"; // Substitute your region here, e.g. "us-west-2" String endpointProtocol = "https://acm-pca." + endpointRegion + ""; EndpointConfiguration endpoint = new AwsClientBuilder.EndpointConfiguration(endpointProtocol, endpointRegion); // Create a client that you can use to make requests. AWSACMPCA client = AWSACMPCAClientBuilder.standard() .withEndpointConfiguration(endpoint) .withCredentials(new AWSStaticCredentialsProvider(credentials)) .build(); // Create a request object and set the CA ARN. ListPermissionsRequest req = new ListPermissionsRequest(); req.withCertificateAuthorityArn("arn:aws:acm-pca:region:account:certificate-authority/CA_ID"); // List the tags. ListPermissionsResult result = null; try { result = client.listPermissions(req); } catch (InvalidArnException ex) { throw ex; } catch (InvalidStateException ex) { throw ex; } catch(RequestFailedException ex) { throw ex; } catch (ResourceNotFoundException ex) { throw ex; } // Retrieve and display the permissions. System.out.println(result); } }

If the designated private CA has assigned permissions to a service principal, your output should be similar to the following:

[{ Arn: arn:aws:acm-pca:region:account:permission/12345678-1234-1234-1234-123456789012, CreatedAt: WedFeb0317: 05: 39PST2019, Prinicpal:, Permissions: { ISSUE_CERTIFICATE, GET_CERTIFICATE, DELETE,CERTIFICATE }, SourceAccount: account }]