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);
}
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;
}
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);
}
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);
}
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));
}
}
}
}
Aggregations