Alex Rivera | Logout

WSContext.getUserPrincipal() returns null for password digest authentication

Asked 2009-10-20T21:27:30.373
10

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.

Edit
Report

1 Answer

1

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.

answered 2011-12-28T14:00:52.203

Your Answer