5 Replies Latest reply on Mar 12, 2003 2:00 PM by John Fortin

    What I need to do to use my custom principal? Please. It´s n

    Jose Luiz Newbie

      What I need to do to use my custom principal?

      My commit() code:
      [pre]
      public boolean commit() throws LoginException
      {
      Set principals = this.subject.getPrincipals();

      Group roleGroup = new SimpleGroup("Roles");
      roleGroup.addMember(new SimplePrincipal("usuario"));
      roleGroup.addMember(new SimplePrincipal("fornecedor"));
      principals.add(roleGroup);

      Group callerPrincipalGroup = new SimpleGroup("CallerPrincipal");
      Principal prin = new MyCustonPrincipal(this.id, this.login);
      Principal prin = new callerPrincipalGroup.addMember(prin);
      principals.add(callerPrincipalGroup);

      this.login = null;
      this.senha = null;

      return true;
      }
      [/pre]

      I did some System.out to make sure it was running ok ... AND IT DID!

      So... I did a Servlet, code:
      [pre]
      public class TestPrincipal extends HttpServlet
      {
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
      {
      Principal p = request.getUserPrincipal();
      response.getWriter().write(p.getClass().getName());
      }
      }
      [/pre]

      The browser shows:
      org.jboss.jetty.security.JBossUserRealm$JBossUserPrincipal

      What am I doing wrong?

      Above my login-config.xml:
      [pre]
      <application-policy name="PILoginModule">

      <login-module code="mypackage.MyLoginModule" flag="required"/>

      </application-policy>
      [/pre]
      My jboss-web.xml
      [pre]
      <security-domain>java:/jaas/PILoginModule</security-domain>
      [/pre]
      Please! Help-me!