In my WebService I need to log the caller's id, but wsContext.getUserPrincipal() returns null even though the user was authenticated using WS-Security with password authentication. According to the JavaDocs for JAX-WS 2.1 WSContext.getUserPrincipal() should only return null if the user has not been authenticated.
Do I have to do something in the security handler to set the user principal into the WSContext? The docs seem to indicate that it is done automatically.
I'm using the metro 1.1 stack (1.1.5 I think) with jax-ws 2.1.3 stack on Tomcat.
Try iterating over wsContext.getMessageContext().entrySet() and displaying the values, sometimes they are there but for some reason not retrievable by the getUserPrincipal() method.
In this case just grab you principal directly from there and leave a comment to future you that this is not very portable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With