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
  • 64,891
  • 24
  • 161
  • 189
hishboy
  • 339
  • 2
  • 10

2 Answers2

2

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

Community
  • 1
  • 1
instantsetsuna
  • 9,183
  • 8
  • 25
  • 28
1

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

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
  • 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