title: Spring Security login programmatically (AuthenticationSuccessHandler)
body: <p>I'm using spring-security 3.2.6 and during testing I programmatically login my users with</p>
  
  <pre><code>public User login(User user) {
      logOut();
      UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(
              user, user.getPassword(), user.getAuthorities());
      SecurityContextHolder.getContext().setAuthentication(
              authenticationToken);
      return user;
  }
  </code></pre>
  
  <p>doing it in that way I notice that isn't going through the <code>AuthenticationSuccessHandler</code>. Is there any way to achieve that?</p>