Search in sources :

Example 1 with KeyStoreAdminClient

use of org.wso2.identity.integration.common.clients.KeyStoreAdminClient in project product-is by wso2.

the class SPMetaDataTenantTestCase method restartTestServer.

@Test(testName = "metaDataTestcase", dependsOnMethods = "addSPMetadataForTenant")
public void restartTestServer() throws Exception {
    super.init();
    ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(isServer);
    serverConfigurationManager.restartGracefully();
    super.init(TestUserMode.TENANT_ADMIN);
    KeyStoreAdminClient keyStoreAdminClient = new KeyStoreAdminClient(backendURL, ADMIN_USERNAME, ADMIN_PASSWORD);
    KeyStoreData[] keyStoreDataArray = keyStoreAdminClient.getKeyStores();
    Assert.assertTrue(keyStoreDataArray != null && keyStoreDataArray.length > 0);
    String[] storeEntries = keyStoreAdminClient.getStoreEntries("wso2-com.jks");
    Assert.assertTrue(storeEntries != null && storeEntries.length > 0);
    Assert.assertTrue(Arrays.asList(storeEntries).contains(CERT_ALIAS));
}
Also used : KeyStoreAdminClient(org.wso2.identity.integration.common.clients.KeyStoreAdminClient) ServerConfigurationManager(org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager) KeyStoreData(org.wso2.carbon.security.mgt.stub.keystore.xsd.KeyStoreData) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 2 with KeyStoreAdminClient

use of org.wso2.identity.integration.common.clients.KeyStoreAdminClient in project product-is by wso2.

the class SAMLQueryProfileTestCase method initiateTenant.

@BeforeTest
public void initiateTenant() throws Exception {
    // Since all the requests sign with default wso2 key, upload that public key to tenants
    super.init(TestUserMode.TENANT_ADMIN);
    KeyStoreAdminClient keyStoreAdminClient = new KeyStoreAdminClient(backendURL, sessionCookie);
    String filePath = FrameworkPathUtil.getSystemResourceLocation() + "keystores" + File.separator + "products" + File.separator + "wso2carbon.pem";
    byte[] crt = Files.readAllBytes(Paths.get(filePath));
    keyStoreAdminClient.importCertToStore("wso2carbon", crt, "wso2-com.jks");
}
Also used : KeyStoreAdminClient(org.wso2.identity.integration.common.clients.KeyStoreAdminClient) BeforeTest(org.testng.annotations.BeforeTest)

Example 3 with KeyStoreAdminClient

use of org.wso2.identity.integration.common.clients.KeyStoreAdminClient in project product-is by wso2.

the class SPMetaDataTenantTestCase method addSPMetadataForTenant.

@Test(testName = "metaDataTestcase")
public void addSPMetadataForTenant() throws Exception {
    String filePath = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "IS" + File.separator + "saml" + File.separator + "sp-metadata.xml";
    byte[] encoded = Files.readAllBytes(Paths.get(filePath));
    String metadataXml = new String(encoded, StandardCharsets.UTF_8);
    // Load the metadata file to the client.
    SAMLSSOServiceProviderDTO samlssoServiceProviderDTO = ssoConfigServiceClient.uploadServiceProvider(metadataXml);
    Assert.assertEquals(samlssoServiceProviderDTO.getIssuer(), ISSUER);
    SAMLSSOServiceProviderDTO[] samlssoServiceProviderDTOs = ssoConfigServiceClient.getServiceProviders().getServiceProviders();
    SAMLSSOServiceProviderDTO samlssoServiceProviderDTOGet = null;
    for (SAMLSSOServiceProviderDTO serviceProviderDTO : samlssoServiceProviderDTOs) {
        if (ISSUER.equals(serviceProviderDTO.getIssuer())) {
            samlssoServiceProviderDTOGet = serviceProviderDTO;
        }
    }
    Assert.assertNotNull(samlssoServiceProviderDTOGet);
    Assert.assertEquals(samlssoServiceProviderDTOGet.getCertAlias(), CERT_ALIAS);
    KeyStoreAdminClient keyStoreAdminClient = new KeyStoreAdminClient(backendURL, ADMIN_USERNAME, ADMIN_PASSWORD);
    KeyStoreData[] keyStoreDataArray = keyStoreAdminClient.getKeyStores();
    Assert.assertTrue(keyStoreDataArray != null && keyStoreDataArray.length > 0);
    String[] storeEntries = keyStoreAdminClient.getStoreEntries("wso2-com.jks");
    Assert.assertTrue(storeEntries != null && storeEntries.length > 0);
    Assert.assertTrue(Arrays.asList(storeEntries).contains(CERT_ALIAS));
}
Also used : KeyStoreAdminClient(org.wso2.identity.integration.common.clients.KeyStoreAdminClient) SAMLSSOServiceProviderDTO(org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO) KeyStoreData(org.wso2.carbon.security.mgt.stub.keystore.xsd.KeyStoreData) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

KeyStoreAdminClient (org.wso2.identity.integration.common.clients.KeyStoreAdminClient)3 Test (org.testng.annotations.Test)2 KeyStoreData (org.wso2.carbon.security.mgt.stub.keystore.xsd.KeyStoreData)2 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)2 BeforeTest (org.testng.annotations.BeforeTest)1 SAMLSSOServiceProviderDTO (org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO)1 ServerConfigurationManager (org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager)1