...
Code Block | ||
---|---|---|
| ||
class ACC { private static class RestrictedAccessControlContext { private static final AccessControlContext INSTANCE; static { INSTANCE = new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, null) // noNo permissions }); } } // Restrict permission using the two-argument form of doPrivileged() try { AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws ScriptException { engine.eval("print('"+ firstName + "')"); return null; } }, RestrictedAccessControlContext.INSTANCE); // From nested class } catch(PrivilegedActionException pae) { // Handle } |
...