• Post Reply Bookmark Topic Watch Topic
  • New Topic

Does a stateless session bean have access to the User Principal?

 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Can a method of a stateless session bean know which user calls it? If not, how about a stateful session bean? What I'm looking for is the username (Principal) specified during the JNDI lookup of the context used to retrieve the home interface.

Thank you,
Yuriy
 
Dave Salter
Ranch Hand
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can do this from a Statefull and a Stateless session bean.

Have a look at SessionContext.getCallerPrincipal()
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dave!

So if 10 different users use the same bean's remote interface to concurrently call business methods, sessionContext.getCallerPrincipal() will return the correct value inside each user's call?

Thank you,
Yuriy
 
Dave Salter
Ranch Hand
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats right. Each user will get an instance of the stateless session bean from a pool and the method will return the correct principal for each one.
[ September 16, 2005: Message edited by: Dave Salter ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!