admin管理员组

文章数量:1277885

When embedding a JavaScript interpreter (Rhino) into a Java application (to be able to script that application), how would one go about restricting the Java packages that are available to scripts? For example, only "java.lang.*" should be accessible.

When embedding a JavaScript interpreter (Rhino) into a Java application (to be able to script that application), how would one go about restricting the Java packages that are available to scripts? For example, only "java.lang.*" should be accessible.

Share Improve this question edited Apr 11, 2009 at 7:16 womp 117k26 gold badges239 silver badges271 bronze badges asked Apr 7, 2009 at 1:41 ThiloThilo 263k105 gold badges522 silver badges671 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

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

how about just saying:

java = undefined; = undefined; Packages = undefined;

in an initial script which is loaded first.

本文标签: Rhino restrict Java packages that can be accessed from JavaScriptStack Overflow