Hi All,

   I am trying to do Basic Authentication against an exchange server.
Following is the code that I use.

public class HttpClientTest {
        private static final String url =
"http://mailbox.iormyxintl.com/exchange/kiranc";;

        public static void main(String[] args) {
                System.setProperty("org.apache.commons.logging.Log",
                        "org.apache.commons.logging.impl.SimpleLog");
                System.setProperty("org.apache.commons.logging.simplelog.showdatetime",
                        "true");


System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire
                        ", "debug");


System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.comm
                        ons.httpclient", "debug");
                HttpClient client = new HttpClient();
                client.getState().setCredentials( "mailbox.iormyxintl.com"
,"65.216.254.35", new UsernamePasswordCredentials(                      "abcd", 
"xyz1234" ) );
                GetMethod get = new GetMethod(url);
                int status;
                try {
                        status = client.executeMethod(  get );
                        System.out.println(status + "\n" + 
get.getResponseBodyAsString());
                } catch (HttpException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }

                get.releaseConnection();
        }
    }

This is always giving me a message "No credentials available for the 'null'
authentication realm at mailbox.iormyxintl.com".

Following is the complete log....

2004/09/13 17:11:18:895 IST [DEBUG] HttpClient - -Java version: 1.4.2_05
2004/09/13 17:11:18:895 IST [DEBUG] HttpClient - -Java vendor: Sun
Microsystems Inc.
2004/09/13 17:11:18:895 IST [DEBUG] HttpClient - -Java class path:
D:\projects\Java-Exchange\bin;D:\kiran\downloads\software\java\jakarta-slide
-webdavclient-bin-2.0\lib\antlr.jar;D:\kiran\downloads\software\java\jakarta
-slide-webdavclient-bin-2.0\lib\commons-httpclient.jar;D:\kiran\downloads\so
ftware\java\jakarta-slide-webdavclient-bin-2.0\lib\commons-logging.jar;D:\ki
ran\downloads\software\blackboard\Services\lib2\tools\servlet\bb-6.0.11.72\s
ervlet.jar
2004/09/13 17:11:18:905 IST [DEBUG] HttpClient - -Operating system
name:Windows XP
2004/09/13 17:11:18:905 IST [DEBUG] HttpClient - -Operating system
architecture: x86
2004/09/13 17:11:18:905 IST [DEBUG] HttpClient - -Operating system
version:5.1
2004/09/13 17:11:19:045 IST [DEBUG] HttpClient - -SUN 1.42: SUN (DSA
key/parameter generation; DSA signing; SHA-1, MD5 digests;
SecureRandom;X.509 certificates; JKS keystore; PKIX CertPathValidator; PKIX
CertPathBuilder; LDAP, Collection CertStores)
2004/09/13 17:11:19:045 IST [DEBUG] HttpClient - -SunJSSE 1.42: Sun JSSE
provider(implements RSA Signatures, PKCS12, SunX509 key/trust factories,
SSLv3, TLSv1)
2004/09/13 17:11:19:045 IST [DEBUG] HttpClient - -SunRsaSign 1.42: SUN's
provider for RSA signatures
2004/09/13 17:11:19:045 IST [DEBUG] HttpClient - -SunJCE 1.42: SunJCE
Provider (implements DES, Triple DES, AES, Blowfish, PBE, Diffie-Hellman,
HMAC-MD5, HMAC-SHA1)
2004/09/13 17:11:19:055 IST [DEBUG] HttpClient - -SunJGSS 1.0: Sun (Kerberos
v5)
2004/09/13 17:11:19:115 IST
[DEBUG]HttpConnection - -HttpConnection.setSoTimeout(0)
2004/09/13 17:11:19:536 IST [DEBUG] HttpMethodBase - -Execute loop try 1
2004/09/13 17:11:19:546 IST [DEBUG] wire - ->> "GET /exchange/kiranc
HTTP/1.1[\r][\n]"
2004/09/13 17:11:19:556 IST [DEBUG] HttpMethodBase - -Adding Host request
header
2004/09/13 17:11:19:576 IST [DEBUG] wire - ->> "User-Agent: Jakarta
Commons-HttpClient/2.0rc3[\r][\n]"
2004/09/13 17:11:19:576 IST [DEBUG] wire - ->> "Host:
mailbox.iormyxintl.com[\r][\n]"
2004/09/13 17:11:19:576 IST [DEBUG] wire - ->> "[\r][\n]"
2004/09/13 17:11:23:081 IST [DEBUG] wire - -<< "HTTP/1.1 401 Access
Denied[\r][\n]"
2004/09/13 17:11:23:081 IST [DEBUG] wire - -<< "Server:
Microsoft-IIS/5.0[\r][\n]"
2004/09/13 17:11:23:081 IST [DEBUG] wire - -<< "Date: Mon, 13 Sep 2004
11:19:31 GMT[\r][\n]"
2004/09/13 17:11:23:081 IST [DEBUG] wire - -<<
"WWW-Authenticate:Negotiate[\r][\n]"
2004/09/13 17:11:23:081 IST [DEBUG] wire - -<<
"WWW-Authenticate:NTLM[\r][\n]"
2004/09/13 17:11:23:091 IST [DEBUG] wire - -<< "WWW-Authenticate: Basic
realm="mailbox.iormyxintl.com"[\r][\n]"
2004/09/13 17:11:23:091 IST [DEBUG] wire - -<< "Connection: close[\r][\n]"
2004/09/13 17:11:23:091 IST [DEBUG] wire - -<< "Content-Length: 24[\r][\n]"
2004/09/13 17:11:23:091 IST [DEBUG] wire - -<< "Content-Type:
text/html[\r][\n]"
2004/09/13 17:11:23:091 IST [DEBUG] HttpMethodBase - -Authorization required
2004/09/13 17:11:23:101 IST [DEBUG] HttpAuthenticator - -Authenticating with
the default authentication realm at mailbox.iormyxintl.com
2004/09/13 17:11:23:111 IST [WARN] HttpMethodBase - -No credentials
available for the 'null' authentication realm at mailbox.iormyxintl.com


2004/09/13 17:11:23:111 IST [DEBUG] HttpMethodBase - -Buffering response
body
2004/09/13 17:11:23:131 IST [DEBUG] wire - -<< "Error: Access is Denied."
2004/09/13 17:11:23:131 IST [DEBUG] HttpMethodBase - -Should close
connection in response to Connection: close

2004/09/13 17:11:23:141 IST [DEBUG] HttpMethodBase - -Default charset used:
ISO-8859-1 401 Error: Access is Denied.




Please let me know how to do a Basic Authentication and what is wrong with
the above code. I had followed teh example code given with HTTPClient.

Regards
Kiran C


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

Reply via email to