• 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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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

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?

[ June 15, 2008: Message edited by: David Nemeskey ]
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic