1

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!

ataylor
  • 62,796
  • 20
  • 153
  • 185
hishboy
  • 239
  • 2
  • 10

2 Answers2

2

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

Community
  • 1
  • 1
instantsetsuna
  • 8,713
  • 7
  • 23
  • 28
1

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

Brian Agnew
  • 261,477
  • 36
  • 323
  • 432
  • a quick look at the link shows that I can "grant" permission to a file directory. However, is it possible to "ungrant" permission? – hishboy Jun 21 '10 at 20:34