Search in sources :

Example 1 with ServerCertificateMetadata

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;
        }
    }
}
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 ServerCertificateMetadata

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);
}
Also used : ServerCertificateMetadata(com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata) LinkedList(java.util.LinkedList) ListServerCertificatesResult(com.amazonaws.services.identitymanagement.model.ListServerCertificatesResult) Test(org.junit.Test)

Example 3 with ServerCertificateMetadata

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());
}
Also used : ServerCertificateMetadata(com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata) LinkedList(java.util.LinkedList) ListServerCertificatesResult(com.amazonaws.services.identitymanagement.model.ListServerCertificatesResult) Test(org.junit.Test)

Example 4 with ServerCertificateMetadata

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());
}
Also used : ServerCertificateMetadata(com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata) UploadServerCertificateResult(com.amazonaws.services.identitymanagement.model.UploadServerCertificateResult) UploadServerCertificateRequest(com.amazonaws.services.identitymanagement.model.UploadServerCertificateRequest) LinkedList(java.util.LinkedList) ListServerCertificatesResult(com.amazonaws.services.identitymanagement.model.ListServerCertificatesResult) Test(org.junit.Test)

Example 5 with ServerCertificateMetadata

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;
}
Also used : ServerCertificateMetadata(com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata) ApplicationVersionDescription(com.amazonaws.services.elasticbeanstalk.model.ApplicationVersionDescription) DBInstance(com.amazonaws.services.rds.model.DBInstance) ServiceEndpoint(com.amazonaws.services.cloudsearchv2.model.ServiceEndpoint) Endpoint(com.amazonaws.services.rds.model.Endpoint) KeyPairInfo(com.amazonaws.services.ec2.model.KeyPairInfo) DomainStatus(com.amazonaws.services.cloudsearchv2.model.DomainStatus) ServiceEndpoint(com.amazonaws.services.cloudsearchv2.model.ServiceEndpoint) LinkedList(java.util.LinkedList)

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