title: How to implement authentication mechanism in Java EE 6
body: <p>I'm trying to learn Java EE 6 and i'm just wondering how to implement authentication mechanism in Java EE 6.</p>
  <p>Here is the Java EE 6 authentiction example:</p>
  <pre><code>    public void login() {
      if (account.authenticate(name, password) == null) {
          message = &quot;Invalid user name or password!&quot;;
      } else {
          message = &quot; Login successful&quot;;
          FacesContext context = FacesContext.getCurrentInstance();
          HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
          try {
              request.login(this.name, this.password);
              Principal principal = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal();
              name = principal.getName();
          } catch (ServletException e) {
              // Handle unknown username/password in request.login().
              context.addMessage(null, new FacesMessage(&quot;Unknown login&quot;));
          }
      }
  }
  </code></pre>
  <p>I have a following questions:</p>
  <p>
  <ol>
  <li>How request.login function check name and password? It isn't know user entity?</li>
  <li>If it isn't right way. How to implement standart authentication mechanism</li>
  </ol>
  </p>
  <p>In finally thank you for your advise and i need a very good tutorials or advise.</p>