Search in sources :

Example 11 with LocalAuthenticatorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig 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);
    }
}
Also used : AuthenticationScriptConfig(org.wso2.carbon.identity.application.common.model.script.xsd.AuthenticationScriptConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) LocalAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig) AuthenticationStep(org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep) URISyntaxException(java.net.URISyntaxException) IdentityDefaultSeqManagementServiceDefaultAuthSeqMgtException(org.wso2.carbon.identity.application.mgt.defaultsequence.stub.IdentityDefaultSeqManagementServiceDefaultAuthSeqMgtException) IOException(java.io.IOException)

Example 12 with LocalAuthenticatorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig 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;
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig) LocalAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig) AuthenticationStep(org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep)

Example 13 with LocalAuthenticatorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig 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;
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig) LocalAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig) AuthenticationStep(org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep)

Example 14 with LocalAuthenticatorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig in project product-is by wso2.

the class EmailOTPTestCase method getLocalAndOutBoundAuthenticator.

private LocalAndOutboundAuthenticationConfig getLocalAndOutBoundAuthenticator() throws Exception {
    LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = new LocalAndOutboundAuthenticationConfig();
    // This will add basic authentication as the first step for authentication.
    AuthenticationStep authenticationStepOne = new AuthenticationStep();
    authenticationStepOne.setStepOrder(1);
    LocalAuthenticatorConfig localConfig = new LocalAuthenticatorConfig();
    localConfig.setName(CommonConstants.BASIC_AUTHENTICATOR);
    localConfig.setDisplayName("basicauth");
    localConfig.setEnabled(true);
    authenticationStepOne.setLocalAuthenticatorConfigs(new LocalAuthenticatorConfig[] { localConfig });
    localAndOutboundAuthenticationConfig.addAuthenticationSteps(authenticationStepOne);
    // This will add email otp as the second step for authentication.
    AuthenticationStep authenticationStepTwo = new AuthenticationStep();
    authenticationStepTwo.setStepOrder(2);
    authenticationStepTwo.setSubjectStep(false);
    authenticationStepTwo.setAttributeStep(false);
    authenticationStepTwo.setFederatedIdentityProviders(new IdentityProvider[] { getEmailOTPIdP() });
    localAndOutboundAuthenticationConfig.addAuthenticationSteps(authenticationStepTwo);
    return localAndOutboundAuthenticationConfig;
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig) LocalAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig) AuthenticationStep(org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep)

Example 15 with LocalAuthenticatorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig in project identity-api-server by wso2.

the class UpdateAuthenticationSequence method buildAuthenticationStep.

private AuthenticationStep buildAuthenticationStep(AuthenticationStepModel stepModel) {
    AuthenticationStep authenticationStep = new AuthenticationStep();
    // iteration the options, divide in to federated and local and add the configs
    if (CollectionUtils.isEmpty(stepModel.getOptions())) {
        throw Utils.buildBadRequestError("Authentication Step options cannot be empty.");
    }
    List<LocalAuthenticatorConfig> localAuthOptions = new ArrayList<>();
    List<IdentityProvider> federatedAuthOptions = new ArrayList<>();
    stepModel.getOptions().forEach(option -> {
        // TODO : add validations to swagger so that we don't need to check inputs here.
        if (FrameworkConstants.LOCAL_IDP_NAME.equals(option.getIdp())) {
            LocalAuthenticatorConfig localAuthOption = new LocalAuthenticatorConfig();
            localAuthOption.setEnabled(true);
            localAuthOption.setName(option.getAuthenticator());
            localAuthOptions.add(localAuthOption);
        } else {
            FederatedAuthenticatorConfig federatedAuthConfig = new FederatedAuthenticatorConfig();
            federatedAuthConfig.setEnabled(true);
            federatedAuthConfig.setName(option.getAuthenticator());
            IdentityProvider federatedIdp = new IdentityProvider();
            federatedIdp.setIdentityProviderName(option.getIdp());
            federatedIdp.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[] { federatedAuthConfig });
            federatedIdp.setDefaultAuthenticatorConfig(federatedAuthConfig);
            federatedAuthOptions.add(federatedIdp);
        }
    });
    authenticationStep.setLocalAuthenticatorConfigs(localAuthOptions.toArray(new LocalAuthenticatorConfig[0]));
    authenticationStep.setFederatedIdentityProviders(federatedAuthOptions.toArray(new IdentityProvider[0]));
    return authenticationStep;
}
Also used : FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig) LocalAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig) ArrayList(java.util.ArrayList) AuthenticationStep(org.wso2.carbon.identity.application.common.model.AuthenticationStep) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider)

Aggregations

LocalAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig)19 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)11 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)9 RequestPathAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig)8 AuthenticationStep (org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep)8 LocalAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig)8 ArrayList (java.util.ArrayList)7 AuthenticationStep (org.wso2.carbon.identity.application.common.model.AuthenticationStep)7 LocalAndOutboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig)6 HashMap (java.util.HashMap)4 AuthenticatorConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig)4 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)4 Map (java.util.Map)3 Authenticator (org.wso2.carbon.identity.api.server.authenticators.v1.model.Authenticator)3 StepConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.StepConfig)3 Property (org.wso2.carbon.identity.application.common.model.Property)3 IOException (java.io.IOException)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 List (java.util.List)2