Rhino: restrict Java packages that can be accessed from JavaScript.

When embedding a JavaScript interpreter (Rhino) in a Java application (to be able to script this application), how can you limit yourself to restricting the Java packages available to scripts? For example, only "java.lang. *" Should be available.

+11
java javascript scripting sandbox rhino
Apr 7 '09 at 1:41
source share
2 answers

The method of blocking access to certain packages and classes (including through reflection) in Rhino is described here . An important interface is ClassShutter , which provides access control to support Rhino LiveConnect.

+8
Apr 07 '09 at 1:48
source share

what about just saying:

java = undefined; com = undefined; Packages = undefined;

in the initial script that is loaded first.

+1
Mar 15 2018-11-15T00:
source share



All Articles