title: What is the default AuthenticationManager in Spring-Security? How does it authenticate?
body: <p>I have the following bean defined:</p>
  
  <pre><code>&lt;sec:authentication-manager alias="authenticationManager"&gt;
      &lt;sec:authentication-provider
          user-service-ref="userDetailsService" /&gt;
  &lt;/sec:authentication-manager&gt;
  </code></pre>
  
  <p>I guess here Spring uses some default implementation of <code>AuthenticationManager</code>.</p>
  
  <p>In my Java code I have:</p>
  
  <pre><code>@Resource(name = "authenticationManager")
  private AuthenticationManager authenticationManager; // specific for Spring Security
  
  public boolean login(String username, String password) {
      try {
          Authentication authenticate = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password));
          if (authenticate.isAuthenticated()) {
              SecurityContextHolder.getContext().setAuthentication(authenticate);             
              return true;
          }
      }
      catch (AuthenticationException e) {         
      }
      return false;
  }
  </code></pre>
  
  <p>Here <code>AuthenticationManager.authenticate(...)</code> is called. But I would like to know which implementation of <code>AuthenticationManager</code> Spring uses by default, and what its <code>authenticate(...)</code> does in order to authenticate (i.e., make sure that username matches password).</p>
  
  <p>Could you explain this?</p>