users@glassfish.java.net

Custom Principal Passed to Web Tier

From: Tim Davidson <trdavidson_at_gmail.com>
Date: Thu, 8 Feb 2007 15:34:18 +0000

Hi

 I have a custom Principal which I create in my Custom Login Module, however
I am having problems as it is not being passed to the web tier i.e

public class CustomLoginModule extends AppservPasswordLoginModule {
...
    protected void authenticateUser()
        throws LoginException
     {

    // authenticate then create new instance of custom principal and
authenticate user
    javax.security.Principal principal = new CustomPrincipal(username);

    _succeeded = true;

    commitUserAuthentication(new String[] {"users","admin"});
   }
}

how do I pass the custom principal to the web tier:

public class CustomServlet extends HttpServlet {
...
   public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
   {
     // should return custom principal
      javax.security.Principal principal = request.getUserPrincipal();
  }
}

at the moment request.getUserPrincipal() returns null, what do I need to do
so that it retuns the same instance created in the login module?

thanks in advance