Thanks Andrei.

I tired the code you provided but I get NULL AuthorizationPolicy. I found the 
following code which worked.

@Resource
WebServiceContext context;

LOG.debug("UserName: [" + context.getUserPrincipal().getName() + "]");


But this works only when WSS4JInInterceptor has action="UsernameToken".

When action="UsernameToken Timestamp Signature Encrypt", the same code gives CN 
of the X.509 certificate.

Can you please help to get the username in the UsernameToken in this case.

Regards
Paul
On Wednesday, May 7, 2014 3:03 AM, Andrei Shakirin <[email protected]> wrote:
 
Hi Paul,

CXF packs username and password into AuthorizationPolicy.
The code could look like:
    @Resource
    WebServiceContext context;

    AuthorizationPolicy policy = (AuthorizationPolicy) context
            .getMessageContext().get(AuthorizationPolicy.class.getName());

    System.out.println("User name: " + policy.getUserName());
    System.out.println("Password: " + policy.getPassword());

Regards,
Andrei.


> -----Original Message-----
> From: Paul Avijit [mailto:[email protected]]
> Sent: Dienstag, 6. Mai 2014 19:54
> To: [email protected]
> Subject: Getting UserId from WS-Security UsernameToken
> 
> Hi,
> 
> How can I get the UserId from WS-Security UsernameToken in the
> implementation class.
> 
> 
> Thanks in advance.
> 
> Regards
> Paul

Reply via email to