Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enforcing Security Permissions

 
Yohan Liyanage
Ranch Hand
Posts: 132
Eclipse IDE Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am building a distributed system where class files are downloaded from remote machines and executed locally. I use a custom ClassLoader implementation to retrieve necessary classes.

However, I want to ensure that the remote code which is executed locally is not allowed to use files, invoke System.exit()... etc. In other words, I want to ensure that the remote code is executed in a sandbox.

Also, I need t ensure that the rest of the application is not affected by these limitations.

If I am to use a SecurityManager and a policy file, how can I ensure that only the code remotely loaded by my class loader is limited from permissions ?

Any suggestions to solve this issue is greatly appreciated.

Thanks.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I may plug my own stuff, this article describes how to use a classloader in conjunction with a security manager to restrict the loaded classes from certain operations. Source code is included.
 
Yohan Liyanage
Ranch Hand
Posts: 132
Eclipse IDE Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the reply Ulf .

I looked into the code, but found some methods are deprecated now, and I couldn't find an alternative way to get the code working without those methods (JavaDoc says to use checkPermission but I couldn't find out how that could be helpful to find which classloader loaded the class).

Finally, I got it working using policy files.

Here's what I did:


In my ClassLoader, I used the "http://my.remote.loaded.code.base" as the CodeSource when I defined my classes.

Code Base "file:/-" matches with rest of the classes, which are loaded from the file system.

So this way, I got my remote code running in a sandbox.
[ August 01, 2008: Message edited by: Yohan Liyanage ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic