aspose file tools
The moose likes Web Services and the fly likes WebServiceContext.getUserPrincipal() Question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "WebServiceContext.getUserPrincipal() Question" Watch "WebServiceContext.getUserPrincipal() Question" New topic
Author

WebServiceContext.getUserPrincipal() Question

Emil Jennings
Ranch Hand

Joined: Jul 09, 2010
Posts: 40
So I've seen a lot of talk regarding the example:


And questions regarding what is returned by the service being null. The usual response is that the web.xml file has to be configured to handle security. My question is this: I don't care about security and authentication, is there a way I can have the service identify what client made the request? Specifically, I make a request to the server via a client and have the Web service determine the userID of the client. I'm trying to get the service to display something like "userID <userIdName> made a request to service <serviceName> from <IPAddress>." No authentication is needed, just information displayed from the service.

Thanks in advance.
Ivan Krizsan
Bartender

Joined: Oct 04, 2006
Posts: 2193
Hi!
The IP address can be obtained from the HttpServletRequest, I believe. This will not be available if the web service is EJB-based.
Standard Java EE security will not supply the name of a user, but only that of the principal and the client needs to present credentials in order for the principal to be set.
There is, as far as I know, no mechanism in HTTP that enclose a user id with every request.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Emil Jennings
Ranch Hand

Joined: Jul 09, 2010
Posts: 40
Thanks Ivan, I made the changes (see below) based on your response and I'm now getting an IP address.

 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: WebServiceContext.getUserPrincipal() Question
 
Similar Threads
web service client needs to pass a Windows security token for authentication
Java for log in authentication? (looking for tutorial that applies to situation)
Can silent login be achieved?
Problem when querying after create or update
The server sent HTTP status code -1