Search in sources :

Example 1 with AuthenticatorClient

use of org.wso2.carbon.integration.common.admin.client.AuthenticatorClient in project product-is by wso2.

the class RiskBasedLoginTestCase method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    super.init();
    InputStream webappUrl = getClass().getResourceAsStream(ISIntegrationTest.URL_SEPARATOR + "samples" + ISIntegrationTest.URL_SEPARATOR + "authenticators" + ISIntegrationTest.URL_SEPARATOR + "sample-auth.war");
    InputStream jarUrl = getClass().getResourceAsStream(ISIntegrationTest.URL_SEPARATOR + "samples" + ISIntegrationTest.URL_SEPARATOR + "authenticators" + ISIntegrationTest.URL_SEPARATOR + "org.wso2.carbon.identity.sample.extension.authenticators.jar");
    String authenticatorPathString = Utils.getResidentCarbonHome() + File.separator + "repository" + File.separator + "components" + File.separator + "dropins" + File.separator + "org.wso2.carbon.identity.sample.extension.authenticators.jar";
    File jarDestFile = new File(authenticatorPathString);
    FileOutputStream jarDest = new FileOutputStream(jarDestFile);
    copyFileUsingStream(jarUrl, jarDest);
    log.info("Copied the demo authenticator jar file to " + authenticatorPathString);
    Assert.assertTrue(Files.exists(Paths.get(authenticatorPathString)), "Demo Authenticator is not copied " + "successfully. File path: " + authenticatorPathString);
    String authenticatorWarPathString = Utils.getResidentCarbonHome() + File.separator + "repository" + File.separator + "deployment" + File.separator + "server" + File.separator + "webapps" + File.separator + "sample-auth.war";
    File warDestFile = new File(authenticatorWarPathString);
    FileOutputStream warDest = new FileOutputStream(warDestFile);
    copyFileUsingStream(webappUrl, warDest);
    // Waiting for the war file to deploy.
    String authenticatorWebappPathString = Utils.getResidentCarbonHome() + File.separator + "repository" + File.separator + "deployment" + File.separator + "server" + File.separator + "webapps" + File.separator + "sample-auth";
    waitForWebappToDeploy(authenticatorWebappPathString, 120000L);
    log.info("Copied the demo authenticator war file to " + authenticatorWarPathString);
    Assert.assertTrue(Files.exists(Paths.get(authenticatorWarPathString)), "Demo Authenticator war is not copied " + "successfully. File path: " + authenticatorWarPathString);
    log.info("Restarting the server at: " + isServer.getContextUrls().getBackEndUrl());
    serverConfigurationManager = new ServerConfigurationManager(isServer);
    changeISConfiguration();
    log.info("Restarting the server at: " + isServer.getContextUrls().getBackEndUrl() + " is successful");
    super.init();
    logManger = new AuthenticatorClient(backendURL);
    String cookie = this.logManger.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), isServer.getSuperTenant().getTenantAdmin().getPassword(), isServer.getInstance().getHosts().get("default"));
    oauthAdminClient = new OauthAdminClient(backendURL, cookie);
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    applicationManagementServiceClient = new ApplicationManagementServiceClient(sessionCookie, backendURL, configContext);
    webAppAdminClient = new WebAppAdminClient(backendURL, sessionCookie);
    client = HttpClientBuilder.create().disableRedirectHandling().setDefaultCookieStore(cookieStore).build();
    String script = getConditionalAuthScript("RiskBasedLoginScript.js");
    createOauthApp(CALLBACK_URL, PRIMARY_IS_APPLICATION_NAME, oauthAdminClient);
    // Create service provider in primary IS with conditional authentication script enabled.
    createServiceProvider(PRIMARY_IS_APPLICATION_NAME, applicationManagementServiceClient, oauthAdminClient, script);
    microserviceServer = MicroserviceUtil.initMicroserviceServer();
    MicroserviceUtil.deployService(microserviceServer, this);
    superTenantResidentIDP = superTenantIDPMgtClient.getResidentIdP();
    updateResidentIDPProperty(superTenantResidentIDP, "adaptive_authentication.analytics.receiver", "http://localhost:" + microserviceServer.getPort());
    userRiskScores.put(userInfo.getUserName(), 0);
}
Also used : OauthAdminClient(org.wso2.identity.integration.common.clients.oauth.OauthAdminClient) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AuthenticatorClient(org.wso2.carbon.integration.common.admin.client.AuthenticatorClient) InputStream(java.io.InputStream) ServerConfigurationManager(org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager) FileOutputStream(java.io.FileOutputStream) ApplicationManagementServiceClient(org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient) WebAppAdminClient(org.wso2.identity.integration.common.clients.webappmgt.WebAppAdminClient) File(java.io.File) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with AuthenticatorClient

use of org.wso2.carbon.integration.common.admin.client.AuthenticatorClient in project product-is by wso2.

the class ReadOnlyUserStoreInitializerTestCase method initUserStoreConfig.

@BeforeTest(alwaysRun = true)
public void initUserStoreConfig() throws Exception {
    super.init();
    userMgtClient = new UserManagementClient(backendURL, getSessionCookie());
    authenticatorClient = new AuthenticatorClient(backendURL);
    userMgtClient.addRole(newUserRole, null, new String[] { "/permission/admin/login" });
    userMgtClient.addUser(newUserName, newUserPassword, new String[] { newUserRole }, null);
    applyTomlConfigsAndRestart();
}
Also used : AuthenticatorClient(org.wso2.carbon.integration.common.admin.client.AuthenticatorClient) UserManagementClient(org.wso2.identity.integration.common.clients.UserManagementClient) BeforeTest(org.testng.annotations.BeforeTest)

Example 3 with AuthenticatorClient

use of org.wso2.carbon.integration.common.admin.client.AuthenticatorClient in project product-is by wso2.

the class UserInformationRecoveryServiceTenantEmailUserTestCase method testInit.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    super.init();
    String carbonHome = Utils.getResidentCarbonHome();
    identityMgtServerFile = new File(carbonHome + File.separator + "repository" + File.separator + "conf" + File.separator + "identity" + File.separator + "identity-mgt.properties");
    File identityMgtConfigFile = new File(getISResourceLocation() + File.separator + "identityMgt" + File.separator + "identity-mgt-enabled.properties");
    File defaultTomlFile = getDeploymentTomlFile(carbonHome);
    File configuredTomlFile = new File(getISResourceLocation() + File.separator + "identityMgt" + File.separator + "user_mgt_regex_changed.toml");
    scm = new ServerConfigurationManager(isServer);
    scm.applyConfigurationWithoutRestart(identityMgtConfigFile, identityMgtServerFile, true);
    scm.applyConfigurationWithoutRestart(configuredTomlFile, defaultTomlFile, true);
    scm.restartGracefully();
    super.init();
    tenantServiceClient = new TenantManagementServiceClient(isServer.getContextUrls().getBackEndUrl(), sessionCookie);
    tenantServiceClient.addTenant(TENANT_DOMAIN, TENANT_ADMIN_TENANT_AWARE_USERNAME, TENANT_ADMIN_PASSWORD, TENANT_ADMIN_USERNAME, "Info", "Recovery");
    loginManger = new AuthenticatorClient(backendURL);
    sessionCookie = this.loginManger.login(TENANT_ADMIN_USERNAME, TENANT_ADMIN_PASSWORD, isServer.getInstance().getHosts().get(profileName));
    userMgtClient = new UserManagementClient(backendURL, sessionCookie);
    infoRecoveryClient = new UserInformationRecoveryServiceClient(backendURL, sessionCookie);
    userMgtClient.addUser(TENANT_USER, "passWord1@", null, profileName);
}
Also used : AuthenticatorClient(org.wso2.carbon.integration.common.admin.client.AuthenticatorClient) ServerConfigurationManager(org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager) UserManagementClient(org.wso2.identity.integration.common.clients.UserManagementClient) File(java.io.File) TenantManagementServiceClient(org.wso2.identity.integration.common.clients.TenantManagementServiceClient) UserInformationRecoveryServiceClient(org.wso2.identity.integration.common.clients.mgt.UserInformationRecoveryServiceClient) BeforeClass(org.testng.annotations.BeforeClass) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment)

Example 4 with AuthenticatorClient

use of org.wso2.carbon.integration.common.admin.client.AuthenticatorClient in project product-is by wso2.

the class UserInformationRecoveryServiceTestCase method testInit.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    super.init();
    String carbonHome = Utils.getResidentCarbonHome();
    identityMgtServerFile = new File(carbonHome + File.separator + "repository" + File.separator + "conf" + File.separator + "identity" + File.separator + "identity-mgt.properties");
    File identityMgtConfigFile = new File(getISResourceLocation() + File.separator + "identityMgt" + File.separator + "identity-mgt-enabled.properties");
    axisServerFile = new File(carbonHome + File.separator + "repository" + File.separator + "conf" + File.separator + "axis2" + File.separator + "axis2.xml");
    File axisConfigFile = new File(getISResourceLocation() + File.separator + "identityMgt" + File.separator + "axis2.xml");
    scm = new ServerConfigurationManager(isServer);
    scm.applyConfigurationWithoutRestart(identityMgtConfigFile, identityMgtServerFile, true);
    scm.applyConfigurationWithoutRestart(axisConfigFile, axisServerFile, true);
    scm.restartGracefully();
    super.init();
    loginManger = new AuthenticatorClient(backendURL);
    userMgtClient = new UserManagementClient(backendURL, sessionCookie);
    infoRecoveryClient = new UserInformationRecoveryServiceClient(backendURL, sessionCookie);
    profileClient = new UserProfileMgtServiceClient(backendURL, sessionCookie);
    loginManger.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), isServer.getSuperTenant().getTenantAdmin().getPassword(), isServer.getInstance().getHosts().get("default"));
    claimMgtClient = new ClaimManagementServiceClient(backendURL, sessionCookie);
    ClaimDTO claim1 = new ClaimDTO();
    claim1.setDialectURI("http://wso2.org/claims");
    claim1.setClaimUri("http://wso2.org/claims/identity/unlockTime");
    claim1.setDescription("Account Unlock time");
    ClaimDTO claim2 = new ClaimDTO();
    claim2.setDialectURI("http://wso2.org/claims");
    claim2.setClaimUri("http://wso2.org/claims/identity/failedLoginAttempts");
    claim2.setDescription("Failed login attempts");
    ClaimMappingDTO claimMapping1 = new ClaimMappingDTO();
    claimMapping1.setClaim(claim1);
    claimMapping1.setMappedAttribute("description");
    claimMgtClient.addNewClaimMapping(claimMapping1);
    ClaimMappingDTO claimMapping2 = new ClaimMappingDTO();
    claimMapping2.setClaim(claim2);
    claimMapping2.setMappedAttribute("employeeType");
    claimMgtClient.addNewClaimMapping(claimMapping2);
    userMgtClient.addUser("user11", "passWord1@", null, "default");
    userMgtClient.addRole("umRole11", new String[] { "user11" }, new String[] { "/permission/admin/login" }, false);
}
Also used : UserProfileMgtServiceClient(org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient) ClaimMappingDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimMappingDTO) UserIdentityClaimDTO(org.wso2.carbon.identity.mgt.stub.dto.UserIdentityClaimDTO) ClaimDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimDTO) ClaimManagementServiceClient(org.wso2.identity.integration.common.clients.ClaimManagementServiceClient) AuthenticatorClient(org.wso2.carbon.integration.common.admin.client.AuthenticatorClient) ServerConfigurationManager(org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager) UserManagementClient(org.wso2.identity.integration.common.clients.UserManagementClient) File(java.io.File) UserInformationRecoveryServiceClient(org.wso2.identity.integration.common.clients.mgt.UserInformationRecoveryServiceClient) BeforeClass(org.testng.annotations.BeforeClass) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment)

Example 5 with AuthenticatorClient

use of org.wso2.carbon.integration.common.admin.client.AuthenticatorClient in project product-is by wso2.

the class ResidentIDPConfigsTestCase method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    AuthenticatorClient loginManger = new AuthenticatorClient(backendURL);
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    String cookie = loginManger.login(username, userPassword, isServer.getInstance().getHosts().get("default"));
    idpMgtServiceClient = new IdentityProviderMgtServiceClient(cookie, isServer.getContextUrls().getBackEndUrl(), configContext);
    IdentityProvider idProvider = idpMgtServiceClient.getResidentIdP();
    log.info("Retrieving resident identity provider");
    fedAuthConfigMap = getFedAuthConfigMap(idProvider);
    provisioningConfigMap = getProvisioningConfigMap(idProvider);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AuthenticatorClient(org.wso2.carbon.integration.common.admin.client.AuthenticatorClient) IdentityProvider(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider) IdentityProviderMgtServiceClient(org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

AuthenticatorClient (org.wso2.carbon.integration.common.admin.client.AuthenticatorClient)56 BeforeClass (org.testng.annotations.BeforeClass)44 UserManagementClient (org.wso2.identity.integration.common.clients.UserManagementClient)19 ApplicationManagementServiceClient (org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient)18 RemoteUserStoreManagerServiceClient (org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient)15 OauthAdminClient (org.wso2.identity.integration.common.clients.oauth.OauthAdminClient)14 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)13 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)10 ServerConfigurationManager (org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager)9 File (java.io.File)8 SetEnvironment (org.wso2.carbon.automation.engine.annotations.SetEnvironment)7 IdentityProviderMgtServiceClient (org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient)7 LoginLogoutClient (org.wso2.carbon.integration.common.utils.LoginLogoutClient)6 SAMLSSOConfigServiceClient (org.wso2.identity.integration.common.clients.sso.saml.SAMLSSOConfigServiceClient)6 BasicCookieStore (org.apache.http.impl.client.BasicCookieStore)5 Test (org.testng.annotations.Test)4 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)4 ServiceProvider (org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)3 UserProfileMgtServiceClient (org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient)3 XPathExpressionException (javax.xml.xpath.XPathExpressionException)2