Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.
Creación de una lista de certificados
El siguiente ejemplo muestra cómo utilizar la función ListCertificates.
package com.amazonaws.samples; import com.amazonaws.services.certificatemanager.AWSCertificateManagerClientBuilder; import com.amazonaws.services.certificatemanager.AWSCertificateManager; import com.amazonaws.services.certificatemanager.model.ListCertificatesRequest; import com.amazonaws.services.certificatemanager.model.ListCertificatesResult; import com.amazonaws.auth.profile.ProfileCredentialsProvider; import com.amazonaws.auth.AWSStaticCredentialsProvider; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.regions.Regions; import com.amazonaws.AmazonClientException; import java.util.Arrays; import java.util.List; /** * This sample demonstrates how to use the ListCertificates function in the AWS Certificate * Manager service. * * Input parameters: * CertificateStatuses - An array of strings that contains the statuses to use for filtering. * MaxItems - The maximum number of certificates to return in the response. * NextToken - Use when paginating results. * * Output parameters: * CertificateSummaryList - A list of certificates. * NextToken - Use to show additional results when paginating a truncated list. * */ public class AWSCertificateManagerExample { 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().getCredentials(); } catch (Exception ex) { throw new AmazonClientException("Cannot load the credentials from file.", ex); } // Create a client. AWSCertificateManager client = AWSCertificateManagerClientBuilder.standard() .withRegion(Regions.
US_EAST_1
) .withCredentials(new AWSStaticCredentialsProvider(credentials)) .build(); // Create a request object and set the parameters. ListCertificatesRequest req = new ListCertificatesRequest(); List<String> Statuses = Arrays.asList("ISSUED", "EXPIRED", "PENDING_VALIDATION", "FAILED"); req.setCertificateStatuses(Statuses); req.setMaxItems(10); // Retrieve the list of certificates. ListCertificatesResult result = null; try { result = client.listCertificates(req); } catch (Exception ex) { throw ex; } // Display the certificate list. System.out.println(result); } }
La muestra de código anterior obtiene un resultado similar al siguiente.
{ CertificateSummaryList: [{ CertificateArn: arn:aws:acm:
region
:account
:certificate/12345678-1234-1234-1234-123456789012
, DomainName:www.example1.com
}, { CertificateArn: arn:aws:acm:region
:account
:certificate/12345678-1234-1234-1234-123456789012
, DomainName:www.example2.com
}, { CertificateArn: arn:aws:acm:region
:account
:certificate/12345678-1234-1234-1234-123456789012
, DomainName:www.example3.com
}] }