本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
以下 Java 示例显示了如何使用该ListPermissions操作。
此操作列出您的私有 CA 已分配的权限(如果有)。权限(包括IssueCertificate
GetCertificate
ListPermissions
、和)可以通过操作分配给 AWS 服务主体,也可以通过CreatePermission操作将其撤销。DeletePermissions
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 com.amazonaws.services.acmpca.AWSACMPCA;
import com.amazonaws.services.acmpca.AWSACMPCAClientBuilder;
import com.amazonaws.services.acmpca.model.ListPermissionsRequest;
import com.amazonaws.services.acmpca.model.ListPermissionsResult;
import com.amazonaws.AmazonClientException;
import com.amazonaws.services.acmpca.model.InvalidArnException;
import com.amazonaws.services.acmpca.model.InvalidNextTokenException;
import com.amazonaws.services.acmpca.model.InvalidStateException;
import com.amazonaws.services.acmpca.model.ResourceNotFoundException;
import com.amazonaws.services.acmpca.model.RequestFailedException;
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 + ".amazonaws.com/";
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:us-east-1
:111122223333
:certificate-authority/11223344-1234-1122-2233-112233445566
");
// 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);
}
}
如果指定的私有 CA 已向服务委托人分配权限,则输出应类似于以下内容:
[{
Arn: arn:aws:acm-pca:region
:account
:permission/12345678-1234-1234-1234-123456789012
,
CreatedAt: WedFeb0317: 05: 39PST2019,
Prinicpal: acm.amazonaws.com,
Permissions: {
ISSUE_CERTIFICATE,
GET_CERTIFICATE,
DELETE,CERTIFICATE
},
SourceAccount: account
}]