title: Programmatic users login
body: <p>I have the classic form based authentication setup in my web.xml file:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;security-constraint&gt;
      &lt;display-name&gt;AccessoRiservato&lt;/display-name&gt;
          &lt;web-resource-collection&gt;
              &lt;web-resource-name&gt;webResourceCollectionReserved&lt;/web-resource-name&gt;
              &lt;url-pattern&gt;*.htm&lt;/url-pattern&gt;
              &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
          &lt;/web-resource-collection&gt;
          &lt;auth-constraint&gt;
              &lt;role-name&gt;admin&lt;/role-name&gt;
              &lt;role-name&gt;guest&lt;/role-name&gt;
          &lt;/auth-constraint&gt;
      &lt;/security-constraint&gt;
  
  &lt;security-constraint&gt;
      &lt;display-name&gt;Pubblico&lt;/display-name&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;webResourceCollectionFree&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/javax.faces.resource/*&lt;/url-pattern&gt;
          &lt;url-pattern&gt;/login.htm&lt;/url-pattern&gt;
      &lt;/web-resource-collection&gt;
  &lt;/security-constraint&gt;
  
  &lt;login-config&gt;
      &lt;auth-method&gt;FORM&lt;/auth-method&gt;
      &lt;form-login-config&gt;
          &lt;form-login-page&gt;/login.htm&lt;/form-login-page&gt;
          &lt;form-error-page&gt;/login.htm&lt;/form-error-page&gt;
      &lt;/form-login-config&gt;    
  &lt;/login-config&gt;
  </code></pre>
  
  <p>I'm correctly redirected to my login.xhtml page:</p>
  
  <pre class="lang-xhtml prettyprint-override"><code>&lt;h:form&gt;
    &lt;h:outputLabel for="j_username" value="Nome Utente:"/&gt;
    &lt;h:inputText value="#{sessioneController.username}" id="j_username" size="20"/&gt;
  
    &lt;h:outputLabel for="j_password" value="Password:"/&gt;
    &lt;h:inputText value="#{sessioneController.password}" id="j_password" size="20"/&gt;
  
    &lt;h:commandButton action="#{sessioneController.login}" value="Login" /&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>I'd like to check by myself whether user is valid or not: </p>
  
  <p>in case of success, how can I say to the container (JBoss 8 - Wildly in this case) "hey, authenticate this user please!". I cannot create a realm unfortunately.</p>