use of org.wso2.identity.integration.common.clients.oauth.OauthAdminClient 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.oauth.OauthAdminClient in project product-is by wso2.
the class AbstractAdaptiveAuthenticationTestCase method createOauthApp.
protected void createOauthApp(String callback, String appName, OauthAdminClient oAuthAdminClient) throws RemoteException, OAuthAdminServiceIdentityOAuthAdminException {
OAuthConsumerAppDTO appDTO = new OAuthConsumerAppDTO();
appDTO.setCallbackUrl(callback);
appDTO.setGrantTypes("authorization_code implicit password client_credentials refresh_token " + "urn:ietf:params:oauth:grant-type:saml2-bearer iwa:ntlm");
appDTO.setOAuthVersion(OAuth2Constant.OAUTH_VERSION_2);
appDTO.setApplicationName(appName);
oAuthAdminClient.registerOAuthApplicationData(appDTO);
OAuthConsumerAppDTO[] appDtos = oAuthAdminClient.getAllOAuthApplicationData();
for (OAuthConsumerAppDTO appDto : appDtos) {
if (appDto.getApplicationName().equals(appName)) {
consumerKey = appDto.getOauthConsumerKey();
consumerSecret = appDto.getOauthConsumerSecret();
}
}
}
use of org.wso2.identity.integration.common.clients.oauth.OauthAdminClient 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.oauth.OauthAdminClient 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));
}
}
}
}
use of org.wso2.identity.integration.common.clients.oauth.OauthAdminClient in project product-is by wso2.
the class CrossProtocolLogoutTestCase method init.
protected void init() throws Exception {
super.init();
adminClient = new OauthAdminClient(backendURL, sessionCookie);
ssoConfigServiceClient = new SAMLSSOConfigServiceClient(backendURL, sessionCookie);
applicationManagementServiceClient = new ApplicationManagementServiceClient(sessionCookie, backendURL, null);
}
Aggregations