• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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

 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 293
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic