Search in sources :

Example 1 with ListServerCertificatesRequest

use of com.amazonaws.services.identitymanagement.model.ListServerCertificatesRequest in project aws-doc-sdk-examples by awsdocs.

the class ListServerCertificates method main.

public static void main(String[] args) {
    final AmazonIdentityManagement iam = AmazonIdentityManagementClientBuilder.defaultClient();
    boolean done = false;
    while (!done) {
        ListServerCertificatesRequest request = new ListServerCertificatesRequest();
        ListServerCertificatesResult response = iam.listServerCertificates(request);
        for (ServerCertificateMetadata metadata : response.getServerCertificateMetadataList()) {
            System.out.printf("Retrieved server certificate %s", metadata.getServerCertificateName());
        }
        request.setMarker(response.getMarker());
        if (!response.getIsTruncated()) {
            done = true;
        }
    }
}
Also used : ServerCertificateMetadata(com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata) ListServerCertificatesRequest(com.amazonaws.services.identitymanagement.model.ListServerCertificatesRequest) AmazonIdentityManagement(com.amazonaws.services.identitymanagement.AmazonIdentityManagement) ListServerCertificatesResult(com.amazonaws.services.identitymanagement.model.ListServerCertificatesResult)

Example 2 with ListServerCertificatesRequest

use of com.amazonaws.services.identitymanagement.model.ListServerCertificatesRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class SSLSetup method findCertificate.

/**
 * Determine if the certificate already exists
 * @param certName
 * @return
 */
public ServerCertificateMetadata findCertificate(String certName) {
    log.debug("Searching for Certificate: " + certName);
    // First we need to get all certificates
    List<ServerCertificateMetadata> allCerts = new LinkedList<ServerCertificateMetadata>();
    ListServerCertificatesResult results = iamClient.listServerCertificates();
    allCerts.addAll(results.getServerCertificateMetadataList());
    while (results.getMarker() != null) {
        results = iamClient.listServerCertificates(new ListServerCertificatesRequest().withMarker(results.getMarker()));
        allCerts.addAll(results.getServerCertificateMetadataList());
    }
    // Check if our cert is in the list.
    for (ServerCertificateMetadata meta : allCerts) {
        if (meta.getServerCertificateName().equals(certName)) {
            log.debug("Certificate found: " + certName);
            return meta;
        }
    }
    // Did not find the cert.
    return null;
}
Also used : ServerCertificateMetadata(com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata) ListServerCertificatesRequest(com.amazonaws.services.identitymanagement.model.ListServerCertificatesRequest) LinkedList(java.util.LinkedList) ListServerCertificatesResult(com.amazonaws.services.identitymanagement.model.ListServerCertificatesResult)

Aggregations

ListServerCertificatesRequest (com.amazonaws.services.identitymanagement.model.ListServerCertificatesRequest)2 ListServerCertificatesResult (com.amazonaws.services.identitymanagement.model.ListServerCertificatesResult)2 ServerCertificateMetadata (com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata)2 AmazonIdentityManagement (com.amazonaws.services.identitymanagement.AmazonIdentityManagement)1 LinkedList (java.util.LinkedList)1