Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rhino: restrict Java packages that can be accessed from JavaScript

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.

like image 272
Thilo Avatar asked Apr 07 '09 01:04

Thilo


1 Answers

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.

like image 60
Dave Ray Avatar answered Oct 11 '22 20:10

Dave Ray