[jboss-user] [EJB 3.0] - Re: how to get principal from Entity
Wolfgang Knauf
do-not-reply at jboss.com
Mon Jun 15 09:52:51 EDT 2009
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
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4237664#4237664
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4237664
More information about the jboss-user
mailing list