1 Reply Latest reply on Oct 10, 2006 4:29 AM by parmarsanjay

    Securing POJO Web Service

    parmarsanjay

      How do I retrieve User Principal in Web Service Implementation?

      It's easy to get the Caller Prinicipal in Web using getUserPrincipal() of HttpServletRequest.

      What's the equivalent in POJO Web Service implementation?

      Cheers,
      Sanjay

        • 1. Re: Securing POJO Web Service
          parmarsanjay

          I found the way to do this. I had to implement "ServiceLifecycle" interface for my Web Service and provide implementation for init and destroy method.

          private ServletEndpointContext mServletEndpointContext = null;
          private ServletContext mServletContext = null;

          public void init(Object context)
          {
          System.out.println("Init Called");
          mServletEndpointContext = (ServletEndpointContext) context;
          mServletContext = mServletEndpointContext.getServletContext();
          }

          /**
          *
          */
          public void destroy()
          {
          System.out.println("Destroy Called");
          mServletEndpointContext = null;
          mServletContext = null;
          }

          You can get the user prinicipal from ServletEndpointContext .

          Cheers,
          Sanjay