After doing some research, I am beginning to believe that this should work the 
way I have described.  Here is my evidence:

In section 4.5.2 of the EJB 3.0 spec (EJBCore) the operations allowed in 
methods of a stateless session bean are defined, and the IllegalStateException 
is to be thrown if these rules are broken.  It states that a call to 
EJBContext's .getCallerPrincipal() method is allowed from any business method 
in the session bean.  I am calling getCallerPrincipal from a business method so 
therefore should not be getting an illegalStateException.

Also, in the EJB Container Provider's Responsibilities, section 16.6.5 states 
that 

"The EJB container must provide access to the caller?s security context 
information from the enterprise
beans? instances via the getCallerPrincipal()" 
and also 

"If the security identity of the caller has not been established, the container
returns the container?s representation of the unauthenticated identity."

Now, since I am calling the method from a valid location, I should be getting 
back the user principal, or a default user principal if I have not logged in.

Earlier it was mentioned that I needed to set the caller identity via 
LoginContext.  I guess my questions come down to this:  

#1 Why do I need to do this?  I am using j_security_check through form 
authentication and from what I have read, jboss automatically sets up a 
LoginContext when this is done, also it is not mentioned in the spec that I 
need  LoginContext in order to call getCallerPrincipal().

#2 How do I go about setting up the caller identity in LoginContext, especially 
if all of the authentication is handled by JBoss through j_security_check.  
Every document I've found on the subject shows me how to take the user's input 
of the username and password then basically do a login using callbackhandlers 
and a whole bunch of other stuff that I have never seen.

I guess what I'm getting at is that there has to be an easier way to do this, 
it's hard to believe that something like this got harder to do between EJB 2.1 
and EJB 3.0, which has simplified things in so many other ways.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3928611#3928611

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3928611


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to