Re: Updating subject while service is deployed
Mark Brouwer <[email protected]>
| Newsgroups | gmane.comp.java.sun.jini |
|---|---|
| Message-ID | <[email protected]> |
Bob Scheifler wrote: >> Looking into the source code of Subject I don't >> dare to modify the set of principals due to concurrency issues. If I add >> a principal and at the same time some of the code in the Jini ERI stack >> iterates over the set op principals a ConcurrentModificationException is >> not that far away. > > The sets returned by Subject are synchronized collections, and JERI code > synchronizes on the set while iterating, so that CME is avoided. I wouldn't call them synchronized sets as many operations are not synchronized and rely on AbstractSet. Given the fact Subject doesn't provide any hints with regard to synchronization I'm not feeling comfortable with modifying the Subject and some investigation shows there are several places where a CME can pop-up, e.g. SubjectDomainCombiner.combine performs no synchronization on the sets it obtains, the same applies to the KeyStoreLoginModule. From what I've seen I don't think there is a real performance penalty with a mutable Subject, the whole checkAccess stuff is already that heavy so iterating over the principals to see whether the sets have changed doesn't seem that much extra. But I'll just filed a bug against Java SE as I'm of the opinion Subject is underspecified with regard to concurrency and can already result in CMEs with the current Sun JRE. >> However I think there is another place where I >> could replace the subject. I already have my own implementation of >> SecurityContextSource so I'm in control of the SecurityContext that >> returns the access control context and I could calculate a new acc when >> I need a 'modified' Subject and attach that to the SecurityContext. > > That seems like it could work for the parts of the system that traffic > in SecurityContexts, but not for anything that just traffics in > access control contexts. Indeed and I guess it is quite normal to have threads (with an 'old' inherited AccessControlContext) performing remote method invocations for which you want the new principals to be available too, so it doesn't seem the right path to follow. -- Mark -------------------------------------------------------------------------- Getting Started: http://www.jini.org/wiki/Category:Getting_Started Community Web Site: http://jini.org jini-users Archive: http://archives.java.sun.com/archives/jini-users.html Unsubscribing: email "signoff JINI-USERS" to [email protected]