Class Sandbox

java.lang.Object
org.codehaus.commons.compiler.Sandbox

public final class Sandbox extends Object
Executes a PrivilegedAction or PrivilegedExceptionAction in a context with restricted permissions. This is useful for executing "untrusted" code, e.g. user-provided expressions or scripts that were compiled with JANINO.

Code example:

     Permissions noPermissions = new Permissions();
     Sandbox sandbox = new Sandbox(noPermissions);
     sandbox.confine(new PrivilegedExceptionAction<Object>() {
         @Override public Object run() throws Exception { new java.io.File("xxx").delete(); return null; }
     });
 
See Also: