RE: HttpClient + HTTPS + NTLM Authentication = HTTP/1.1 401AccessDenied
] 2004/09/30 10:05:34:122 CDT [DEBUG] header - IISExport: This web site was ex ported using IIS Export v3.0[\r][\n] 2004/09/30 10:05:34:122 CDT [DEBUG] header - Content-Length: 2878[\r][\n] 2004/09/30 10:05:34:122 CDT [DEBUG] header - Content-Type: text/html[\r][\n] 2004/09/30 10:05:34:122 CDT [DEBUG] header - Set-Cookie: ASPSESSIONIDACQABDQ S=OPDPAAPBNOGEOCJAHGNLNBKC; path=/[\r][\n] 2004/09/30 10:05:34:122 CDT [DEBUG] header - Cache-control: private[\r][\n] 2004/09/30 10:05:34:142 CDT [DEBUG] HttpMethodBase - Cookie accepted: $Version= 0; ASPSESSIONIDACQABDQS=OPDPAAPBNOGEOCJAHGNLNBKC; $Path=/ Status Line: HTTP/1.1 200 OK Status Code: 200 2004/09/30 10:05:34:142 CDT [DEBUG] HttpMethodBase - Resorting to protocol versi on default close connection policy 2004/09/30 10:05:34:142 CDT [DEBUG] HttpMethodBase - Should NOT close connection , using HTTP/1.1 2004/09/30 10:05:34:142 CDT [DEBUG] HttpConnection - Releasing connection back t o connection manager. Press any key to continue . . . Please reply at your earliest convenience. Chris -Original Message- From: Oleg Kalnichevski [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 29, 2004 5:10 PM To: Commons HttpClient Project Subject: RE: HttpClient + HTTPS + NTLM Authentication = HTTP/1.1 401AccessDenied Christopher, Ok, I see. This is weird. I can't explain it. Maybe I am just too tired right now and should go to bed. Actually it is preferred to not do a POST against a protected URL. One should do a GET or a HEAD first, get authenticated, get a session cookie, and than do a POST. Another thing to try is turning on 'expect: continue' handshake http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/ httpclient/methods/ExpectContinueMethod.html#setUseExpectHeader(boolean) Oleg On Wed, 2004-09-29 at 23:59, Burke, Christopher wrote: Oleg, Thanks for your prompt response. The main problem is that the file has not been uploaded, but the return code is 200. I am trying to post the File object 'f' to the 'F1' textbox in the following form (File f = new File(C:/secureHttp/anotherLog.log);). I believe my code is correct. I am at a loss. What could be the problem? FORM ENCTYPE=multipart/form-data METHOD=POST ACTION=siteman.asp?u=Dd=c:\im\ FONT SIZE=1 FACE=Arial, Helvetica, sans-serifNAME OF DESTINATION FOLDER ON WEB SITE/FONTBR FONT SIZE=4 FACE=Arial, Helvetica, sans-serifBc:\im\/B/FONTP FONT SIZE=1 FACE=Arial, Helvetica, sans-serifPATHNAME OF LOCAL DOCUMENTBR(SEND THIS FILE TO THE WEB SERVER)/FONTBRINPUT SIZE=30 TYPE=FILE NAME=F1P INPUT TYPE=SUBMIT VALUE=UPLOAD nbsp; INPUT TYPE=SUBMIT NAME=POSTACTION VALUE=CANCEL PFONT SIZE=2 FACE=Arial, Helvetica, sans-serifIf the B[BROWSE...]/B button is not displayed, BRyou must upgrade your A HREF=http://www.netscape.com;Netscape/A or A HREF=http://www.microsoft.com;Microsoft/A browser. /FORM/ Thanks again for your help, Oleg. Christopher -Original Message- From: Oleg Kalnichevski [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 29, 2004 4:29 PM To: Commons HttpClient Project Subject: Re: HttpClient + HTTPS + NTLM Authentication = HTTP/1.1 401Access Denied Christopher, What is exactly the problem? The authentication succeeded: HTTP/1.1 200 OK Session cookie has been sent: ASPSESSIONIDAQQBDABR=LMNNMHNALPPKIBENMNNANHGP NTLM authentication scheme is a stateful one and requires multiple challenges/responses. The first 401 Access Denied response is perfectly OK. For details see: http://davenport.sourceforge.net/ntlm.html WARNING: contains utter insanity ;-) Oleg On Wed, 2004-09-29 at 23:10, Burke, Christopher wrote: All, I need help implementing a Commons HttpClient solution to post files to a web server via an ASP page. This seems somewhat straightforward, but I am having trouble with the NTLM authentication. Code Snippet: String url = https://keystone.ibanksystems.com/carlsontest/siteman.asp?u=Yd=c:\\im\ \; NTCredentials creds = new NTCredentials(user,password,keystone.ibanksystems.com,domain); HttpClient client = new HttpClient(); MultipartPostMethod mpPostMethod = new MultipartPostMethod(url); client.getState().setCredentials(null, null, creds); File f = new File(C:/secureHttp/anotherLog.log); //mpPostMethod.addParameter(F1,f.getName(),f); mpPostMethod.addParameter(F1,f); int statusCode = client.executeMethod(mpPostMethod); System.out.println(Status Line: + mpPostMethod.getStatusLine()); System.out.println(Status Code: + statusCode); mpPostMethod.releaseConnection(); Debug Output: 2004/09/29 15:53:44:425 CDT [DEBUG] HttpClient - Java version: 1.4.2_05 2004/09/29 15:53:44:425 CDT [DEBUG] HttpClient - Java vendor: Sun Microsystems I nc. 2004/09/29 15:53:44:425 CDT [DEBUG] HttpClient - Java class path: .;..;C:\j2sdk1 .4.2_05\bin;C:\apacheCommons\commons-httpclient.jar;C:\apacheCommons\com mons-log ging-api.jar;C
RE: HttpClient + HTTPS + NTLM Authentication = HTTP/1.1 401AccessDenied
: keystone.ibanksystems.com [\r][\n] 2004/09/30 10:05:34:042 CDT [DEBUG] header - Expect: 100-continue[\r][\n] 2004/09/30 10:05:34:042 CDT [DEBUG] header - Content-Type: multipart/form-da ta; boundary=314159265358979323846[\r][\n] 2004/09/30 10:05:34:042 CDT [DEBUG] header - [\r][\n] 2004/09/30 10:05:34:072 CDT [DEBUG] header - HTTP/1.1 100 Continue[\r][\n] 2004/09/30 10:05:34:072 CDT [DEBUG] header - Server: Microsoft-IIS/5.0[\r][\ n] 2004/09/30 10:05:34:072 CDT [DEBUG] header - Date: Thu, 30 Sep 2004 15:05:30 GMT[\r][\n] 2004/09/30 10:05:34:072 CDT [DEBUG] header - IISExport: This web site was ex ported using IIS Export v3.0[\r][\n] 2004/09/30 10:05:34:072 CDT [DEBUG] HttpMethodBase - OK to continue received 2004/09/30 10:05:34:122 CDT [DEBUG] header - HTTP/1.1 200 OK[\r][\n] 2004/09/30 10:05:34:122 CDT [DEBUG] header - Server: Microsoft-IIS/5.0[\r][\ n] 2004/09/30 10:05:34:122 CDT [DEBUG] header - Date: Thu, 30 Sep 2004 15:05:30 GMT[\r][\n] 2004/09/30 10:05:34:122 CDT [DEBUG] header - IISExport: This web site was ex ported using IIS Export v3.0[\r][\n] 2004/09/30 10:05:34:122 CDT [DEBUG] header - Content-Length: 2878[\r][\n] 2004/09/30 10:05:34:122 CDT [DEBUG] header - Content-Type: text/html[\r][\n] 2004/09/30 10:05:34:122 CDT [DEBUG] header - Set-Cookie: ASPSESSIONIDACQABDQ S=OPDPAAPBNOGEOCJAHGNLNBKC; path=/[\r][\n] 2004/09/30 10:05:34:122 CDT [DEBUG] header - Cache-control: private[\r][\n] 2004/09/30 10:05:34:142 CDT [DEBUG] HttpMethodBase - Cookie accepted: $Version= 0; ASPSESSIONIDACQABDQS=OPDPAAPBNOGEOCJAHGNLNBKC; $Path=/ Status Line: HTTP/1.1 200 OK Status Code: 200 2004/09/30 10:05:34:142 CDT [DEBUG] HttpMethodBase - Resorting to protocol versi on default close connection policy 2004/09/30 10:05:34:142 CDT [DEBUG] HttpMethodBase - Should NOT close connection , using HTTP/1.1 2004/09/30 10:05:34:142 CDT [DEBUG] HttpConnection - Releasing connection back t o connection manager. Press any key to continue . . . Please reply at your earliest convenience. Chris -Original Message- From: Oleg Kalnichevski [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 29, 2004 5:10 PM To: Commons HttpClient Project Subject: RE: HttpClient + HTTPS + NTLM Authentication = HTTP/1.1 401AccessDenied Christopher, Ok, I see. This is weird. I can't explain it. Maybe I am just too tired right now and should go to bed. Actually it is preferred to not do a POST against a protected URL. One should do a GET or a HEAD first, get authenticated, get a session cookie, and than do a POST. Another thing to try is turning on 'expect: continue' handshake http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/ httpclient/methods/ExpectContinueMethod.html#setUseExpectHeader(boolean) Oleg On Wed, 2004-09-29 at 23:59, Burke, Christopher wrote: Oleg, Thanks for your prompt response. The main problem is that the file has not been uploaded, but the return code is 200. I am trying to post the File object 'f' to the 'F1' textbox in the following form (File f = new File(C:/secureHttp/anotherLog.log);). I believe my code is correct. I am at a loss. What could be the problem? FORM ENCTYPE=multipart/form-data METHOD=POST ACTION=siteman.asp?u=Dd=c:\im\ FONT SIZE=1 FACE=Arial, Helvetica, sans-serifNAME OF DESTINATION FOLDER ON WEB SITE/FONTBR FONT SIZE=4 FACE=Arial, Helvetica, sans-serifBc:\im\/B/FONTP FONT SIZE=1 FACE=Arial, Helvetica, sans-serifPATHNAME OF LOCAL DOCUMENTBR(SEND THIS FILE TO THE WEB SERVER)/FONTBRINPUT SIZE=30 TYPE=FILE NAME=F1P INPUT TYPE=SUBMIT VALUE=UPLOAD nbsp; INPUT TYPE=SUBMIT NAME=POSTACTION VALUE=CANCEL PFONT SIZE=2 FACE=Arial, Helvetica, sans-serifIf the B[BROWSE...]/B button is not displayed, BRyou must upgrade your A HREF=http://www.netscape.com;Netscape/A or A HREF=http://www.microsoft.com;Microsoft/A browser. /FORM/ Thanks again for your help, Oleg. Christopher -Original Message- From: Oleg Kalnichevski [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 29, 2004 4:29 PM To: Commons HttpClient Project Subject: Re: HttpClient + HTTPS + NTLM Authentication = HTTP/1.1 401Access Denied Christopher, What is exactly the problem? The authentication succeeded: HTTP/1.1 200 OK Session cookie has been sent: ASPSESSIONIDAQQBDABR=LMNNMHNALPPKIBENMNNANHGP NTLM authentication scheme is a stateful one and requires multiple challenges/responses. The first 401 Access Denied response is perfectly OK. For details see: http://davenport.sourceforge.net/ntlm.html WARNING: contains utter insanity ;-) Oleg On Wed, 2004-09-29 at 23:10, Burke, Christopher wrote: All, I need help implementing a Commons HttpClient solution to post files to a web server via an ASP page. This seems somewhat straightforward, but I am having trouble with the NTLM