title: How to implement login page using Spring Security so that it works with Spring web flow?
body: <p>I have a web application using Spring 2.5.6 and Spring Security 2.0.4. I have implemented a working login page, which authenticates the user against a web service. The authentication is done by defining a custom authentincation manager, like this:</p>
  
  <pre><code>
  &lt;beans:bean id="customizedFormLoginFilter"
      class="org.springframework.security.ui.webapp.AuthenticationProcessingFilter"&gt;
      &lt;custom-filter position="AUTHENTICATION_PROCESSING_FILTER" /&gt;
      &lt;beans:property name="defaultTargetUrl" value="/index.do" /&gt;
      &lt;beans:property name="authenticationFailureUrl" value="/login.do?error=true" /&gt;
      &lt;beans:property name="authenticationManager" ref="customAuthenticationManager" /&gt;
      &lt;beans:property name="allowSessionCreation" value="true" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="customAuthenticationManager"
      class="com.sevenp.mobile.samplemgmt.web.security.CustomAuthenticationManager"&gt;
      &lt;beans:property name="authenticateUrlWs" value="${WS_ENDPOINT_ADDRESS}" /&gt;
  &lt;/beans:bean&gt;
  </code></pre>
  
  <p>The authentication manager class:</p>
  
  <pre><code>
  public class CustomAuthenticationManager implements AuthenticationManager, ApplicationContextAware {
  
      @Transactional
      @Override
      public Authentication authenticate(Authentication authentication) throws AuthenticationException {
  
                  //authentication logic
  
          return new UsernamePasswordAuthenticationToken(principal, authentication.getCredentials(),
                  grantedAuthorityArray);
      }
  </code></pre>
  
  <p>The essential part of the login jsp looks like this:</p>
  
  <pre><code>
  &lt;c:url value="/j_spring_security_check" var="formUrlSecurityCheck"/&gt;
  &lt;form method="post" action="${formUrlSecurityCheck}"&gt;
      &lt;div id="errorArea" class="errorBox"&gt; 
         &lt;c:if test="${not empty param.error}"&gt;
            ${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message}
        &lt;/c:if&gt;
    &lt;/div&gt;
      &lt;label for="loginName"&gt;
          Username:           
          &lt;input style="width:125px;" tabindex="1" id="login" name="j_username" /&gt;
      &lt;/label&gt;
  
      &lt;label for="password"&gt;
          Password:           
          &lt;input style="width:125px;" tabindex="2" id="password" name="j_password" type="password" /&gt;
      &lt;/label&gt;
      &lt;input type="submit" tabindex="3" name="login" class="formButton" value="Login" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Now the problem is that the application should use <a href="http://www.springsource.org/webflow" rel="noreferrer">Spring Web Flow</a>. After the application was configured to use Spring Web Flow, the login does not work anymore - the form action to "/j_spring_security_check" results in a blank page without error message. What is the best way to adapt the existing login process so that it works with Spring Web Flow?</p>
  
  <p><strong>Edit:</strong> there was no error message, just a blank page was displayed. It works now - the problem was that web.xml was missing entries</p>
  
  <pre><code>
  &lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>Since I cannot cancel the bounty although the problem is solved, the bounty is awarded to most insightful answer or link, which would help other people in configuring Spring Security and Web Flow to work together.</p>