title: Moving Spring Security To Java Config, where does authentication-success-handler-ref go?
body: <p>Our app has a custom success handler for successful logins. It basically redirects them to the page they were on when their session expired.</p>
  
  <p>We're moving to a Java config rather than a spring xml config. The rest of the config went very smoothly, but we can't find where to put the authentication-success-handler-ref attribute of the security:form-login tag.</p>
  
  <pre><code>&lt;security:http auto-config='true'&gt;
    ...
    &lt;security:intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY"/&gt;
    &lt;security:form-login login-page="/login" default-target-url="/sites"
                       authentication-failure-url="/login"
                       authentication-success-handler-ref="authenticationSuccessHandler"/&gt;
   ...
  </code></pre>
  
  <p></p>
  
  <p>Here's our config, so far.</p>
  
  <pre><code>  @Override
    protected void configure(HttpSecurity http) throws Exception {
      http
         .authorizeRequests()
            .anyRequest().authenticated()
            .and()
          .formLogin()
            .loginPage("/login")
            .failureUrl("/login")
            .and()
          .logout()
            .permitAll()
            .and()
    }
  </code></pre>
  
  <p>Also, we can't find where to put default-target-url, but that is definitely less important.</p>
  
  <p>Caveat, we're actually using Groovy, but the code is basically the same as a Java config.</p>