title: How to create security role in weblogic
body: <p>I followed this totorial to create security role in weblogic: <a href="http://blog.whitehorses.nl/2010/01/29/weblogic-web-application-container-security-part-1/" rel="nofollow">http://blog.whitehorses.nl/2010/01/29/weblogic-web-application-container-security-part-1/</a></p>
  
  <p>I create in weblogic server group RobMon and user monitor with pass. Then I create this xml:</p>
  
  <p>my web.xml:</p>
  
  <pre><code>&lt;security-constraint&gt;
  
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;my-application&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/admin&lt;/url-pattern&gt;
      &lt;/web-resource-collection&gt;
      &lt;auth-constraint&gt;
          &lt;role-name&gt;RobMon&lt;/role-name&gt;
      &lt;/auth-constraint&gt;
  &lt;/security-constraint&gt;
  
  &lt;security-role&gt;
      &lt;role-name&gt;RobMon&lt;/role-name&gt;
  &lt;/security-role&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&lt;/form-login-page&gt;
          &lt;form-error-page&gt;/login&lt;/form-error-page&gt;
      &lt;/form-login-config&gt;
  &lt;/login-config&gt;
  </code></pre>
  
  <p>weblogic.xml:</p>
  
  <pre><code>&lt;wls:security-role-assignment&gt;
      &lt;wls:role-name&gt;RobMon&lt;/wls:role-name&gt;
      &lt;wls:principal-name&gt;RobMon&lt;/wls:principal-name&gt;
  &lt;/wls:security-role-assignment&gt;
  </code></pre>
  
  <p>and now I want to println role and principles:</p>
  
  <pre><code>    Subject subject = Security.getCurrentSubject();
      Set&lt;Principal&gt; allPrincipals = subject.getPrincipals();
      for (Principal principal : allPrincipals) {
          if (principal instanceof WLSGroupImpl) {
              logger.error(principal.getName() + "??????????");
              roles.add(principal.getName());
          }
          if (principal instanceof WLSUserImpl) {
              logger.error(principal.getName() + "!!!!!!!!!!!");
              user = principal.getName();
          }
      }
  </code></pre>
  
  <p>but this prints me something else what I want</p>
  
  <pre><code> admin!!!!!!!!!!!
   Administrators??????????
  </code></pre>
  
  <p>it should println monitor and RobMon. What is wrong ?</p>