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