Dear All
I am using Louis security @Factory (thankyou) method for placing the user information into 'Seam' space from JAAS. (with the addition of the JBPM actor stuff).
The method looks like this
@In
User currentUser
@Factory("currentUser") public void loadCurrentUser() { log.info("**** FACTORY ****** currentUser is " + currentUser); try { String username = new String("unknown"); FacesContext facesContext = FacesContext.getCurrentInstance(); if ( facesContext.getExternalContext().getUserPrincipal() == null ) { currentUser = null; log.info("not logged in"); return; } // // get security login name // username = facesContext.getExternalContext().getUserPrincipal().getName().toString(); // // create DB query // String query = new String("FROM " + User.class.getName() + " where username='" + 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 User ){ currentUser = (User) obj; Contexts.getSessionContext().set("currentUser",currentUser); actor.setId(currentUser.getActorId()); actor.getGroupActorIds().addAll(currentUser.getGroupActorIds()); Contexts.getSessionContext().set( LOGIN_KEY, true ); } } } catch ( Throwable t ) { log.error("currentUser factory throws " + t); currentUser = null; } }
#{currentUser.username}or something similar.
@In(create=true) User currentUser
it does do exactly that.