title: Custom Security mechanism in Java EE 6/7 application
body: <p>I would like to create (implement by my own) authentication mechanism which will be
  plugged into my Java EE application. </p>
  
  <p>As far as I know I have to implement LoginModule and connect this implementation with 
  container mechanisms somehow.  But the problem is that I don't know how to do it. 
  Maybe You know where I can find sample code or tutorial about it?</p>
  
  <p>In other words I would like to force container to call my classes whenever methods:
  authenticate, login, and logout are called. </p>
  
  <p><strong>Sample implementation</strong>:
  HttpServletRequest.login method will successfully authenticate only users with even numer of letters in login.</p>