use of org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep in project carbon-identity-framework by wso2.
the class ApplicationIdentityProviderMgtListener method updateApplicationWithFederatedAuthenticator.
/**
* Update the service providers, with the default authenticator of the identity provider.
*
* @param identityProvider
* @param tenantDomain
* @param serviceProvider
* @param authStep
* @throws IdentityApplicationManagementException
* @throws IdentityProviderManagementException
*/
private void updateApplicationWithFederatedAuthenticator(IdentityProvider identityProvider, String tenantDomain, ServiceProvider serviceProvider, AuthenticationStep authStep) throws IdentityApplicationManagementException, IdentityProviderManagementException {
IdentityProvider fedIdp = authStep.getFederatedIdentityProviders()[0];
if (StringUtils.equals(fedIdp.getIdentityProviderName(), identityProvider.getIdentityProviderName())) {
String defaultAuthName = fedIdp.getDefaultAuthenticatorConfig().getName();
if (identityProvider.getDefaultAuthenticatorConfig() != null) {
String currentDefaultAuthName = identityProvider.getDefaultAuthenticatorConfig().getName();
boolean isCurrentDefaultAuthEnabled = identityProvider.getDefaultAuthenticatorConfig().isEnabled();
if (!StringUtils.equals(currentDefaultAuthName, defaultAuthName)) {
FederatedAuthenticatorConfig currentDefaultAuthenticatorConfig = identityProvider.getDefaultAuthenticatorConfig();
fedIdp.setDefaultAuthenticatorConfig(currentDefaultAuthenticatorConfig);
fedIdp.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[] { currentDefaultAuthenticatorConfig });
ApplicationMgtSystemConfig.getInstance().getApplicationDAO().updateApplication(serviceProvider, tenantDomain);
} else if (!isCurrentDefaultAuthEnabled && StringUtils.equals(currentDefaultAuthName, defaultAuthName)) {
throw new IdentityProviderManagementException("Error in disabling default federated authenticator" + " as it is referred by service providers.");
}
}
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep in project product-is by wso2.
the class DefaultAuthSeqManagementTestCase method updateApplicationData.
private void updateApplicationData(String name) {
try {
ServiceProvider serviceProvider = applicationManagementServiceClient.getApplication(name);
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationType("flow");
AuthenticationStep authStep = new AuthenticationStep();
authStep.setStepOrder(1);
authStep.setAttributeStep(true);
authStep.setSubjectStep(true);
LocalAuthenticatorConfig localAuthenticatorConfig = new LocalAuthenticatorConfig();
localAuthenticatorConfig.setName("BasicAuthenticator");
localAuthenticatorConfig.setDisplayName("basic");
localAuthenticatorConfig.setEnabled(true);
authStep.setLocalAuthenticatorConfigs(new LocalAuthenticatorConfig[] { localAuthenticatorConfig });
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(new AuthenticationStep[] { authStep });
AuthenticationScriptConfig scriptConfig = new AuthenticationScriptConfig();
scriptConfig.setLanguage("application/javascript");
scriptConfig.setContent("function onLoginRequest(context) {\r\n executeStep(1);\r\n}\r\n");
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationScriptConfig(scriptConfig);
applicationManagementServiceClient.updateApplicationData(serviceProvider);
ServiceProvider updatedServiceProvider = applicationManagementServiceClient.getApplication(applicationName);
Assert.assertEquals(updatedServiceProvider.getLocalAndOutBoundAuthenticationConfig().getAuthenticationSteps()[0].getLocalAuthenticatorConfigs()[0].getDisplayName(), "basic", "Failed update Authentication step");
} catch (Exception e) {
fail("Error while trying to update Service Provider", e);
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep in project product-is by wso2.
the class AbstractAdaptiveAuthenticationTestCase method createLocalAndOutboundAuthenticationConfig.
/**
* Create the AdvancedAuthenticator with Multi steps.
* Use any attributes needed if needed to do multiple tests with different advanced authenticators.
*
* @throws Exception
*/
protected LocalAndOutboundAuthenticationConfig createLocalAndOutboundAuthenticationConfig() throws Exception {
LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = new LocalAndOutboundAuthenticationConfig();
localAndOutboundAuthenticationConfig.setAuthenticationType("flow");
AuthenticationStep authenticationStep1 = new AuthenticationStep();
authenticationStep1.setStepOrder(1);
LocalAuthenticatorConfig localConfig = new LocalAuthenticatorConfig();
localConfig.setName(CommonConstants.BASIC_AUTHENTICATOR);
localConfig.setDisplayName("basicauth");
localConfig.setEnabled(true);
authenticationStep1.setLocalAuthenticatorConfigs(new LocalAuthenticatorConfig[] { localConfig });
authenticationStep1.setSubjectStep(true);
authenticationStep1.setAttributeStep(true);
localAndOutboundAuthenticationConfig.addAuthenticationSteps(authenticationStep1);
return localAndOutboundAuthenticationConfig;
}
use of org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep in project product-is by wso2.
the class RiskBasedLoginTestCase method createLocalAndOutboundAuthenticationConfig.
protected LocalAndOutboundAuthenticationConfig createLocalAndOutboundAuthenticationConfig() throws Exception {
LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = super.createLocalAndOutboundAuthenticationConfig();
AuthenticationStep authenticationStep2 = new AuthenticationStep();
authenticationStep2.setStepOrder(2);
LocalAuthenticatorConfig localConfig = new LocalAuthenticatorConfig();
localConfig.setName("DemoFingerprintAuthenticator");
localConfig.setDisplayName("Demo Fingerprint Authenticator");
localConfig.setEnabled(true);
authenticationStep2.setLocalAuthenticatorConfigs(new LocalAuthenticatorConfig[] { localConfig });
authenticationStep2.setSubjectStep(false);
authenticationStep2.setAttributeStep(false);
localAndOutboundAuthenticationConfig.addAuthenticationSteps(authenticationStep2);
return localAndOutboundAuthenticationConfig;
}
use of org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep in project product-is by wso2.
the class ApplicationManagementTestCase method testOutboundAuthenticatorConfiguration.
@Test(alwaysRun = true, description = "Testing update Outbound Authenticator Configuration")
public void testOutboundAuthenticatorConfiguration() {
String applicationName = "TestServiceProvider";
try {
ServiceProvider serviceProvider = applicationManagementServiceClient.getApplication(applicationName);
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationType("federated");
AuthenticationStep authStep = new AuthenticationStep();
IdentityProvider idp = new IdentityProvider();
idp.setIdentityProviderName("fed_idp");
FederatedAuthenticatorConfig customConfig = new FederatedAuthenticatorConfig();
customConfig.setName("test_auth");
customConfig.setEnabled(true);
idp.setDefaultAuthenticatorConfig(customConfig);
createIdp(idp);
authStep.setFederatedIdentityProviders(new IdentityProvider[] { idp });
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(new AuthenticationStep[] { authStep });
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setSubjectClaimUri("subject_claim_uri");
applicationManagementServiceClient.updateApplicationData(serviceProvider);
ServiceProvider updatedServiceProvider = applicationManagementServiceClient.getApplication(applicationName);
Assert.assertEquals(updatedServiceProvider.getLocalAndOutBoundAuthenticationConfig().getAuthenticationSteps()[0].getFederatedIdentityProviders()[0].getIdentityProviderName(), "fed_idp", "Failed update Authentication step");
Assert.assertEquals(updatedServiceProvider.getLocalAndOutBoundAuthenticationConfig().getSubjectClaimUri(), "subject_claim_uri", "Failed update subject claim uri");
} catch (Exception e) {
Assert.fail("Error while trying to update Outbound Authenticator Configuration", e);
}
}
Aggregations