hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Terrell <Steven.Terr...@guideworkstv.com>
Subject RE: Preemptive Authorisation Problem
Date Tue, 06 Sep 2005 18:42:06 GMT
I'll answer the easy one, "Why does Eclipse report as deprecated..."

It's because they are deprecated, according to the documentation:

-----Original Message-----
From: Chris Ashurst [mailto:cashurst@thig.com] 
Sent: Tuesday, September 06, 2005 2:31 PM
To: httpclient-user@jakarta.apache.org
Subject: Preemptive Authorisation Problem

I've been playing around with the httpclient library for a little bit to 
try and get it to connect to a service website in use by my employer.

The problem is weird... As far as I can see, I've followed the example 
scripts and they've worked fine in terms of testing against the server 
running on my dev machine. However, when I try to connect to the service 
website, I always get the following:

[INFO] AuthChallengeProcessor - basic authentication scheme selected
[INFO] HttpMethodDirector - Failure authenticating with BASIC 

This happens regardless of whether I choose to use preemptive 
authentication or not.

As I say, on my localhost Basic auth test, I get no problems at all with 
the login (again, regardless of whether I choose preemptive login or not).

As far as I can see, the service website uses IIS, and attempting to 
read the headers through a regular login on FireFox shows that it does 
in fact use Basic authentication:

HTTP/1.x 401 Access Denied
Server: Microsoft-IIS/5.0
Date: Tue, 06 Sep 2005 18:26:26 GMT
WWW-Authenticate: Basic realm="blackweb.msbexpress.net"
Connection: close
Content-Length: 4431
Content-Type: text/html

So I know I have the correct realm set, but one thing I'm curious about 
is the fact that the username has to be sent as <domain>\<username> and 
the password includes an ampersand (&)... This is usual of an NTLM 
login, right (as far as the domain\username part)?

And one last thing... Why does Eclipse report 
setAuthenticationPreemptive and setCredentials as depreceated?

Code as follows:


import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.methods.GetMethod;

public class BasicAuth {

     public BasicAuth() {}

     public static void main(String[] args) throws Exception {
         HttpClient client = new HttpClient();

         // pass our credentials to HttpClient, they will only be used for
         // authenticating to servers with realm "realm", to 
authenticate agains
         // an arbitrary realm change this to null.
             new UsernamePasswordCredentials("domain\user", 
"pass&word")		//Duh

         GetMethod get = new 

         int status = client.executeMethod(get);

         System.out.println(status + "\n" + get.getResponseBodyAsString());




Thanks in advance


~Chris Ashurst
~~Tower Hill Insurance

To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org

To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org

View raw message