title: Spring Security - Programmatic login without a password
body: <p>I am trying to perform an automatic login when the user clicks a link in their email with Spring Security.</p>
  
  <p>I have seen a lot of examples to perform a programmatic login like the following:</p>
  
  <pre><code>UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password);
  try {
      Authentication auth = authenticationManager.authenticate(token);
      SecurityContextHolder.getContext().setAuthentication(auth);
      repository.saveContext(SecurityContextHolder.getContext(), request, response);
      rememberMeServices.loginSuccess(request, response, auth);
   ....
  </code></pre>
  
  <p>The problem I see is that I do not have the original password so I can't create a UsernamePasswordAuthenticationToken. Any other way to login the user if I do not have the plain text password (I have the one that is encoded)? </p>
  
  <p>Thanks in advance.</p>