How do I set the SecurityManager for this thread and not for System?

I have a program that runs the basic RMISecurityManager on all of its threads. But I would like to do more control over multiple threads and install a different SecurityManager specifically for those threads.

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

thank you in advance.

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

+1


source to share


2 answers


It doesn't make a lot of sense. What if the code (malicious or not) causes execution on a different thread? This can even happen in a Java library with a passed security context (which can use java.security.AccessController.getContext

/ doPrivileged

).

Applets use a slightly complex system involving ThreadGroup

s, but I wouldn't recommend it. JAAS allows adding Subject

to AccessControlContext

, but personally I would suggest not using this programming style.



Give the loaded code (if any) the appropriate permissions and don't give sensitive objects to code you don't trust.

+4


source


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

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



YC

+2


source







All Articles