title: Programmatically add roles after authentication
body: <p>I have the following JSF 2.1 login form, running in Glassfish 3.1</p>
  
  <pre><code>&lt;h:form id="loginForm"&gt;
          &lt;h:panelGrid columns="2" cellspacing="5"&gt;
              &lt;h:outputText value="Username" /&gt;
              &lt;h:inputText value="#{loginHandler.username}" /&gt;
              &lt;h:outputText value="Password:" /&gt;
              &lt;h:inputText value="#{loginHandler.password}" /&gt;
              &lt;h:outputLabel value="" /&gt;
              &lt;h:commandButton value="Login" action="#{loginHandler.login}" /&gt;
          &lt;/h:panelGrid&gt;
      &lt;/h:form&gt;
  </code></pre>
  
  <p>And the following backing bean.</p>
  
  <pre><code>public String login() throws IOException, LoginException {
  
      log.debug("Trying to login with username " + username);
  
      HttpSession session = getRequest().getSession(true);
  
      try {
          getRequest().login(username, password);
  
          // if OK, add Roles
                      ????????
                      ...................
  
      } catch (ServletException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
  
      log.debug("USER principal === " + getRequest().getUserPrincipal());
  
      return "home";
  }
  </code></pre>
  
  <p>The question is, how can I add roles programmatically to the UserPrincipal after successful login?</p>
  
  <p>Update 1: I tried to get the Subject by using the following code but subject == null.</p>
  
  <pre><code>Subject thisSubject = Subject.getSubject(AccessController
                  .getContext());
  </code></pre>
  
  <p>Thanks,
  Coen</p>