use of com.amazonaws.services.identitymanagement.model.ListServerCertificatesResult 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;
}
}
}
use of com.amazonaws.services.identitymanagement.model.ListServerCertificatesResult in project Synapse-Stack-Builder by Sage-Bionetworks.
the class SSLSetupTest method testDescribeSSLCertificateCertNotFound.
@Test(expected = IllegalStateException.class)
public void testDescribeSSLCertificateCertNotFound() {
String certName = "someCertName";
ServerCertificateMetadata srvCertMeta = new ServerCertificateMetadata().withServerCertificateName(certName);
List<ServerCertificateMetadata> expectedLstSrvCertMetadata = new LinkedList<ServerCertificateMetadata>();
expectedLstSrvCertMetadata.add(srvCertMeta);
ListServerCertificatesResult expectedLstssr = new ListServerCertificatesResult().withServerCertificateMetadataList(expectedLstSrvCertMetadata);
when(mockAmznIamClient.listServerCertificates()).thenReturn(expectedLstssr);
SSLSetup sslSetup = new SSLSetup(factory, config, resources);
sslSetup.describeSSLCertificate(StackEnvironmentType.REPO);
}
use of com.amazonaws.services.identitymanagement.model.ListServerCertificatesResult in project Synapse-Stack-Builder by Sage-Bionetworks.
the class SSLSetupTest method testDescribeResourcesCertificateFound.
@Test
public void testDescribeResourcesCertificateFound() {
String expectedCertName = config.getSSLCertificateName(StackEnvironmentType.REPO);
String expectedCertArn = "expectedCertArn";
ServerCertificateMetadata srvCertMeta = new ServerCertificateMetadata().withServerCertificateName(expectedCertName).withArn(expectedCertArn);
List<ServerCertificateMetadata> expectedLstSrvCertMetadata = new LinkedList<ServerCertificateMetadata>();
expectedLstSrvCertMetadata.add(srvCertMeta);
ListServerCertificatesResult expectedLstssr = new ListServerCertificatesResult().withServerCertificateMetadataList(expectedLstSrvCertMetadata);
when(mockAmznIamClient.listServerCertificates()).thenReturn(expectedLstssr);
SSLSetup sslSetup = new SSLSetup(factory, config, resources);
sslSetup.describeSSLCertificate(StackEnvironmentType.REPO);
// assertEquals(expectedCertArn, config.getSSLCertificateARN("generic"));
assertEquals(srvCertMeta, resources.getSslCertificate(StackEnvironmentType.REPO));
assertEquals(expectedCertArn, resources.getSslCertificate(StackEnvironmentType.REPO).getArn());
}
use of com.amazonaws.services.identitymanagement.model.ListServerCertificatesResult in project Synapse-Stack-Builder by Sage-Bionetworks.
the class SSLSetupTest method testSetupSSLCertificateNoCertificate.
@Test
public void testSetupSSLCertificateNoCertificate() {
String expectedCertName = config.getSSLCertificateName(StackEnvironmentType.REPO);
String expectedCertArn = "expectedCertArn";
// Returned in 1st call to FindCertificate() --> empty
// ServerCertificateMetadata scmdList1 = new ServerCertificateMetadata().withServerCertificateName(expectedCertName);
List<ServerCertificateMetadata> expectedLstSrvCertMetadata1 = new LinkedList<ServerCertificateMetadata>();
// expectedLstSrvCertMetadata1.add(scmdList1);
// Returned in 2nd call to FindCertificate()
ServerCertificateMetadata scmdList2 = new ServerCertificateMetadata().withServerCertificateName(expectedCertName).withArn(expectedCertArn);
List<ServerCertificateMetadata> expectedLstSrvCertMetadata2 = new LinkedList<ServerCertificateMetadata>();
expectedLstSrvCertMetadata1.add(scmdList2);
// listServerCertificates() should return empty list, then uploaded cert
ListServerCertificatesResult expectedLstssr1 = new ListServerCertificatesResult().withServerCertificateMetadataList(expectedLstSrvCertMetadata1);
ListServerCertificatesResult expectedLstssr2 = new ListServerCertificatesResult().withServerCertificateMetadataList(expectedLstSrvCertMetadata2);
when(mockAmznIamClient.listServerCertificates()).thenReturn(expectedLstssr1, expectedLstssr2);
// Call to uploadServerCertificate()
ServerCertificateMetadata srvCertMeta = new ServerCertificateMetadata().withServerCertificateName(expectedCertName).withArn(expectedCertArn);
UploadServerCertificateRequest uscr = new UploadServerCertificateRequest().withServerCertificateName(expectedCertName);
UploadServerCertificateResult expectedUscr = new UploadServerCertificateResult().withServerCertificateMetadata(srvCertMeta);
when(mockAmznIamClient.uploadServerCertificate(uscr)).thenReturn(expectedUscr);
SSLSetup sslSetup = new SSLSetup(factory, config, resources);
sslSetup.setupSSLCertificate(StackEnvironmentType.REPO);
// Meta for upload server cert should be in resources
assertEquals(expectedCertName, resources.getSslCertificate(StackEnvironmentType.REPO).getServerCertificateName());
assertEquals(expectedCertArn, resources.getSslCertificate(StackEnvironmentType.REPO).getArn());
}
use of com.amazonaws.services.identitymanagement.model.ListServerCertificatesResult 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;
}
Aggregations