Skip to content

Commit

Permalink
Add changes due to new generic interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
shanggeeth committed Mar 6, 2024
1 parent 001e009 commit d21b180
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Object> promptParameters = new HashMap<>();
promptParameters.put(STEP_PARAM, step);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit d21b180

Please sign in to comment.