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));
}
}
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;
}
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);
}
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);
}
}
Aggregations