问题
I just embedded Groovy in my application and wondering if it's possible to restrict access to some APIs i.e. java.io.File, java.net.URL, etc
Or instead of completely restricting java.io.File access, I want to ONLY allow access to certain directories on the machine.
Any guidance is greatly appreciated!
回答1:
Use the Java Security Manager. Refer this answer for an example.
回答2:
Have you looked at Java security and the policy file ? I suspect setting FilePermission will do what you want.
来源:https://stackoverflow.com/questions/3079998/restrict-some-api-in-embedded-groovy