8 Replies Latest reply on Nov 12, 2009 10:12 PM by Binesh Gummadi

    Remember Me doesn't remember me

    Jens Weintraut Apprentice

      Hi,


      I've a problem using the identity.rememberMe feature. I want to use it in normal mode, not with auto-login. This is my page:



      <ui:define name="content">
        <h:outputText value="#{ares_messages.header_login}" styleClass="h1" />
        <s:div styleClass="loginBox">
         <h:outputText value="#{ares_messages.label_login_boxHeader}" styleClass="boxHeader" />
         <ice:form style="padding: 0px 20px;" id="loginForm">
          <ui:include src="inc/messages.xhtml" />
          
          <h:outputLabel for="username" value="#{ares_messages.label_login_userName}:" />
          <s:decorate id="decorate_username" template="inc/decorateField.xhtml">
           <h:inputText id="username" value="#{identity.username}" required="true" />
          </s:decorate>
      
          <h:outputLabel for="password" value="#{ares_messages.label_login_userPassword}:" />
          <s:decorate id="decorate_password" template="inc/decorateField.xhtml">
           <h:inputSecret id="password" value="#{identity.password}" />
          </s:decorate>
          
          <h:outputLabel for="rememberMe" value="Remember me:" />
          <h:selectBooleanCheckbox id="rememberMe" value="#{identity.rememberMe}"/>
          
          <s:div styleClass="boxButtonBar">
           <h:commandButton action="#{identity.login}" value="#{ares_messages.button_login}" />
          </s:div>
         </ice:form>
        </s:div>
      </ui:define>



      and I think it's like it's recommended. But when I enter my credentials and log in, then log out, the app doesn't remember me: the checkbox is checked, but the input field username still is empty.
      I'm using Seam 2.0.1.GA, JBoss 4.2.2.GA and Firefox 3.0, IE 7.0. With FF I had a look at my cookies from localhost and found a cookie org.jboss.seam.security.username with my username as content. But this cookie expires the same time I logged in, not sometime in the future.


      Thanks in advance
      Jens

        • 1. Re: Remember Me doesn't remember me
          Jens Weintraut Apprentice

          I'm still stuck on this. Doesn't anyone have any idea on this? I don't know what's wrong.

          • 2. Re: Remember Me doesn't remember me
            Binesh Gummadi Novice

            I have not used this feature myself but do you have remember-me set to true in your component.xml?


            <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>
            



            Let us know if it worked.

            • 3. Re: Remember Me doesn't remember me
              Jens Weintraut Apprentice

              First I thought this would help. But as far as I understand, this flag tells the Remember me checkbox if it's checked or not.

              • 4. Re: Remember Me doesn't remember me
                Jens Weintraut Apprentice

                This is the workaround I use ATM:


                <action execute="#{org.jboss.seam.security.facesSecurityEvents.initCredentialsFromCookie(org.jboss.seam.security.identity)}"/>



                I included this as a page action for my login page. But I hope that the Seam guys fix this bug.

                • 5. Re: Remember Me doesn't remember me
                  guy bashan Apprentice

                  Hi,


                  has anyone managed doing autologin with cookie?


                  I tried this line but it doesn't work:





                  <action execute="#{org.jboss.seam.security.facesSecurityEvents.initCredentialsFromCookie(org.jboss.seam.security.identity)}"/>
                  





                  I have tried doing autologin in Seam for ages with no luck...

                  • 6. Re: Remember Me doesn't remember me
                    Binesh Gummadi Novice

                    Try adding this to your component.xml.
                    What version of seam are you using? Seems like there is a bug in Seam2.2.0.GA.



                       <security:rememberMe enabled="true" mode="autoLogin" cookie-max-age="604800"/>



                    Default behavior is to remember the username but if you want autologin you should enable it by setting the mode. Let us know if it worked.

                    • 7. Re: Remember Me doesn't remember me
                      guy bashan Apprentice

                      I added this line ti my components.xml and got this exception when trying to login:




                      HTTP Status 500 -
                      
                      type Exception report
                      
                      message
                      
                      description The server encountered an internal error () that prevented it from fulfilling this request.
                      
                      exception
                      
                      javax.servlet.ServletException: #{identity.login}: java.lang.NullPointerException
                           javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                           org.jboss.seam.web.RewriteFilter.doFilter(RewriteFilter.java:63)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                           org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                           org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
                           org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
                           org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           com.snaptale.ui.view.util.SessionIdFilter.doFilter(SessionIdFilter.java:75)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                      
                      root cause
                      
                      javax.faces.FacesException: #{identity.login}: java.lang.NullPointerException
                           com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
                           javax.faces.component.UICommand.broadcast(UICommand.java:387)
                           org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:324)
                           org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:299)
                           org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:256)
                           org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:469)
                           com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                           com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                           com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                           javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                           org.jboss.seam.web.RewriteFilter.doFilter(RewriteFilter.java:63)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                           org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                           org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
                           org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
                           org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           com.snaptale.ui.view.util.SessionIdFilter.doFilter(SessionIdFilter.java:75)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                      
                      root cause
                      
                      javax.faces.el.EvaluationException: java.lang.NullPointerException
                           javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
                           com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
                           javax.faces.component.UICommand.broadcast(UICommand.java:387)
                           org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:324)
                           org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:299)
                           org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:256)
                           org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:469)
                           com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                           com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                           com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                           javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                           org.jboss.seam.web.RewriteFilter.doFilter(RewriteFilter.java:63)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                           org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                           org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
                           org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
                           org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           com.snaptale.ui.view.util.SessionIdFilter.doFilter(SessionIdFilter.java:75)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                      
                      root cause
                      
                      java.lang.NullPointerException
                           org.jboss.seam.security.RememberMe.postAuthenticate(RememberMe.java:385)
                           sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                           sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                           sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                           java.lang.reflect.Method.invoke(Method.java:597)
                           org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                           org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
                           org.jboss.seam.Component.callComponentMethod(Component.java:2253)
                           org.jboss.seam.core.Events.raiseEvent(Events.java:85)
                           org.jboss.seam.security.Identity.postAuthenticate(Identity.java:397)
                           org.jboss.seam.security.Identity.authenticate(Identity.java:345)
                           org.jboss.seam.security.Identity.authenticate(Identity.java:332)
                           org.jboss.seam.security.Identity.login(Identity.java:259)
                           sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                           sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                           sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                           java.lang.reflect.Method.invoke(Method.java:597)
                           org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
                           org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:348)
                           org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
                           org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
                           org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                           com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
                           javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
                           com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
                           javax.faces.component.UICommand.broadcast(UICommand.java:387)
                           org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:324)
                           org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:299)
                           org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:256)
                           org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:469)
                           com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                           com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                           com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                           javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                           org.jboss.seam.web.RewriteFilter.doFilter(RewriteFilter.java:63)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                           org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                           org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
                           org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
                           org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           com.snaptale.ui.view.util.SessionIdFilter.doFilter(SessionIdFilter.java:75)
                           org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                      
                      note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
                      Apache Tomcat/6.0.20
                      



                      Any idea?

                      • 8. Re: Remember Me doesn't remember me
                        Binesh Gummadi Novice

                        Did you configure the token store? I made this mistake too but it is clearly explained in 15.3.5.1. Token-based Remember-me Authentication.
                        It would be nice to see an error message which explains the cause as opposed to NPE.