Wow! Never made that mistake.;)
Chris Ashurst wrote:

*clonk*

Yeah... Now I feel dumber than dirt for missing that.

I was wondering why when I was reading through the debug log that the base64 encoded username/password combination wasn't matching up with the one I had made locally. That one single escaped slash.

Thank you :)

Michael Becke wrote:

Hi Chris,

Try:

 new UsernamePasswordCredentials("domain\\user", "pass&word")

Mike

On 9/6/05, Chris Ashurst <[EMAIL PROTECTED]> wrote:

My apologies... For all intents and purposes, I copied the basic auth
example directly from the httpclient site.

~~~

client.getState().setCredentials(
            new AuthScope("blackweb.msbexpress.net", 80,
"blackweb.msbexpress.net", "basic"),
            new UsernamePasswordCredentials("domain\user", "pass&word")
        );
~~~

Does this seem better?

Steven Terrell wrote:

I'll answer the easy one, "Why does Eclipse report as deprecated..."

It's because they are deprecated, according to the documentation:
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/http
client/HttpState.html


--Steve
-----Original Message-----
From: Chris Ashurst [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 06, 2005 2:31 PM
To: [email protected]
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
'blackweb.msbexpress.net'@blackweb.msbexpress.net:80

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();
        client.getState().setAuthenticationPreemptive(true);

// 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.
        client.getState().setCredentials(
            "blackweb.msbexpress.net",
//Realm
            "blackweb.msbexpress.net",
//Host
            new UsernamePasswordCredentials("domain\user",
"pass&word")          //Duh
        );

        GetMethod get = new
GetMethod("http://blackweb.msbexpress.net/thig/Test";);
        get.setDoAuthentication(true);

        int status = client.executeMethod(get);

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

        get.releaseConnection();
    }

}

~~~

Thanks in advance


~Chris


--
~Chris Ashurst
~~Tower Hill Insurance
~~(352) 333 1284
[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
"In every revolution, there is one man with a vision."--Jerome Bixby

Thom Hehl
<A href="www.heavyweightsoftware.com"> www.heavyweightsoftware.com</A>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to