use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.EndStep in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandler method executeFunction.
private void executeFunction(String outcomeName, DynamicDecisionNode dynamicDecisionNode, AuthenticationContext context, Map<String, Object> data) {
SerializableJsFunction fn = dynamicDecisionNode.getFunctionMap().get(outcomeName);
FrameworkServiceDataHolder dataHolder = FrameworkServiceDataHolder.getInstance();
JsGraphBuilderFactory jsGraphBuilderFactory = dataHolder.getJsGraphBuilderFactory();
JsGraphBuilder jsGraphBuilder = jsGraphBuilderFactory.createBuilder(context, context.getSequenceConfig().getAuthenticationGraph().getStepMap(), dynamicDecisionNode);
JsGraphBuilder.JsBasedEvaluator jsBasedEvaluator = jsGraphBuilder.new JsBasedEvaluator(fn);
jsBasedEvaluator.evaluate(context, (jsConsumer) -> jsConsumer.call(null, new JsAuthenticationContext(context), new JsWritableParameters(data)));
if (dynamicDecisionNode.getDefaultEdge() == null) {
dynamicDecisionNode.setDefaultEdge(new EndStep());
}
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.EndStep in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandler method gotoToNextNode.
private void gotoToNextNode(AuthenticationContext context, SequenceConfig sequenceConfig, AuthGraphNode currentNode) {
AuthGraphNode nextNode = null;
if (currentNode instanceof StepConfigGraphNode) {
nextNode = ((StepConfigGraphNode) currentNode).getNext();
}
if (nextNode == null) {
if (log.isDebugEnabled()) {
log.debug("No Next node found for the current graph node : " + currentNode.getName() + ", Service Provider: " + context.getServiceProviderName() + " . Ending the authentication flow.");
}
nextNode = new EndStep();
}
context.setProperty(FrameworkConstants.JSAttributes.PROP_CURRENT_NODE, nextNode);
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.EndStep in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandler method modifyCurrentNodeAsFirstStep.
private void modifyCurrentNodeAsFirstStep(AuthenticationContext context) {
context.removeProperty(BACK_TO_FIRST_STEP);
if (context.getProperty(PROP_CURRENT_NODE) != null) {
// Identifier first should be the first step. Other steps will be determine dynamically.
int size = context.getSequenceConfig().getStepMap().size();
for (int i = 2; i <= size; i++) {
context.getSequenceConfig().getStepMap().remove(i);
}
context.getSequenceConfig().setCompleted(false);
context.setProperty(PROP_CURRENT_NODE, null);
AuthGraphNode startNode = context.getSequenceConfig().getAuthenticationGraph().getStartNode();
if (startNode instanceof StepConfigGraphNode) {
((StepConfigGraphNode) startNode).getStepConfig().setCompleted(false);
((StepConfigGraphNode) startNode).getStepConfig().setAuthenticatedAutenticator(null);
((StepConfigGraphNode) startNode).getStepConfig().setAuthenticatedUser(null);
if (((StepConfigGraphNode) startNode).getNext() instanceof DynamicDecisionNode) {
((DynamicDecisionNode) ((StepConfigGraphNode) startNode).getNext()).setDefaultEdge(new EndStep());
}
}
if (log.isDebugEnabled()) {
log.debug("Modified current node a parent node which can restart authentication flow" + " from first step.");
}
}
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.EndStep in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandler method executeFunction.
private void executeFunction(String outcomeName, DynamicDecisionNode dynamicDecisionNode, AuthenticationContext context) {
SerializableJsFunction fn = dynamicDecisionNode.getFunctionMap().get(outcomeName);
FrameworkServiceDataHolder dataHolder = FrameworkServiceDataHolder.getInstance();
JsGraphBuilderFactory jsGraphBuilderFactory = dataHolder.getJsGraphBuilderFactory();
JsGraphBuilder graphBuilder = jsGraphBuilderFactory.createBuilder(context, context.getSequenceConfig().getAuthenticationGraph().getStepMap(), dynamicDecisionNode);
JsGraphBuilder.JsBasedEvaluator jsBasedEvaluator = graphBuilder.new JsBasedEvaluator(fn);
jsBasedEvaluator.evaluate(context, (jsConsumer) -> jsConsumer.call(null, new JsAuthenticationContext(context)));
if (dynamicDecisionNode.getDefaultEdge() == null) {
dynamicDecisionNode.setDefaultEdge(new EndStep());
}
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.EndStep in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandler method handleDecisionPoint.
private void handleDecisionPoint(HttpServletRequest request, HttpServletResponse response, AuthenticationContext context, SequenceConfig sequenceConfig, DynamicDecisionNode dynamicDecisionNode) throws FrameworkException {
if (dynamicDecisionNode == null) {
log.error("Dynamic decision node is null");
return;
}
AuthenticatorFlowStatus flowStatus = (AuthenticatorFlowStatus) request.getAttribute(FrameworkConstants.RequestParams.FLOW_STATUS);
if (flowStatus != null) {
switch(flowStatus) {
case SUCCESS_COMPLETED:
executeFunction("onSuccess", dynamicDecisionNode, context);
break;
case FAIL_COMPLETED:
if (dynamicDecisionNode.getFunctionMap().get("onFail") != null) {
executeFunction("onFail", dynamicDecisionNode, context);
} else {
if (context.isRetrying()) {
AuthGraphNode nextNode = dynamicDecisionNode.getParent();
context.setProperty(FrameworkConstants.JSAttributes.PROP_CURRENT_NODE, nextNode);
return;
}
}
if (dynamicDecisionNode.getDefaultEdge() instanceof EndStep) {
dynamicDecisionNode.setDefaultEdge(new FailNode());
}
break;
case FALLBACK:
executeFunction("onFallback", dynamicDecisionNode, context);
break;
case USER_ABORT:
executeFunction("onUserAbort", dynamicDecisionNode, context);
break;
}
}
AuthGraphNode nextNode = dynamicDecisionNode.getDefaultEdge();
context.setProperty(FrameworkConstants.JSAttributes.PROP_CURRENT_NODE, nextNode);
}
Aggregations