Reputation: 1457
I want to know username and password of a HTTP request using basic authentication.
I´m using WebServiceContext.
@Resource
private WebServiceContext context;
I can know the username by using context.getUserPrincipal().toString()
But I still want to know the password.By making debug I am allowed to see my password, which is password.
How can I retrieve the submitted password accessing only the WebServiceContext
?
I can see it on debug, can´t I access it directly from code?
Upvotes: 1
Views: 454
Reputation: 21004
password is a char array
, if you use toString()
you will return the memory address of the array.
instead, use String.valueOf(passwordAsCharArray);
Assuming you have the correct getters,
String.valueOf(( new ArrayList<PasswordCredential>((((Subject)context.getMessageContext().get("CLIENT_SUBJECT")).getPrivCredentials())).get(0)).getPassword());
Upvotes: 1