I am using javax.scripting
to add support for running arbitrary user-uploaded JavaScripts on the server-side. Obviously I want to secure those scripts!
Rhino, on it's own, has a framework for securing scripts at runtime. The documentation for javax.scripting
, however, doesn't mention security, permissions or restricting classes available to the script. So is this just a huge hole in the javax.scripting
API that it doesn't offer a framework to secure scripts it executes?
I don't want to use Rhino directly because I originally tried that but had some problems exposing Java instances to the running script. The javax.scripting
framework made it (which uses Rhino under the hood) made this trivial and also simplified running scripts in a multi-threaded server.
I would like to white-list Java classes that can be accessed/instantiated within the running script. Can anyone point me to an example or documentation on how to achieve this?