Praneeth
Praneeth

Reputation: 1487

How to get authenticated user info in a JAX-WS web service?

How can I get authenticated user info from JAX-WS Web Service?

Thanks

Upvotes: 2

Views: 3404

Answers (1)

Praneeth
Praneeth

Reputation: 1487

I didn't know how to mark the question as answered as @home answered the question as a comment.

Anyhow, following is the answer

@WebService()
public class MyWebService{
  @Resource
  private WebServiceContext wsContext;
  @WebMethod
  public void echoHello(String msg) {
    System.out.println("Username = " + wsContext.getUserPrincipal().getName());
  }
}

Upvotes: 6

Related Questions