views:

47

answers:

2

Hello,

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  A: 

Have you looked at Java security and the policy file ? I suspect setting FilePermission will do what you want.

Brian Agnew
a quick look at the link shows that I can "grant" permission to a file directory. However, is it possible to "ungrant" permission?
hishboy
+2  A: 

Use the Java Security Manager. Refer this answer for an example.

instantsetsuna