1 Reply Latest reply on Nov 4, 2004 9:32 PM by starksm64

    getUserPrincipal() retuns null after authentication

    sudarshanreddy

      Hi All,
      I am doing authentication using code below

      String authenticationType = getServletConfig().getInitParameter("authentication");
       SecurityAssociationHandler handler = new
       SecurityAssociationHandler();
       SimplePrincipal user = new SimplePrincipal(userName);
       handler.setSecurityInfo(user, password.toCharArray());
      
       LoginContext ctx = new LoginContext(authenticationType, handler);
      
       ctx.login();


      authentication is going fine and even i can retrieve the principles from subject.
      But when i am trying to get the UserPrinciple() from servelt it's returning null and even isUserInRole() returning null.

      Is i need to do some thing to attach my subject to servlet container..
      Any help is appreciated.

      Regards,
      Sudarshan

        • 1. Re: getUserPrincipal() retuns null after authentication
          starksm64

          You have to use the web container security model via the web.xml descriptor in order for the servlet security apis to return useful information. Simply doing a JAAS login does not populate the servlet container security context. This is only useful for interacting with other secured resources from within a servlet.