Restrict some API in Embedded Groovy

痴心易碎 提交于 2019-12-08 05:11:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!