What's wrong with the obvious solution of adding method parameters?
Thanks for the reply Stephen,
Let me tell you the actual problem, i want to get the user name from remote client without using the security principal or configuring security domain in ejb using jboss-ejb3.xml.
As you said i could have taken the user name from the method parameters, the problem is i need the user name for audit purpose and am using hibernate envers for that.
The RevisionEntity class of hibernate envers should be able to get the same user name from the context.
RevisionListener class which will be invoked by hibernate looks some thing like this:
public class ExampleListener implements RevisionListener
public void newRevision(Object revisionEntity)
ExampleRevEntity exampleRevEntity = (ExampleRevEntity) revisionEntity;
Can you please give me some idea on implementing this use case.
If it were me I'd configure security properly and then inject the current javax.security.Principal where needed.
If you don't want to do this then you could still pass the username as a parameter and then stash it in a ThreadLocal in your session bean. The listener can subsequently recover it from the ThreadLocal. Don't forget to clear it in a finally block after stashing it!
Thank u very much for the suggession stephen, the solution is perfectly working fine in my scenario.