Hi,
this was quite painful as there was no way I could find to do that
automatically after the JAAS login. In the end we used an @Factory variable
included in one of the admin templates to force the creation and outjection of
the PortalUser. Something as follows:
| /**
| * if there is no portalUser, this method will execute
| */
| @Factory("portalUser")
| public void loadCurrentPortalUser() {
| logger.info("**** FACTORY ****** portalUser is " +
portalUser);
| try {
| String username = new String("unknown");
|
| facesContext = FacesContext.getCurrentInstance();
| if (
facesContext.getExternalContext().getUserPrincipal()
| == null ) {
| portalUser = null;
| logger.info("not logged in");
| return;
| }
|
|
| //
| // get security login name
| //
| username =
| facesContext.getExternalContext().
| getUserPrincipal().getName().toString();
|
|
|
| //
| // create DB query
| //
| String query = new String("FROM " +
| PortalUser.class.getName() +
| " where login='" + username +
| "'");
| //
| // get user from db
| //
| List list = em.createQuery(query).getResultList();
| if ( list != null && list.size() > 0 ) {
| Object obj = list.get(0);
| if ( obj instanceof PortalUser ){
| portalUser = (PortalUser) obj;
|
Contexts.getSessionContext().set("portalUser",portalUser);
| }
| }
|
| }
|
| catch ( Throwable t ) {
| logger.error("portalUser factory throws " + t);
| portalUser = null;
| }
| }
|
Hope it helps
L
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3931410#3931410
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3931410
-------------------------------------------------------
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