title: Spring security: remember-me doesn't work with custom AuthenticationProvider
body: <p>I am using a custom <code>AuthenticationProvider</code>:</p>
  
  <pre><code>public class CustomAuthenticationProviderImpl extends AbstractUserDetailsAuthenticationProvider {
  
      @Resource(name="userDetailsService")
      private UserDetailsService userDetailsService;
  
      //.......
  
  }
  </code></pre>
  
  <p>I also try to use the remember-me feature:</p>
  
  <pre><code>&lt;security:http auto-config="true" use-expressions="true" access-denied-page="/auth/accessDenied.xhtml" &gt;
  
      &lt;!-- ........... --&gt;
  
      &lt;security:remember-me user-service-ref="userDetailsService" key="some-string"/&gt;
  
  &lt;/security:http&gt;
  </code></pre>
  
  <p>Everything works except for the remember-me. It used to work when I did not use custom <code>AuthenticationProvider</code>.</p>
  
  <p>What do I need to do in order to make the remember-me work?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I am also using an <code>AuthenticationSuccessHandler</code>:</p>
  
  <pre><code>public class AuthenticationSuccessHandlerImpl extends SimpleUrlAuthenticationSuccessHandler {
  
      @Override
      public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
  
          int timeout = 60*60;
  
          request.getSession().setMaxInactiveInterval(timeout); //60 minutes
  
          System.out.println("Session timeout of user: " + authentication.getName() + " has been set to: " + request.getSession().getMaxInactiveInterval() + " seconds.");
  
          setDefaultTargetUrl("/views/home.jsf");
  
          super.onAuthenticationSuccess(request, response, authentication);
      }
  }
  </code></pre>
  
  <p><strong>UPDAT 2:</strong></p>
  
  <p>I am getting the following debug output when I restart Tomcat. But when I load the login form, and when I submit it - I do not see any text that includes <code>remember</code> in the debug output, and no remember-me cookie is created.</p>
  
  <pre><code>DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,166 (DefaultSingletonBeanRegistry.java:217) - org.springframework.beans.factory.support.DefaultSingletonBeanRegistry getSingleton :
   Creating shared instance of singleton bean 'rememberMeFilter'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,166 (AbstractAutowireCapableBeanFactory.java:430) - org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory createBean :
   Creating instance of bean 'rememberMeFilter'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,182 (AbstractEnvironment.java:114) - org.springframework.core.env.AbstractEnvironment &lt;init&gt; :
   Initializing new StandardServletEnvironment
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,182 (MutablePropertySources.java:103) - org.springframework.core.env.MutablePropertySources addLast :
   Adding [servletConfigInitParams] PropertySource with lowest search precedence
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,182 (MutablePropertySources.java:103) - org.springframework.core.env.MutablePropertySources addLast :
   Adding [servletContextInitParams] PropertySource with lowest search precedence
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,182 (MutablePropertySources.java:103) - org.springframework.core.env.MutablePropertySources addLast :
   Adding [jndiProperties] PropertySource with lowest search precedence
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,182 (MutablePropertySources.java:103) - org.springframework.core.env.MutablePropertySources addLast :
   Adding [systemProperties] PropertySource with lowest search precedence
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,182 (MutablePropertySources.java:103) - org.springframework.core.env.MutablePropertySources addLast :
   Adding [systemEnvironment] PropertySource with lowest search precedence
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,182 (AbstractEnvironment.java:120) - org.springframework.core.env.AbstractEnvironment &lt;init&gt; :
   Initialized StandardServletEnvironment with PropertySources [servletConfigInitParams,servletContextInitParams,jndiProperties,systemProperties,systemEnvironment]
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,182 (AbstractAutowireCapableBeanFactory.java:504) - org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory doCreateBean :
   Eagerly caching bean 'rememberMeFilter' to allow for resolving potential circular references
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,182 (DefaultSingletonBeanRegistry.java:217) - org.springframework.beans.factory.support.DefaultSingletonBeanRegistry getSingleton :
   Creating shared instance of singleton bean 'rememberMeServices'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,182 (AbstractAutowireCapableBeanFactory.java:430) - org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory createBean :
   Creating instance of bean 'rememberMeServices'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,198 (AbstractAutowireCapableBeanFactory.java:504) - org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory doCreateBean :
   Eagerly caching bean 'rememberMeServices' to allow for resolving potential circular references
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,198 (AbstractBeanFactory.java:245) - org.springframework.beans.factory.support.AbstractBeanFactory doGetBean :
   Returning cached instance of singleton bean 'userDetailsService'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractAutowireCapableBeanFactory.java:1498) - org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory invokeInitMethods :
   Invoking afterPropertiesSet() on bean with name 'rememberMeServices'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractBeanFactory.java:245) - org.springframework.beans.factory.support.AbstractBeanFactory doGetBean :
   Returning cached instance of singleton bean 'org.springframework.security.methodSecurityMetadataSourceAdvisor'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractBeanFactory.java:245) - org.springframework.beans.factory.support.AbstractBeanFactory doGetBean :
   Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractAutowireCapableBeanFactory.java:458) - org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory createBean :
   Finished creating instance of bean 'rememberMeServices'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractBeanFactory.java:245) - org.springframework.beans.factory.support.AbstractBeanFactory doGetBean :
   Returning cached instance of singleton bean 'org.springframework.security.authenticationManager'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractAutowireCapableBeanFactory.java:1498) - org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory invokeInitMethods :
   Invoking afterPropertiesSet() on bean with name 'rememberMeFilter'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractBeanFactory.java:245) - org.springframework.beans.factory.support.AbstractBeanFactory doGetBean :
   Returning cached instance of singleton bean 'org.springframework.security.methodSecurityMetadataSourceAdvisor'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractBeanFactory.java:245) - org.springframework.beans.factory.support.AbstractBeanFactory doGetBean :
   Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractAutowireCapableBeanFactory.java:458) - org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory createBean :
   Finished creating instance of bean 'rememberMeFilter'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractBeanFactory.java:245) - org.springframework.beans.factory.support.AbstractBeanFactory doGetBean :
   Returning cached instance of singleton bean 'rememberMeServices'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (DefaultSingletonBeanRegistry.java:217) - org.springframework.beans.factory.support.DefaultSingletonBeanRegistry getSingleton :
   Creating shared instance of singleton bean 'rememberMeAuthenticationProvider'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractAutowireCapableBeanFactory.java:430) - org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory createBean :
   Creating instance of bean 'rememberMeAuthenticationProvider'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractAutowireCapableBeanFactory.java:504) - org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory doCreateBean :
   Eagerly caching bean 'rememberMeAuthenticationProvider' to allow for resolving potential circular references
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractAutowireCapableBeanFactory.java:1498) - org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory invokeInitMethods :
   Invoking afterPropertiesSet() on bean with name 'rememberMeAuthenticationProvider'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractBeanFactory.java:245) - org.springframework.beans.factory.support.AbstractBeanFactory doGetBean :
   Returning cached instance of singleton bean 'org.springframework.security.methodSecurityMetadataSourceAdvisor'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractBeanFactory.java:245) - org.springframework.beans.factory.support.AbstractBeanFactory doGetBean :
   Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
  DEBUG [pool-2-thread-1] 2012-04-16 09:18:11,213 (AbstractAutowireCapableBeanFactory.java:458) - org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory createBean :
   Finished creating instance of bean 'rememberMeAuthenticationProvider'
  </code></pre>
  
  <p>I have the following in my <code>AuthenticationSuccessHandlerImpl</code>:</p>
  
  <p><code>System.out.println("_spring_security_remember_me after authentication = " + request.getParameter("_spring_security_remember_me"));</code></p>
  
  <p>and the output is:</p>
  
  <p><code>_spring_security_remember_me after authentication = on</code></p>
  
  <p>But no remember-me cookie was created!</p>