Search in sources :

Example 6 with ServerCertificateMetadata

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

the class SSLSetup method deleteSSLCertificate.

/*
	 * Delete the SSL certificate
	 */
public void deleteSSLCertificate(StackEnvironmentType env) {
    ServerCertificateMetadata meta = findCertificate(config.getSSLCertificateName(env));
    if (meta == null) {
        // Just log
        // TODO: Or throw IllegalStateException?
        log.debug("Could not find SSL certificate metadata for" + config.getSSLCertificateName(env));
    } else {
        DeleteServerCertificateRequest request = new DeleteServerCertificateRequest();
        request.setServerCertificateName(config.getSSLCertificateName(env));
        iamClient.deleteServerCertificate(request);
        meta = findCertificate(config.getSSLCertificateName(env));
    }
    if (meta != null) {
        throw new IllegalStateException("Failed to delete the SSL certificate: " + config.getSSLCertificateName(env));
    }
}
Also used : ServerCertificateMetadata(com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata) DeleteServerCertificateRequest(com.amazonaws.services.identitymanagement.model.DeleteServerCertificateRequest)

Example 7 with ServerCertificateMetadata

use of com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata 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)

Example 8 with ServerCertificateMetadata

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

the class SSLSetup method setupSSLCertificate.

/**
 * Setup the SSL certificate.
 */
public void setupSSLCertificate(StackEnvironmentType env) {
    // First determine if the certificate already exists already exists
    ServerCertificateMetadata meta = findCertificate(config.getSSLCertificateName(env));
    if (meta == null) {
        // Upload the parts of the certificate.
        UploadServerCertificateRequest request = new UploadServerCertificateRequest();
        request.setServerCertificateName(config.getSSLCertificateName(env));
        request.setPrivateKey(getCertificateStringFromS3(config.getSSlCertificatePrivateKeyName(env)));
        request.setCertificateBody(getCertificateStringFromS3(config.getSSLCertificateBodyKeyName(env)));
        request.setCertificateChain(getCertificateStringFromS3(config.getSSLCertificateChainKeyName(env)));
        UploadServerCertificateResult result = iamClient.uploadServerCertificate(request);
        log.debug("Created SSL certificate: " + result);
        // Search for it
        meta = findCertificate(config.getSSLCertificateName(env));
    }
    if (meta == null)
        throw new IllegalStateException("Failed to find or create the SSL certificate: " + config.getSSLCertificateName(env));
    // Also set the SSL Cert arn as a property
    // config.setSSLCertificateARN(prefix, meta.getArn());
    resources.setSslCertificate(env, meta);
}
Also used : ServerCertificateMetadata(com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata) UploadServerCertificateResult(com.amazonaws.services.identitymanagement.model.UploadServerCertificateResult) UploadServerCertificateRequest(com.amazonaws.services.identitymanagement.model.UploadServerCertificateRequest)

Example 9 with ServerCertificateMetadata

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

the class SSLSetup method describeSSLCertificate.

public void describeSSLCertificate(StackEnvironmentType env) {
    String certName = config.getSSLCertificateName(env);
    ServerCertificateMetadata meta = findCertificate(certName);
    if (meta == null) {
        throw new IllegalStateException("Failed to find or create the SSL certificate: " + config.getSSLCertificateName(env));
    } else {
        // config.setSSLCertificateARN(prefix, meta.getArn());
        resources.setSslCertificate(env, meta);
    }
}
Also used : ServerCertificateMetadata(com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata)

Aggregations

ServerCertificateMetadata (com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata)9 ListServerCertificatesResult (com.amazonaws.services.identitymanagement.model.ListServerCertificatesResult)5 LinkedList (java.util.LinkedList)5 Test (org.junit.Test)3 ListServerCertificatesRequest (com.amazonaws.services.identitymanagement.model.ListServerCertificatesRequest)2 UploadServerCertificateRequest (com.amazonaws.services.identitymanagement.model.UploadServerCertificateRequest)2 UploadServerCertificateResult (com.amazonaws.services.identitymanagement.model.UploadServerCertificateResult)2 DomainStatus (com.amazonaws.services.cloudsearchv2.model.DomainStatus)1 ServiceEndpoint (com.amazonaws.services.cloudsearchv2.model.ServiceEndpoint)1 KeyPairInfo (com.amazonaws.services.ec2.model.KeyPairInfo)1 ApplicationVersionDescription (com.amazonaws.services.elasticbeanstalk.model.ApplicationVersionDescription)1 AmazonIdentityManagement (com.amazonaws.services.identitymanagement.AmazonIdentityManagement)1 DeleteServerCertificateRequest (com.amazonaws.services.identitymanagement.model.DeleteServerCertificateRequest)1 DBInstance (com.amazonaws.services.rds.model.DBInstance)1 Endpoint (com.amazonaws.services.rds.model.Endpoint)1