Search in sources :

Example 1 with ApplicationManagementServiceClient

use of org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient in project product-is by wso2.

the class DefaultAuthSeqManagementTestCase method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    super.init();
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    defaultAuthSeqMgtServiceClient = new DefaultAuthSeqMgtServiceClient(sessionCookie, backendURL, configContext);
    applicationManagementServiceClient = new ApplicationManagementServiceClient(sessionCookie, backendURL, configContext);
    seqContent1 = readResource("defaultAuthSeq/" + seqFileName1);
    seqContent2 = readResource("defaultAuthSeq/" + seqFileName2);
    seqContent3 = readResource("defaultAuthSeq/" + seqFileName3);
    seqContent4 = readResource("defaultAuthSeq/" + seqFileName4);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) ApplicationManagementServiceClient(org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient) DefaultAuthSeqMgtServiceClient(org.wso2.identity.integration.common.clients.application.mgt.DefaultAuthSeqMgtServiceClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with ApplicationManagementServiceClient

use of org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient in project product-is by wso2.

the class AbstractAdaptiveAuthenticationTestCase method createServiceProvider.

protected ServiceProvider createServiceProvider(String appName, ApplicationManagementServiceClient applicationManagementServiceClient, OauthAdminClient oauthAdminClient, String script) throws Exception {
    OAuthConsumerAppDTO[] appDtos = oauthAdminClient.getAllOAuthApplicationData();
    for (OAuthConsumerAppDTO appDto : appDtos) {
        if (appDto.getApplicationName().equals(appName)) {
            consumerKey = appDto.getOauthConsumerKey();
            consumerSecret = appDto.getOauthConsumerSecret();
        }
    }
    ServiceProvider serviceProvider = new ServiceProvider();
    serviceProvider.setApplicationName(appName);
    serviceProvider.setDescription("This is a test Service Provider for conditional authentication flow test.");
    applicationManagementServiceClient.createApplication(serviceProvider);
    serviceProvider = applicationManagementServiceClient.getApplication(appName);
    InboundAuthenticationRequestConfig requestConfig = new InboundAuthenticationRequestConfig();
    requestConfig.setInboundAuthKey(consumerKey);
    requestConfig.setInboundAuthType("oauth2");
    if (StringUtils.isNotBlank(consumerSecret)) {
        Property property = new Property();
        property.setName("oauthConsumerSecret");
        property.setValue(consumerSecret);
        Property[] properties = { property };
        requestConfig.setProperties(properties);
    }
    InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig();
    inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { requestConfig });
    serviceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig);
    LocalAndOutboundAuthenticationConfig outboundAuthConfig = createLocalAndOutboundAuthenticationConfig();
    outboundAuthConfig.setEnableAuthorization(false);
    AuthenticationScriptConfig config = new AuthenticationScriptConfig();
    config.setContent(script);
    config.setEnabled(true);
    outboundAuthConfig.setAuthenticationScriptConfig(config);
    serviceProvider.setLocalAndOutBoundAuthenticationConfig(outboundAuthConfig);
    applicationManagementServiceClient.updateApplicationData(serviceProvider);
    return serviceProvider;
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig) InboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig) AuthenticationScriptConfig(org.wso2.carbon.identity.application.common.model.script.xsd.AuthenticationScriptConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig) Property(org.wso2.carbon.identity.application.common.model.xsd.Property) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty)

Example 3 with ApplicationManagementServiceClient

use of org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient 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 4 with ApplicationManagementServiceClient

use of org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient in project product-is by wso2.

the class ApplicationAuthzTestCase method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    super.init(TestUserMode.SUPER_TENANT_ADMIN);
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    applicationManagementServiceClient = new ApplicationManagementServiceClient(sessionCookie, backendURL, configContext);
    ssoConfigServiceClient = new SAMLSSOConfigServiceClient(backendURL, sessionCookie);
    remoteUSMServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie);
    entitlementPolicyClient = new EntitlementPolicyServiceClient(backendURL, sessionCookie);
    httpClientAzUser = HttpClientBuilder.create().setDefaultCookieStore(new BasicCookieStore()).build();
    httpClientNonAzUser = HttpClientBuilder.create().setDefaultCookieStore(new BasicCookieStore()).build();
    createRole(AZ_TEST_ROLE);
    createUser(AZ_TEST_USER, AZ_TEST_USER_PW, new String[] { AZ_TEST_ROLE });
    userId = UserUtil.getUserId(MultitenantUtils.getTenantAwareUsername(AZ_TEST_USER), isServer.getContextTenant());
    createUser(NON_AZ_TEST_USER, NON_AZ_TEST_USER_PW, new String[0]);
    createApplication(APPLICATION_NAME);
    createSAMLApp(APPLICATION_NAME, true, true, true);
    setupXACMLPolicy(POLICY_ID, POLICY);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) BasicCookieStore(org.apache.http.impl.client.BasicCookieStore) ApplicationManagementServiceClient(org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient) SAMLSSOConfigServiceClient(org.wso2.identity.integration.common.clients.sso.saml.SAMLSSOConfigServiceClient) RemoteUserStoreManagerServiceClient(org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient) EntitlementPolicyServiceClient(org.wso2.identity.integration.common.clients.entitlement.EntitlementPolicyServiceClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with ApplicationManagementServiceClient

use of org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient in project product-is by wso2.

the class AbstractIdentityFederationTestCase method createServiceClients.

public void createServiceClients(int portOffset, String sessionCookie, IdentityConstants.ServiceClientType[] adminClients) throws Exception {
    if (adminClients == null) {
        return;
    }
    String serviceUrl = getSecureServiceUrl(portOffset, automationContextMap.get(portOffset).getContextUrls().getSecureServiceUrl());
    if (sessionCookie == null) {
        AuthenticatorClient authenticatorClient = new AuthenticatorClient(serviceUrl);
        sessionCookie = authenticatorClient.login(automationContextMap.get(portOffset).getSuperTenant().getTenantAdmin().getUserName(), automationContextMap.get(portOffset).getSuperTenant().getTenantAdmin().getPassword(), automationContextMap.get(portOffset).getDefaultInstance().getHosts().get("default"));
    }
    if (sessionCookie != null) {
        ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
        for (IdentityConstants.ServiceClientType clientType : adminClients) {
            if (IdentityConstants.ServiceClientType.APPLICATION_MANAGEMENT.equals(clientType)) {
                applicationManagementServiceClients.put(portOffset, new ApplicationManagementServiceClient(sessionCookie, serviceUrl, configContext));
            } else if (IdentityConstants.ServiceClientType.IDENTITY_PROVIDER_MGT.equals(clientType)) {
                identityProviderMgtServiceClients.put(portOffset, new IdentityProviderMgtServiceClient(sessionCookie, serviceUrl));
            } else if (IdentityConstants.ServiceClientType.SAML_SSO_CONFIG.equals(clientType)) {
                samlSSOConfigServiceClients.put(portOffset, new SAMLSSOConfigServiceClient(serviceUrl, sessionCookie));
            } else if (IdentityConstants.ServiceClientType.OAUTH_ADMIN.equals(clientType)) {
                oauthAdminClients.put(portOffset, new OauthAdminClient(serviceUrl, sessionCookie));
            }
        }
    }
}
Also used : OauthAdminClient(org.wso2.identity.integration.common.clients.oauth.OauthAdminClient) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) IdentityConstants(org.wso2.identity.integration.test.utils.IdentityConstants) AuthenticatorClient(org.wso2.carbon.integration.common.admin.client.AuthenticatorClient) ApplicationManagementServiceClient(org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient) SAMLSSOConfigServiceClient(org.wso2.identity.integration.common.clients.sso.saml.SAMLSSOConfigServiceClient) IdentityProviderMgtServiceClient(org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient)

Aggregations

ApplicationManagementServiceClient (org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient)42 BeforeClass (org.testng.annotations.BeforeClass)32 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)20 AuthenticatorClient (org.wso2.carbon.integration.common.admin.client.AuthenticatorClient)18 SAMLSSOConfigServiceClient (org.wso2.identity.integration.common.clients.sso.saml.SAMLSSOConfigServiceClient)17 RemoteUserStoreManagerServiceClient (org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient)16 OauthAdminClient (org.wso2.identity.integration.common.clients.oauth.OauthAdminClient)15 BasicCookieStore (org.apache.http.impl.client.BasicCookieStore)8 IdentityProviderMgtServiceClient (org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient)7 LoginLogoutClient (org.wso2.carbon.integration.common.utils.LoginLogoutClient)6 ServiceProvider (org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)5 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)4 ServerConfigurationManager (org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager)4 UserManagementClient (org.wso2.identity.integration.common.clients.UserManagementClient)4 ApplicationManagementServiceClient (org.wso2.identity.scenarios.commons.clients.application.mgt.ApplicationManagementServiceClient)4 File (java.io.File)3 InboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig)3 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig)3 Property (org.wso2.carbon.identity.application.common.model.xsd.Property)3 AfterClass (org.testng.annotations.AfterClass)2