title: isUserInRole sometimes returns false
body: <p>I'm developing my first Jsf, Jaas, JPA, JBoss application and now I have this trouble. I created two security domains in JBoss:</p>
  
  <pre><code>&lt;security-domain name="Database" cache-type="default"&gt;
  &lt;authentication&gt;
      &lt;login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required"&gt;
          &lt;module-option name="dsJndiName" value="java:jboss/JaasDS"/&gt;
          &lt;module-option name="principalsQuery" value="select password from user where mail=?"/&gt;
          &lt;module-option name="rolesQuery" value="select role, 'Roles'   from user u where u.mail=?"/&gt;
      &lt;/login-module&gt;
  &lt;/authentication&gt;
  &lt;/security-domain&gt;
  &lt;security-domain name="Custom" cache-type="default"&gt;
    &lt;authentication&gt;
      &lt;login-module code="demo.SampleLoginModule" flag="required"/&gt;
    &lt;/authentication&gt;
  &lt;/security-domain&gt;
  </code></pre>
  
  <p>If I use "Database" domain everything works, while if I use a "Custom" domain I can not set the role to the principal.</p>
  
  <p>My SampleLoginModule</p>
  
  <pre><code>public class SampleLoginModule implements LoginModule {
      private String username;
      private String password;
  
      private SamplePrincipal userPrincipal;
  
      public boolean login() throws LoginException {
          //Here i check the credentials 
      }
  
      public boolean commit() throws LoginException {
          //Here i add principal to subject 
  
          userPrincipal.setName("username");
  
          if (!(subject.getPrincipals().contains(userPrincipal))) 
              subject.getPrincipals().add(userPrincipal);
          }
      }
  }
  </code></pre>
  
  <p>MySimplePrincipal</p>
  
  <pre><code>public class SamplePrincipal implements Principal {
      private String name;
  
      public SamplePrincipal() {
          super();
      }
  
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }   
  }
  </code></pre>
  
  <p>I would add a role to a principal within of the method commit because <code>isUserInRole</code> otherwise return <code>false</code>.</p>
  
  <p>How can I do this?</p>