title: Apache Tomcat - Two factor authentication
body: <p>I am trying to integrate a two factor authentication solution with a mail server that is hosted on Apache Tomcat. Right now the app is using form based authentication and the user enters his user name and password and is authenticated against openLDAP as back end.</p>
  
  <p>What we want is the following -</p>
  
  <p>1). User enters his Un and PWD<br>
  2). The request is "intercepted" and put on "hold"<br>
  3). A one time pwd (OTP) is generated and sent as SMS to the user.<br>
  4). The user sees a new page with a box to enter that OTP.<br>
  5). The user enters his/her OTP sent as SMS<br>
  6). The OTP is verified and if true the "held" request in step "2" is forwarded for further authentication  </p>
  
  <p>The trouble is that I have no access to source code of the mail server app.</p>
  
  <p>I can achieve something very similar in IIS(Microsoft) using an ISAPI filter, but need to know how to achieve this in Apache?</p>
  
  <p>I am looking on the lines of Valve/Filter and SAML, but have no clue how and where to progress.</p>