title: Username Password Authentication in Spring Security
body: <p>I'm trying to make a simple username/password authentication in a Spring Security web app.  I have a web service that authenticates by passing in a user name/password, and gets back a role.  Then I need to retain the password for future web service calls.</p>
  
  <p>My app was initially created with App Fuse, so it had some JDBC-based authentication.  I've ripped that out, but I'm not sure how to add my custom authentication in.</p>
  
  <p>The documentation says that it's <a href="http://static.springsource.org/spring-security/site/docs/3.0.x/reference/technical-overview.html#tech-intro-authentication" rel="nofollow">"simple" to add in such a mechanism</a>.  But the example app is a command line hello-world style program, not a web app.  I can't seem to find an example of username/password authentication in a web app.</p>
  
  <p>I've got the following in my XML file:</p>
  
  <pre><code>&lt;beans:bean id="myProvider" class="com.example.MyProvider"&gt;&lt;/beans:bean&gt;
  
  &lt;authentication-manager&gt;
      &lt;authentication-provider ref="myProvider"&gt;&lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  </code></pre>
  
  <p>I don't know if this is the right place to put my authentication in, and I'm not sure what interface to implement.  I think I might need to implement <code>AuthenticationManager</code>.  And I might use <code>UsernamePasswordAuthenticationToken</code>.  </p>
  
  <p>How do I wire this all together?  </p>