views:

103

answers:

1

I have various EJBs on a J2EE-server, with different security roles.

Now, from a Java Swing client application, when I log the user on to the server, I would like to discover which of these EJBs that are accessible to the user, without actually trying to create them or invoke them.

The reason I want to do this is to adjust the user interface depending on which EJBs are available.

For instance, if the "AdministerMetadata" EJB is usable by the current user, I want to display a menu option for administering metadata etc.

It is acceptable for me to query from a predefined list of known EJBs within the client, so I dont need it to be totally dynamic that way.

I dont want to create a special EJB to just return this access-information, and I want to avoid having to try to call methods and catch Exceptions to do the discovery.

I am planning on using the solution on JBoss, but would prefer a standard solution if possible.

Is this possible? If so how?

+1  A: 

As far as I know there is nothing in J2EE which would provide you this information at the client side. Even at the server side EJBContext will give you just the roles the caller owns as well as the caller's principal (e.g. login name).

I see no other way than to have an extra Session Bean which you can query on the client side and which will inspect the EJBContext on the server side to tell the client which roles the current user owns.

ordnungswidrig
Thanks! I guess I could resort to the "try to create the EJB and handle the exception" way of discovering what EJBs are accessible (although that won't tell me anything about method-specific access restrictions)
Brummo