You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Kory Markevich <Ko...@ACL.com> on 2008/11/26 01:31:30 UTC
getCallerPrincipal in @PostConstruct
I'm trying to call getCallerPrincipal in a method annotated with
PostConstruct on a stateful session bean. I'm using whatever version of
OpenEJB was used in Geronimo 2.1.2. From what I can tell reading the
ejbcore spec (4.4.1) this call is legal, and sure enough it doesn't throw an
exception. However the principal being returned is an un-authenticated stub
rather than the actual user. When debugging this I noticed most of the code
was actually from Geronimo rather than OpenEJB, so I'm not sure which
project I should be asking this on. Should the principal being returned be
the actual client of the bean, or is this a legal interpretation? Is this
behaviour determined by OpenEJB or Geronimo?
Someone using JBoss had the same question, but not official answer:
http://forums.sun.com/thread.jspa?threadID=5291168
Thanks!
--
View this message in context: http://www.nabble.com/getCallerPrincipal-in-%40PostConstruct-tp20692570p20692570.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: getCallerPrincipal in @PostConstruct
Posted by Dain Sundstrom <da...@iq80.com>.
I'm not very familiar with the Geronimo/OpenEJB security integration,
but I'll answer what I can.
On Nov 25, 2008, at 4:31 PM, Kory Markevich wrote:
> I'm trying to call getCallerPrincipal in a method annotated with
> PostConstruct on a stateful session bean. I'm using whatever
> version of
> OpenEJB was used in Geronimo 2.1.2. From what I can tell reading the
> ejbcore spec (4.4.1) this call is legal, and sure enough it doesn't
> throw an
> exception. However the principal being returned is an un-
> authenticated stub
> rather than the actual user.
Yes that method is legal (unlike the deprecated getCallerIdentity
method), but EJB 3.0 (core) section 4.3.4 states, "The PostConstruct
lifecycle callback interceptor methods execute in an unspecified
transaction and security context." The phrase "unspecified security
context" means that the container can choose any context in which to
execute the PostConstruct method. Later in section 4.3.10.2 the
specification gives a reason for not specifying the security and
transaction context with the following:
Since stateless session bean instances are typically
pooled, the time of the client’s invocation of the
create method need not have any direct relationship
to the container’s invocation of the PostConstruct/
ejbCreate method on the stateless session bean instance.
IIRC, OpenEJB choose to execute virtually all callbacks using an
unauthenticated principal for consistency, but you could argue that we
should execute PostConstruct for a SFSB using the caller's principal
(and maybe TX context) since we don't pool SFSB instances. Instead we
always create the instance at "the time of the client’s invocation of
the create method."
If this is a change you would like to see, please make the argument
and file a JIRA :)
-dain