Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WSContext.getUserPrincipal() returns null for password digest authentication

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.

like image 860
Dean Schulze Avatar asked Oct 20 '09 21:10

Dean Schulze


1 Answers

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.

like image 195
MahdeTo Avatar answered Oct 04 '22 23:10

MahdeTo