2 Replies Latest reply on May 26, 2008 11:13 AM by Ido Tamir

    failing to outject

    Ido Tamir Newbie

      Hi,
      while I am able to programatically set the authenticated user into the session, the outjected user is nowhere to be found. Why not?


      thank you very much for your answers,
      ido




      @Stateful
      @Scope(ScopeType.EVENT)
      @Name("authenticator")
      public class AuthenticatorAction implements Authenticator {
           @PersistenceContext
           private EntityManager em;
      
           @Out(scope=ScopeType.SESSION,required=false)
           private User user; //fails
                
           public boolean authenticate() {
                String encryptedPW = Service.getInstance().getSaltedHash(Identity.instance().getPassword());
                try {
                     User user = (User) em.createQuery(
                     "from User where username = :username and password = :password")
                     .setParameter("username", Identity.instance().getUsername())
                     .setParameter("password", encryptedPW)
                     .getSingleResult();
                     Identity.instance().addRole(user.getRole());
                     Contexts.getSessionContext().set("authenticatedUser", user); //works
                     return true;
                }
                catch (NoResultException ex){
                     return false;
                }
           }
      
           @Destroy @Remove
           public void destroy() {}
      
      }