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

    failing to outject

    ido_tamir

      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() {}
      
      }


        • 1. Re: failing to outject
          stephen

          Err, stupid question, but in the version that should use injection, you did remove the User declaration here, did you:



          User user = (User) em.createQuery(



          Else you only ever set the value of the local var and there is nothing to outject.

          • 2. Re: failing to outject
            ido_tamir

            No of course not, stupid me. Guess it was a bit to late yesterday.
            And sorry for the low rating of your comment, I did not know that it was so ajaxified.


            thanks,
            ido