I'm developing an eclipse based application capable to execute third party component (not eclipse-plugin).
Each component has a custom descriptor, where are listed permissions (with correspondent motivation). In this way final user can decide if execute it or not.
Components are executed in separated threads. How can I restrict permissions to these threads according with the descriptor, without restrict entire application?
Thanks
First of all, you should turn on the Security Manager. Then create an AccessControlContext with the desired permissions. (No permissions in my example.) Finally execute the third party code in the AccessController.doPrivileged(...) method.
This is a very simple solution:
Testing the SafeRunnable:
First thread prints Hello, the second throws
AccessControlException: access denied ("java.lang.RuntimePermission" "exitVM.0")