Search in sources :

Example 1 with AuthenticationSequence

use of org.wso2.carbon.identity.api.server.application.management.v1.AuthenticationSequence in project identity-api-server by wso2.

the class UpdateAuthenticationSequence method apply.

@Override
public void apply(ServiceProvider application, AuthenticationSequence authSequenceApiModel) {
    if (authSequenceApiModel != null) {
        updateRequestPathAuthenticatorConfigs(authSequenceApiModel, application);
        // Authentication steps
        LocalAndOutboundAuthenticationConfig localAndOutboundConfig = getLocalAndOutboundConfig(application);
        updateAuthenticationSteps(authSequenceApiModel, localAndOutboundConfig);
        updateAdaptiveAuthenticationScript(authSequenceApiModel, localAndOutboundConfig);
    }
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig)

Example 2 with AuthenticationSequence

use of org.wso2.carbon.identity.api.server.application.management.v1.AuthenticationSequence in project identity-api-server by wso2.

the class UpdateAuthenticationSequence method getAuthenticationSteps.

private AuthenticationStep[] getAuthenticationSteps(AuthenticationSequence authSequenceApiModel) {
    if (CollectionUtils.isEmpty(authSequenceApiModel.getSteps())) {
        throw Utils.buildBadRequestError("Authentication steps cannot be empty for user defined " + "authentication type: " + AuthenticationSequence.TypeEnum.USER_DEFINED);
    }
    // Sort the authentication steps.
    List<AuthenticationStepModel> sortedStepModelList = Optional.of(authSequenceApiModel.getSteps()).map(steps -> {
        steps.sort(Comparator.comparingInt(AuthenticationStepModel::getId));
        return steps;
    }).orElse(Collections.emptyList());
    int numSteps = sortedStepModelList.size();
    if (numSteps != sortedStepModelList.get(numSteps - 1).getId()) {
        // to be equal to number of steps.
        throw Utils.buildBadRequestError("Step ids need to be consecutive in the authentication sequence steps.");
    }
    int subjectStepId = getSubjectStepId(authSequenceApiModel.getSubjectStepId(), numSteps);
    int attributeStepId = getSubjectStepId(authSequenceApiModel.getAttributeStepId(), numSteps);
    // We create a array of size (numSteps + 1) since step order starts from 1.
    AuthenticationStep[] authenticationSteps = new AuthenticationStep[numSteps];
    int stepOrder = 1;
    for (AuthenticationStepModel stepModel : sortedStepModelList) {
        AuthenticationStep authenticationStep = buildAuthenticationStep(stepModel);
        authenticationStep.setStepOrder(stepOrder);
        if (subjectStepId == stepOrder) {
            authenticationStep.setSubjectStep(true);
        }
        if (attributeStepId == stepOrder) {
            authenticationStep.setAttributeStep(true);
        }
        authenticationSteps[stepOrder - 1] = authenticationStep;
        stepOrder++;
    }
    return authenticationSteps;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) AuthenticationSequence(org.wso2.carbon.identity.api.server.application.management.v1.AuthenticationSequence) Utils(org.wso2.carbon.identity.api.server.application.management.v1.core.functions.Utils) FrameworkConstants(org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants) RequestPathAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) AuthenticationStep(org.wso2.carbon.identity.application.common.model.AuthenticationStep) FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig) ArrayList(java.util.ArrayList) AuthenticationStepModel(org.wso2.carbon.identity.api.server.application.management.v1.AuthenticationStepModel) AuthenticationScriptConfig(org.wso2.carbon.identity.application.common.model.script.AuthenticationScriptConfig) ApplicationConstants(org.wso2.carbon.identity.application.mgt.ApplicationConstants) List(java.util.List) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig) CollectionUtils(org.apache.commons.collections.CollectionUtils) UpdateFunction(org.wso2.carbon.identity.api.server.application.management.v1.core.functions.UpdateFunction) Optional(java.util.Optional) LocalAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig) Comparator(java.util.Comparator) Collections(java.util.Collections) AuthenticationStepModel(org.wso2.carbon.identity.api.server.application.management.v1.AuthenticationStepModel) AuthenticationStep(org.wso2.carbon.identity.application.common.model.AuthenticationStep)

Example 3 with AuthenticationSequence

use of org.wso2.carbon.identity.api.server.application.management.v1.AuthenticationSequence in project identity-api-server by wso2.

the class ServiceProviderToApiModel method buildAuthenticationSequence.

private AuthenticationSequence buildAuthenticationSequence(ServiceProvider application) {
    LocalAndOutboundAuthenticationConfig authConfig = application.getLocalAndOutBoundAuthenticationConfig();
    AuthenticationSequence.TypeEnum authenticationType = getAuthenticationType(authConfig);
    if (authenticationType == AuthenticationSequence.TypeEnum.DEFAULT) {
        // If this is the default sequence we need to set the default tenant authentication sequence.
        if (log.isDebugEnabled()) {
            log.debug("Authentication type is set to 'DEFAULT'. Reading the authentication sequence from the " + "'default' application and showing the effective authentication sequence for application " + "with id: " + application.getApplicationResourceId());
        }
        authConfig = getDefaultAuthenticationConfig();
    }
    AuthenticationSequence authSequence = new AuthenticationSequence();
    authSequence.setType(authenticationType);
    if (authConfig.getAuthenticationScriptConfig() != null) {
        authSequence.script(authConfig.getAuthenticationScriptConfig().getContent());
    }
    addAuthenticationStepInformation(authConfig, authSequence);
    List<String> requestPathAuthenticators = getRequestPathAuthenticators(application);
    authSequence.setRequestPathAuthenticators(requestPathAuthenticators);
    return authSequence;
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig) AuthenticationSequence(org.wso2.carbon.identity.api.server.application.management.v1.AuthenticationSequence)

Aggregations

LocalAndOutboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig)3 AuthenticationSequence (org.wso2.carbon.identity.api.server.application.management.v1.AuthenticationSequence)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Optional (java.util.Optional)1 CollectionUtils (org.apache.commons.collections.CollectionUtils)1 StringUtils (org.apache.commons.lang.StringUtils)1 AuthenticationStepModel (org.wso2.carbon.identity.api.server.application.management.v1.AuthenticationStepModel)1 UpdateFunction (org.wso2.carbon.identity.api.server.application.management.v1.core.functions.UpdateFunction)1 Utils (org.wso2.carbon.identity.api.server.application.management.v1.core.functions.Utils)1 FrameworkConstants (org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants)1 AuthenticationStep (org.wso2.carbon.identity.application.common.model.AuthenticationStep)1 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)1 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)1 LocalAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig)1 RequestPathAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig)1 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)1 AuthenticationScriptConfig (org.wso2.carbon.identity.application.common.model.script.AuthenticationScriptConfig)1