Security Issue with Java ScriptEngine

I just started using Java ScriptEngine to make small extensions for my application, then I noticed that I can import all java classes into a script and use them without restrictions. Is there a way to indicate which classes a script can use? I donโ€™t want them to do things likejava.lang.System.exit(1);

+5
source share
3 answers

Well, you seem to need to learn about the Java SecurityManager. This is a pretty big topic, you can read it, and then post a more specific question if you have problems with its work.

+2
source

Java. .

+1

I solved this by putting "importPackage = null" on top of all the scripts, it seems to work, but I'm not sure that this hack can be avoided.

+1
source

All Articles