title: Programmatically authentication in LifeRay
body: <p>I'm using LifeRay and need some kind of special authentication: my users have x.509 certificates which are validated by an Apache Webserver. After a successful validation, the user is redirected to Tomcat and in there LifeRay.</p>
  
  <p>Now I want to do the following: get the subject DN of the user's certificate programmatically and log in the LifeRay user that is connected to this DN.</p>
  
  <p>So far, I have the following:</p>
  
  <ul>
  <li>Created a hook "login.events.pre" where I get the DN from the certificate</li>
  <li>Search the LifeRay DB for a user with this DN (using UserLocalServiceUtil.getUserByOpenId())</li>
  <li>Authenticate user using UserLocalServiceUtil.authenticateByScreenName()</li>
  </ul>
  
  <p>My question now: is that the "best"/cleanest way to do this or should I use other methods for querying the LifeRay DB, authenticating the user etc. For instance, instead of a hook I could create an Ext-Extensions for LifeRay. Additionally, I found some stuff like "com.liferay.portlet.login.util.LoginUtil.login" or User user = PortalUtil.getUser(request); to get a user.</p>
  
  <p>Is there a place in the docu where those questions are answered? The API is not that comprehensive...</p>