This content has been marked as final.
Show 2 replies
-
1. Re: how to get principal from Entity
rwiesemann Jun 14, 2009 9:32 AM (in response to apdo)Hi,
i have a similar requirement to lookup the caller principal in an entity bean.
Have you got (or found) a solution?
Thanks
Roland Wiesemann -
2. Re: how to get principal from Entity
wolfgangknauf Jun 15, 2009 9:52 AM (in response to apdo)Hi Roland,
I think that "EntityContext" is EJB2 and no longer supported in EJB3. You can get this information from the SessionContext in a SessionBean:@Resource() private SessionContext sessionContext = null; public void someSessionBeanMethod() { Principal principal = this.sessionContext.getCallerPrincipal(); ... }
Or maybe you could follow this post: http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3968882
It seems that you can use entity callbacks like "@PreUpdate" and use the class "org.jboss.security.SecurityAssociation" to get the Principal:@PreUpdate private void someMethod() { Principal principal = SecurityAssociation.getPrincipal(); ... }
Hope this helps
Wolfgang