public class Sandbox extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Sandbox.ClassLoaderSupplier
A Supplier that returns an instance of a ClassLoader to be used
for loading Java classes into the currently-running script.
|
| Constructor and Description |
|---|
Sandbox()
Create a new sandbox that will not affect anything in any way.
|
Sandbox(Sandbox parent)
Create a new sandbox that will copy the parameters from a parent.
|
| Modifier and Type | Method and Description |
|---|---|
ExecutorService |
getAsyncThreadPool() |
Sandbox.ClassLoaderSupplier |
getClassLoaderSupplier()
Returns the ClassLoaderSupplier if set, null otherwise.
|
org.mozilla.javascript.ClassShutter |
getExtraClassShutter() |
String |
getFilesystemRoot() |
List<Map.Entry<String,String>> |
getMounts() |
NetworkPolicy |
getNetworkPolicy() |
OutputStream |
getStderr() |
InputStream |
getStdin() |
OutputStream |
getStdout() |
SubprocessPolicy |
getSubprocessPolicy() |
String |
getWorkingDirectory() |
boolean |
isAllowJarLoading() |
boolean |
isHideOSDetails() |
void |
mount(String prefix,
String target)
Mount a location on the local filesystem at a virtual path.
|
Sandbox |
setAllowJarLoading(boolean allowed)
Allow the use of the "trireme-support" module's "loadJars" method to load JAR files into the
currently-running script.
|
Sandbox |
setAsyncThreadPool(ExecutorService exec)
Set the Executor where any jobs can be run that require a separate thread pool.
|
Sandbox |
setClassLoaderSupplier(Sandbox.ClassLoaderSupplier classLoaderSupplier)
Allows specifying the Supplier that will return an instance of a ClassLoader
that will be used by the "trireme-support" module's "loadJars" method to load JAR files
into the currently-running script.
|
Sandbox |
setExtraClassShutter(org.mozilla.javascript.ClassShutter extraClassShutter)
Attach an extra
ClassShutter that can allow Trireme embedders the ability to expose
extra Java classes to JavaScript code. |
Sandbox |
setFilesystemRoot(String root)
Provide a "chroot"-like facility so that all filenames used by the "fs" module
(not all files used internally by
NodeRunner) must be treated as if the "root" is in a different location.
|
Sandbox |
setHideOSDetails(boolean obscure)
If set to true, hide the internal details returned by the "OS" package.
|
Sandbox |
setNetworkPolicy(NetworkPolicy policy)
Attach an object that will be called every time the process tries to open an outgoing network
connection or listen for incoming connections.
|
Sandbox |
setStderr(OutputStream s)
Set the stream that scripts should use for standard error output.
|
Sandbox |
setStdin(InputStream s)
Set the stream that scripts should use for standard input.
|
Sandbox |
setStdout(OutputStream s)
Set the stream that scripts should use for standard output.
|
Sandbox |
setSubprocessPolicy(SubprocessPolicy policy)
Attach an object that will be called every time the process tries to invoke a sub process, including
"node" itself.
|
Sandbox |
setWorkingDirectory(String wd)
Set the working directory of this script.
|
public Sandbox()
public Sandbox(Sandbox parent)
public Sandbox setFilesystemRoot(String root)
public String getFilesystemRoot()
public void mount(String prefix, String target)
prefix - where to mount, such as "/opt". This must be an absolute path.target - what to mount there, which may be a relative or absolute path.public Sandbox setWorkingDirectory(String wd)
public String getWorkingDirectory()
public Sandbox setStdout(OutputStream s)
public OutputStream getStdout()
public Sandbox setStderr(OutputStream s)
public OutputStream getStderr()
public Sandbox setStdin(InputStream s)
public InputStream getStdin()
public Sandbox setAsyncThreadPool(ExecutorService exec)
public ExecutorService getAsyncThreadPool()
public Sandbox setNetworkPolicy(NetworkPolicy policy)
public NetworkPolicy getNetworkPolicy()
public Sandbox setSubprocessPolicy(SubprocessPolicy policy)
public SubprocessPolicy getSubprocessPolicy()
public Sandbox setHideOSDetails(boolean obscure)
public boolean isHideOSDetails()
public Sandbox setExtraClassShutter(org.mozilla.javascript.ClassShutter extraClassShutter)
ClassShutter that can allow Trireme embedders the ability to expose
extra Java classes to JavaScript code.
WARNING: This must be used with care as passing Java objects disallowed by the default
Trireme ClassShutter can result in unknown consequences.public org.mozilla.javascript.ClassShutter getExtraClassShutter()
public Sandbox setAllowJarLoading(boolean allowed)
public boolean isAllowJarLoading()
public Sandbox setClassLoaderSupplier(Sandbox.ClassLoaderSupplier classLoaderSupplier)
public Sandbox.ClassLoaderSupplier getClassLoaderSupplier()
Copyright © 2016 Apigee Corporation. All Rights Reserved.