views:

350

answers:

2

Hello, I have a program that is running a basic RMISecurityManager in all its threads. But I would like to do more control to several threads and set another SecurityManager specially for these threads.

How can I do that ? ...if this is possible !?

thank you by advance.

Edit : I have found my solution. See here for more details.

+1  A: 

Hi,

The SecurityManager performs checks based on the security context of the running thread, perhaps you want to make your SecurityManager to behave differently based on whatever it finds in the context?

Or maybe, you want to implement your SecurityManager using the strategy pattern.

yc

yclian
+2  A: 

It doesn't make a great deal of sense. What if code (malicious or not) causes execution on a different thread? This can even happen within the Java library, with security context transferred (which may use java.security.AccessController.getContext/doPrivileged).

Applets do use a slightly difficult system involving ThreadGroups, but I wouldn't recommend it. JAAS allows a Subject to be added to the AccessControlContext, but personally I'd suggest not using this style of programming.

Give downloaded code (if any) appropriate permissions, and don't give sensitive objects to code you don't trust with them.

Tom Hawtin - tackline
In fact we got an architectural problem. Our app' is running with root's privileges and creates one thread per task.This task has to have specific rights according to a user.
Le Barde
The solution we took has been to extend a RMISecurityManager and use JNI. That works well with a ThreadLocal variable. But the problem is, it doesn't work with automatically-created threads, like those created when you create sockets.
Le Barde
For that I would like a securityManager for everything, and one for the threads' tasks... if that was possible...
Le Barde