title: JSF2 Login authentication with multiple databases
body: <p>I'm writing web app using JSF2 and primefaces with Glassfish 3.1.2. I want to start with login/logout mechanism but i'm not sure about solution. </p>
  
  <p>What I want to achieve: 
  Three main goals:</p>
  
  <ul>
  <li><p>web application in JSF 2.1</p></li>
  <li><p>this application will use many databases (but every db will have the same user, password and "security table" with application login and password). So user during authentication must give database name, user and password. </p></li>
  <li><p>I want to be able to logout and login on different user without closing browser.</p></li>
  </ul>
  
  <p>What authentication method will be the best in that case ? I cannot just create a new Realm with database name because it is not const in my situation. </p>
  
  <p>I thought about web-services, which will take db_name, app_login and app_password as parameters and return whether it is ok or not..  And then create a simple managed bean, which will tell me whether user is logged. But i want to totally separate login logic from other stuff.. and I want to check whether user is logged before I view every page in application.</p>
  
  <p>Thanks for your tips, 
  Regards</p>