• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SecurityManager with custom thread groups

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I would like to have an architecture where certain threads (and threads created by them) cannot access other threads and thread groups outside their own. More specifically, if I have thread A in thread group AG, the thread should be able to create thread groups A1G, A2G... if those are children of AG. It should also be able to create threads in them. However, it should not be able to access any other thread groups.

I figured I would create a CustomThreadGroup class for AG, and use a SecurityManager to check permissions. The overwritten checkaccess method looks like this:

, where getCustomAncestor returns the uppermost CustomThreadGroup in the thread group tree (or null).

The problem with this is, that in getCustomAncestor, I have to call the getParent() method of the thread group. This, however, results in another checkAccess() call, and that in another getCustomAncestor, resulting in a StackOverflowError.

My question would be:
How to prevent the recursivity? I thought about creating a thread in the SecurityManager (private Thread class), that can access both groups, but isn't it an overkill to such a problem? Isn't there a simpler (API) way?

Thanks,
David
[ June 15, 2008: Message edited by: David Nemeskey ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic