diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.test.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/test/utils/sequence/JsSequenceHandlerRunner.java b/components/org.wso2.carbon.identity.conditional.auth.functions.test.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/test/utils/sequence/JsSequenceHandlerRunner.java index 806fc6c2..544ce07d 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.test.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/test/utils/sequence/JsSequenceHandlerRunner.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.test.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/test/utils/sequence/JsSequenceHandlerRunner.java @@ -30,6 +30,7 @@ import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JSExecutionSupervisor; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsBaseGraphBuilderFactory; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsGenericGraphBuilderFactory; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsGraphBuilderFactory; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsWrapperFactory; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsWrapperFactoryProvider; @@ -97,7 +98,7 @@ public class JsSequenceHandlerRunner { protected GraphBasedSequenceHandler graphBasedSequenceHandler = new GraphBasedSequenceHandler(); protected UIBasedConfigurationLoader configurationLoader; - protected JsBaseGraphBuilderFactory graphBuilderFactory; + protected JsGenericGraphBuilderFactory graphBuilderFactory; protected JSExecutionSupervisor jsExecutionSupervisor; private JsFunctionRegistryImpl jsFunctionRegistry; @@ -126,7 +127,7 @@ public void init(URL applicationAuthenticatorConfigFileLocation, String scriptEn FrameworkServiceDataHolder.getInstance().setJsExecutionSupervisor(jsExecutionSupervisor); graphBuilderFactory.init(); - FrameworkServiceDataHolder.getInstance().setJsGraphBuilderFactory(graphBuilderFactory); + FrameworkServiceDataHolder.getInstance().setJsGenericGraphBuilderFactory(graphBuilderFactory); Field wrapperFactory = JsWrapperFactoryProvider.class.getDeclaredField("jsWrapperBaseFactory"); wrapperFactory.setAccessible(true); diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/PromptIdentifierFunctionImpl.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/PromptIdentifierFunctionImpl.java index bb03319f..7fd4ad2b 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/PromptIdentifierFunctionImpl.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/PromptIdentifierFunctionImpl.java @@ -22,6 +22,7 @@ import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsGraphBuilder; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.SerializableJsFunction; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.ShowPromptNode; +import org.wso2.carbon.identity.conditional.auth.functions.user.model.JsWrapperFactoryProvider; import java.util.HashMap; import java.util.Map; @@ -50,7 +51,8 @@ public void promptIdentifier(int step, Object... parameters) { } if (validators.get(ShowPromptNode.PRE_HANDLER) == null) { - validators.put(ShowPromptNode.PRE_HANDLER, new SerializableJsFunction(DEFAULT_PRE_HANDLER_FUNC, true)); + validators.put(ShowPromptNode.PRE_HANDLER, JsWrapperFactoryProvider.getInstance() + .getWrapperFactory().createJsSerializableFunction(DEFAULT_PRE_HANDLER_FUNC, true)); } Map promptParameters = new HashMap<>(); promptParameters.put(STEP_PARAM, step); diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsGraalWrapperFactory.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsGraalWrapperFactory.java index 91ead611..a85742fb 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsGraalWrapperFactory.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsGraalWrapperFactory.java @@ -18,6 +18,7 @@ package org.wso2.carbon.identity.conditional.auth.functions.user.model; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.graaljs.GraalSerializableJsFunction; import org.wso2.carbon.identity.application.authentication.framework.model.Application; import org.wso2.carbon.identity.application.authentication.framework.model.UserSession; import org.wso2.carbon.identity.conditional.auth.functions.user.model.graaljs.JsGraalApplication; @@ -40,4 +41,9 @@ public JsApplication createJsApplication(Application application) { return new JsGraalApplication(application); } + + public GraalSerializableJsFunction createJsSerializableFunction(String source, boolean isFunction) { + + return new GraalSerializableJsFunction(source, isFunction); + } } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsOpenJdkNashornWrapperFactory.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsOpenJdkNashornWrapperFactory.java index ed32d27a..f9857edb 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsOpenJdkNashornWrapperFactory.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsOpenJdkNashornWrapperFactory.java @@ -18,6 +18,7 @@ package org.wso2.carbon.identity.conditional.auth.functions.user.model; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.openjdk.nashorn.OpenJdkNashornSerializableJsFunction; import org.wso2.carbon.identity.application.authentication.framework.model.Application; import org.wso2.carbon.identity.application.authentication.framework.model.UserSession; import org.wso2.carbon.identity.conditional.auth.functions.user.model.openjdk.nashorn.JsOpenJdkNashornApplication; @@ -37,6 +38,12 @@ public JsUserSession createJsUserSession(UserSession userSession) { @Override public JsApplication createJsApplication(Application application) { + return new JsOpenJdkNashornApplication(application); } + + public OpenJdkNashornSerializableJsFunction createJsSerializableFunction(String source, boolean isFunction) { + + return new OpenJdkNashornSerializableJsFunction(source, isFunction); + } } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsWrapperBaseFactory.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsWrapperBaseFactory.java index 29753b43..4edc3cc4 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsWrapperBaseFactory.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsWrapperBaseFactory.java @@ -18,6 +18,7 @@ package org.wso2.carbon.identity.conditional.auth.functions.user.model; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.GenericSerializableJsFunction; import org.wso2.carbon.identity.application.authentication.framework.model.Application; import org.wso2.carbon.identity.application.authentication.framework.model.UserSession; @@ -39,4 +40,13 @@ public interface JsWrapperBaseFactory { * @return Proxy for Application */ JsApplication createJsApplication(Application application); + + /** + * Creates a Serializable Javascript function. + * + * @param source - Source of the function + * @param isFunction - Is the source a function + * @return Serializable Javascript function + */ + GenericSerializableJsFunction createJsSerializableFunction(String source, boolean isFunction); } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsWrapperFactory.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsWrapperFactory.java index aa950441..229eb3c3 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsWrapperFactory.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsWrapperFactory.java @@ -18,6 +18,7 @@ package org.wso2.carbon.identity.conditional.auth.functions.user.model; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.SerializableJsFunction; import org.wso2.carbon.identity.application.authentication.framework.model.Application; import org.wso2.carbon.identity.application.authentication.framework.model.UserSession; import org.wso2.carbon.identity.conditional.auth.functions.user.model.nashorn.JsNashornApplication; @@ -36,4 +37,9 @@ public JsUserSession createJsUserSession(UserSession userSession) { public JsApplication createJsApplication(Application application) { return new JsNashornApplication(application); } + + public SerializableJsFunction createJsSerializableFunction(String source, boolean isFunction) { + + return new SerializableJsFunction(source, isFunction); + } } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsWrapperFactoryProvider.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsWrapperFactoryProvider.java index fbd37dc3..c6e35ec4 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsWrapperFactoryProvider.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsWrapperFactoryProvider.java @@ -18,8 +18,7 @@ package org.wso2.carbon.identity.conditional.auth.functions.user.model; -import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsBaseGraphBuilderFactory; -import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsGraphBuilderFactory; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsGenericGraphBuilderFactory; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.graaljs.JsGraalGraphBuilderFactory; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.openjdk.nashorn.JsOpenJdkNashornGraphBuilderFactory; import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkUtils; @@ -35,7 +34,7 @@ public class JsWrapperFactoryProvider { private JsWrapperFactoryProvider() { - JsBaseGraphBuilderFactory jsGraphBuilderFactory = FrameworkUtils.createJsGraphBuilderFactoryFromConfig(); + JsGenericGraphBuilderFactory jsGraphBuilderFactory = FrameworkUtils.createJsGraphBuilderFactoryFromConfig(); if (jsGraphBuilderFactory instanceof JsOpenJdkNashornGraphBuilderFactory) { jsWrapperBaseFactory = new JsOpenJdkNashornWrapperFactory(); } else if (jsGraphBuilderFactory instanceof JsGraalGraphBuilderFactory) {