You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by mi...@us.ibm.com on 2006/09/29 21:55:21 UTC
HttpServletRequest getRemoteUser() returns 'null'
Hi,
using this in my client to set authorization.....
client = new HttpClient(
new MultiThreadedHttpConnectionManager());
client.getHttpConnectionManager().getParams().
setConnectionTimeout(30000);
client.getState().setCredentials(
new AuthScope(null, -1),
new UsernamePasswordCredentials("principal", "password"));
post.setDoAuthentication(true);
trying to retrieve in my servlet using....
setRemoteUser(httpRequest.getRemoteUser()); //always returns null
but httpRequest.getRemoteUser() always returns null.
Can anyone give me some things to try. I can get it to work if I
specficly set the "Authorization" httpRequest header and use httpRequest
.getHeader(AUTHORIZATION_HEADER_NAME) in the servlet but I would like to
understand why setting the Credentials on the client doesn't work with
getRemoteUser() in my servlet.,
thanks,
miles
Re: HttpServletRequest getRemoteUser() returns 'null'
Posted by Roland Weber <ht...@dubioso.net>.
Hello Miles,
> Can anyone give me some things to try. I can get it to work if I
> specficly set the "Authorization" httpRequest header and use httpRequest
> .getHeader(AUTHORIZATION_HEADER_NAME) in the servlet but I would like to
> understand why setting the Credentials on the client doesn't work with
> getRemoteUser() in my servlet.,
Authentication will only be performed if the server requires it
(except preemtive authentication.) If access to your servlet is
not restricted in the web.xml on the server, then there will be
no authentication challenge from the server to the client, and
HttpClient has no reason whatsoever to perform authentication.
Hence, the servlet is accessed anonymously.
For details, see the J2EE or Servlet specifications. Look for
security related information in the deployment descriptor (web.xml).
http://jcp.org/en/jsr/detail?id=154
http://java.sun.com/products/servlet/
http://java.sun.com/products/servlet/docs.html
http://publib.boulder.ibm.com/infocenter/wasinfo/v5r1//index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/rweb_relinks.html
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org