Skip to content

Commit

Permalink
Load promiseJS indirectly from classpath (frankframework#2058)
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsm5 authored Jul 23, 2021
1 parent c7f8069 commit 3180d3e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package nl.nn.adapterframework.extensions.javascript;

import java.net.URL;
import java.util.function.Consumer;

import javax.script.Invocable;
Expand All @@ -27,6 +28,8 @@
import nl.nn.adapterframework.core.PipeLineSession;
import nl.nn.adapterframework.extensions.graphviz.ResultHandler;
import nl.nn.adapterframework.stream.Message;
import nl.nn.adapterframework.util.ClassUtils;
import nl.nn.adapterframework.util.Misc;

public class Nashorn implements JavascriptEngine<ScriptEngine> {

Expand All @@ -48,7 +51,9 @@ public void startRuntime() throws JavascriptException {
try {
engine = engineManager.getEngineByName("nashorn");

engine.eval("load('classpath:net/arnx/nashorn/lib/promise.js')");
//Add PromiseJS polyfill
URL promise = ClassUtils.getResourceURL("net/arnx/nashorn/lib/promise.js");
executeScript(Misc.resourceToString(promise));
} catch (Exception e) { //Catch all exceptions
throw new JavascriptException("error initializing Nashorn, unable to load Promise.js", e);
}
Expand Down
13 changes: 9 additions & 4 deletions ear/src/main/application/META-INF/was.policy
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ permission java.lang.RuntimePermission "getFileSystemAttributes";

// required to read the ibm-application-bnd.xmi from within the Ibis Console
permission java.io.FilePermission "${was.install.root}${/}profiles${/}${current.node.name}${/}config${/}cells${/}${current.cell.name}${/}applications${/}-", "read";
//permission java.io.FilePermission "${was.install.root}${/}profiles${/}${current.node.name}${/}config${/}cells${/}${current.cell.name}${/}applications${/}${APPLICATION_NAME}.ear${/}deployments${/}${APPLICATION_NAME}${/}META-INF${/}ibm-application-bnd.xmi", "read";
// required to read the resources.xml from within the Ibis Console
permission java.io.FilePermission "${was.install.root}${/}profiles${/}${current.node.name}${/}config${/}cells${/}${current.cell.name}${/}nodes${/}-", "read";
permission java.io.FilePermission "${was.install.root}${/}profiles${/}${current.node.name}${/}config${/}cells${/}${current.cell.name}${/}nodes${/}${current.node.name}${/}servers${/}${current.server.name}${/}resources.xml", "read";

permission java.util.logging.LoggingPermission "control";

Expand Down Expand Up @@ -67,6 +68,7 @@ permission java.util.PropertyPermission "*", "write";
// required to for CredentialFactory to obtain credentials from JAAS Authentication Entries:
permission javax.security.auth.AuthPermission "createLoginContext.DefaultPrincipalMapping";
permission javax.security.auth.PrivateCredentialPermission "javax.resource.spi.security.PasswordCredential nl.nn.credentialprovider.WebSphereCredentials$FrankPrincipal "Frank"", "read";
permission javax.security.auth.PrivateCredentialPermission "javax.resource.spi.security.PasswordCredential nl.nn.adapterframework.util.CredentialFactory$IbisPrincipal "Ibis"", "read"; // for 7.6 compatiblity

// required for Spring AbstractAutowireCapableBeanFactory:
permission java.lang.RuntimePermission "getProtectionDomain";
Expand All @@ -89,8 +91,9 @@ permission java.lang.RuntimePermission "accessClassInPackage.sun.io";

permission java.lang.RuntimePermission "accessClassInPackage.com.ibm.oti.shared";

// required for nashhorn
// required for the Nashorn javascript engine
permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.dynalink.support";
permission java.lang.RuntimePermission "accessClassInPackage.jdk.nashorn.internal.runtime";
permission java.lang.RuntimePermission "accessClassInPackage.jdk.nashorn.internal.runtime.*";

// required for MS SQL:
Expand Down Expand Up @@ -164,10 +167,12 @@ permission java.io.FilePermission "/usr/share/fonts/-", "read";
// required for ladybug retrieving userprincipal
permission java.security.SecurityPermission "printIdentity";

// required for Log4j
permission java.lang.RuntimePermission "createSecurityManager"; // for stacktrace rendering and JavaAssist PipeLineSessionDebugger proxying
// required for Log4J stacktrace rendering and JavaAssist PipeLineSessionDebugger proxying
permission java.lang.RuntimePermission "createSecurityManager";
// required for Log4J
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.fs";

// required for CXF
permission java.lang.RuntimePermission "shutdownHooks";

};

0 comments on commit 3180d3e

Please sign in to comment.