4 Replies Latest reply on Feb 21, 2008 4:13 PM by srini.ragu

    Chaotic Logging problem

    ziphyre

      Hi,


      I have a log.info(...) instruction (the third one) who doesn't get executed at all (at least I thing so)


          @Logger 
          private Log log;
          
          @In 
          private Identity identity;
         
          @PersistenceContext
          private EntityManager entityManager;
          
          public boolean authenticate()
          {               
               User u;
              log.info("1- username: #0", identity.getUsername());        
              Query q = entityManager.createQuery("from User u where u.phoneNumber = 'xxxxxx' and u.password = 'xxxxxx'");
              log.info("2- password: #0", identity.getPassword());
            
              try {
                   u = (User) q.getSingleResult();
                   log.info("3- password: #0", u.getPassword());
              }
              catch (NoResultException e) {        
                   return false;
           }
              return true;
          }



      And the result is:


      20:21:36,930 INFO  [Authenticator] 1- username: 123
      20:21:36,939 INFO  [Authenticator] 2- password: 123
      20:21:36,941 INFO  [STDOUT] Hibernate: 
          select
              user0_.id as id4_,
              user0_.password as password4_,
              user0_.fullName as fullName4_,
              user0_.phoneNumber as phoneNum4_4_ 
          from
              User user0_ 
          where
              user0_.phoneNumber='xxxxxx' 
              and user0_.password='xxxxxx'
      20:21:37,116 INFO  [Authenticator] 1- username: 123
      20:21:37,116 INFO  [Authenticator] 2- password: 123
      20:21:37,123 INFO  [STDOUT] Hibernate: 
          select
              user0_.id as id4_,
              user0_.password as password4_,
              user0_.fullName as fullName4_,
              user0_.phoneNumber as phoneNum4_4_ 
          from
              User user0_ 
          where
              user0_.phoneNumber='xxxxxx' 
              and user0_.password='xxxxxx'



      Well, I have 3 question:


      1-) Why the third log instruction



      log.info("3- password: #0", u.getPassword());




      doesn't get logged?


      2-) When the previous code is executed for the first time, as you see it logs 2 times the same thing? But the following executions log only once (password xxxxx is wrong so I always try to log in...)


      By the way, it's the authenticator method of the basic seam-gen generated code, without major modifications


      Thanks for any clarification.

        • 1. Re: Chaotic Logging problem
          ziphyre


          1-) Why the third log instruction


          log.info("3- password: #0", u.getPassword());




          doesn't get logged?

          Ahh, never mind the first question. I'm reading the seam doc for hours, and my vision is a little blurred :)


          But the 2nd question still applies...

          • 2. Re: Chaotic Logging problem
            pmuir

            Ziphyre Marco wrote on Feb 20, 2008 07:37 PM:


            2-) When the previous code is executed for the first time, as you see it logs 2 times the same thing? But the following executions log only once (password xxxxx is wrong so I always try to log in...)



            FAQ - the authenticator may be called more than once (it's an authenticator, not a login method).

            • 3. Re: Chaotic Logging problem
              ziphyre

              Pete Muir wrote on Feb 21, 2008 12:30 PM:



              FAQ - the authenticator may be called more than once (it's an authenticator, not a login method).


              Thanks. Which FAQ is this in? I couldn't see any related article on this site's FAQ?

              • 4. Re: Chaotic Logging problem
                srini.ragu

                better way to perform post authentication setup or initializing values after successful login is to have separate method and register them as Observer to seam events like:


                EVENTPOSTAUTHENTICATE, EVENTLOGINSUCCESSFUL


                http://docs.jboss.com/seam/2.1.0.A1/api/org/jboss/seam/security/Identity.html