use of com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata 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.ServerCertificateMetadata 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.ServerCertificateMetadata 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.ServerCertificateMetadata 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.ServerCertificateMetadata in project Synapse-Stack-Builder by Sage-Bionetworks.
the class TestHelper method createTestResources.
/**
* Create GeneratedResources that can be used for a test.
*
* @param config
* @return
*/
public static GeneratedResources createTestResources(InputConfiguration config) {
GeneratedResources resources = new GeneratedResources();
resources.setIdGeneratorDatabase(new DBInstance().withDBInstanceIdentifier(config.getIdGeneratorDatabaseIdentifier()).withEndpoint(new Endpoint().withAddress("id-gen-db.someplace.com")));
resources.setStackInstancesDatabase(new DBInstance().withDBInstanceIdentifier(config.getStackInstanceDatabaseIdentifier()).withEndpoint(new Endpoint().withAddress("stack-instance-db.someplace.com")));
resources.setSearchDomain(new DomainStatus().withSearchService(new ServiceEndpoint().withEndpoint("search-service.someplace.com")));
resources.getSearchDomain().setDocService(new ServiceEndpoint().withEndpoint("doc-service.someplace.com"));
resources.setSslCertificate(StackEnvironmentType.REPO, new ServerCertificateMetadata().withArn("ssl:arn:123"));
resources.setSslCertificate(StackEnvironmentType.WORKERS, new ServerCertificateMetadata().withArn("ssl:arn:123"));
resources.setSslCertificate(StackEnvironmentType.PORTAL, new ServerCertificateMetadata().withArn("ssl:arn:456"));
resources.setACMCertificateArn(StackEnvironmentType.PORTAL, "arn:aws:acm:us-east1:123456789012:certificate/12345678-1234-1234-1234-123456789012");
resources.setACMCertificateArn(StackEnvironmentType.REPO, "arn:aws:acm:us-east1:123456789012:certificate/12345678-1234-1234-1234-223456789012");
resources.setACMCertificateArn(StackEnvironmentType.WORKERS, "arn:aws:acm:us-east1:123456789012:certificate/12345678-1234-1234-1234-323456789012");
resources.setPortalApplicationVersion(new ApplicationVersionDescription().withVersionLabel(config.getVersionLabel(PREFIX_PORTAL)));
resources.setRepoApplicationVersion(new ApplicationVersionDescription().withVersionLabel(config.getVersionLabel(PREFIX_REPO)));
resources.setWorkersApplicationVersion(new ApplicationVersionDescription().withVersionLabel(config.getVersionLabel(PREFIX_WORKERS)));
resources.setStackKeyPair(new KeyPairInfo().withKeyName(config.getStackKeyPairName()));
// Add tables database instances
List<DBInstance> tablesInstances = new LinkedList<DBInstance>();
tablesInstances.add(new DBInstance().withEndpoint(new Endpoint().withAddress("tables.endpoint.one")));
tablesInstances.add(new DBInstance().withEndpoint(new Endpoint().withAddress("tables.endpoint.two")));
resources.setStackInstanceTablesDatabases(tablesInstances);
return resources;
}
Aggregations