use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.SerializableJsFunction 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.SerializableJsFunction 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.SerializableJsFunction in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandler method evaluateHandler.
private Object evaluateHandler(String outcomeName, ShowPromptNode dynamicDecisionNode, AuthenticationContext context, Object stepId) {
SerializableJsFunction fn = dynamicDecisionNode.getHandlerMap().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);
return jsBasedEvaluator.evaluate(context, (jsFunction) -> jsFunction.call(null, stepId, new JsAuthenticationContext(context)));
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.SerializableJsFunction in project identity-conditional-auth-functions by wso2-extensions.
the class PromptIdentifierFunctionImpl method promptIdentifier.
@Override
public void promptIdentifier(int step, Object... parameters) {
Map<String, Object> validators;
if (parameters.length == 2 && parameters[1] instanceof Map) {
validators = (Map<String, Object>) parameters[1];
} else {
validators = new HashMap<>();
}
Map<String, Object> callbacks = null;
if (parameters.length > 0 && parameters[parameters.length - 1] instanceof Map) {
callbacks = (Map<String, Object>) parameters[parameters.length - 1];
}
if (validators.get(ShowPromptNode.PRE_HANDLER) == null) {
validators.put(ShowPromptNode.PRE_HANDLER, new SerializableJsFunction(DEFAULT_PRE_HANDLER_FUNC, true));
}
Map<String, Object> promptParameters = new HashMap<>();
promptParameters.put(STEP_PARAM, step);
JsGraphBuilder.addPrompt(IDENTIFIER_TEMPLATE_NAME, promptParameters, validators, callbacks);
}
Aggregations