1 Reply Latest reply on Oct 10, 2011 4:10 AM by sjahan

    How to get the principal on a webservice behind JAAS?

    sjahan Newbie

      Hi,

       

      I assume this is certainly a newbie question but i never worked on this pattern before so i'm quite stuck on the question and need some help.

       

      Here is the case: i have some JBossWS webservices : they're just some usual classes with annotations like that:

       

      @PermitAll

      @WebService(targetNamespace="http://www.ws.com/portal", name="portal", serviceName="portal")

      @SOAPBinding(style = SOAPBinding.Style.DOCUMENT)

      public class WSPortal{

       

      They're protected resource by JAAS, with a LDAPLoginModule which works fine for authentication, the trouble is that i didn't find a way to simply get the login of the connected user (or the principal or anything).

      I used to work on servlets and this was quite simple to get it with HTTPServletRequest, but here, that doesn't fit

       

      How am i supposed to get something on the user once i passed through JAAS in a JbossWS webservice class?

      Maybe i'm not supposed to authenticate via JAAS, but i have no clue on the matter and i hope someone could help me about it!

       

      Thank you very much by advance for your support,

       

      SJ.

        • 1. Re: How to get the principal on a webservice behind JAAS?
          sjahan Newbie

          Finally figured out, it's quite simple but i got to look for it with good keywords.

           

          For those who could wonder about the answer, you just declare a variable WebServiceContext in your POJO, with a @Resource annotation.

          Example:

           

          @Resource

          public WebServiceContext wsCtx;

           

          ...

           

          Later:

           

          wsCtx.getUserPrincipal();

           

          Hoping this could help someone later

          Have a nice day.

           

          SJ.