Hi Oleg,

Thank you for the response. I have tried that and I got the same error.
I agree that this is not httpclient issue, I have used the same code and
replace the url to google.com for example and I am able to receive
cookie


2009/05/29 12:09:53:507 PDT [DEBUG] DefaultHttpParams - Set parameter
http.useragent = Jakarta Commons-HttpClient/3.1
2009/05/29 12:09:53:507 PDT [DEBUG] DefaultHttpParams - Set parameter
http.protocol.version = HTTP/1.1
2009/05/29 12:09:53:507 PDT [DEBUG] DefaultHttpParams - Set parameter
http.connection-manager.class = class
org.apache.commons.httpclient.SimpleHttpConnectionManager
2009/05/29 12:09:53:507 PDT [DEBUG] DefaultHttpParams - Set parameter
http.protocol.cookie-policy = default
2009/05/29 12:09:53:507 PDT [DEBUG] DefaultHttpParams - Set parameter
http.protocol.element-charset = US-ASCII
2009/05/29 12:09:53:507 PDT [DEBUG] DefaultHttpParams - Set parameter
http.protocol.content-charset = ISO-8859-1
2009/05/29 12:09:53:507 PDT [DEBUG] DefaultHttpParams - Set parameter
http.method.retry-handler =
org.apache.commons.httpclient.defaulthttpmethodretryhand...@c05d3b
2009/05/29 12:09:53:507 PDT [DEBUG] DefaultHttpParams - Set parameter
http.dateparser.patterns = [EEE, dd MMM yyyy HH:mm:ss zzz, EEEE,
dd-MMM-yy HH:mm:ss zzz, EEE MMM d HH:mm:ss yyyy, EEE, dd-MMM-yyyy
HH:mm:ss z, EEE, dd-MMM-yyyy HH-mm-ss z, EEE, dd MMM yy HH:mm:ss z, EEE
dd-MMM-yyyy HH:mm:ss z, EEE dd MMM yyyy HH:mm:ss z, EEE dd-MMM-yyyy
HH-mm-ss z, EEE dd-MMM-yy HH:mm:ss z, EEE dd MMM yy HH:mm:ss z,
EEE,dd-MMM-yy HH:mm:ss z, EEE,dd-MMM-yyyy HH:mm:ss z, EEE, dd-MM-yyyy
HH:mm:ss z]
2009/05/29 12:09:53:522 PDT [DEBUG] DefaultHttpParams - Set parameter
http.useragent = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10
2009/05/29 12:09:53:522 PDT [DEBUG] DefaultHttpParams - Set parameter
http.connection.timeout = 60000
2009/05/29 12:09:53:554 PDT [DEBUG] DefaultHttpParams - Set parameter
http.protocol.cookie-policy = compatibility
2009/05/29 12:09:53:554 PDT [DEBUG] HttpConnection - Open connection to
www.google.com:80
2009/05/29 12:09:53:601 PDT [DEBUG] header - >> "GET / HTTP/1.1[\r][\n]"
2009/05/29 12:09:53:601 PDT [DEBUG] HttpMethodBase - Adding Host request
header
2009/05/29 12:09:53:616 PDT [DEBUG] header - >> "User-Agent: Mozilla/5.0
(Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316
Firefox/3.0.10[\r][\n]"
2009/05/29 12:09:53:616 PDT [DEBUG] header - >> "Host:
www.google.com[\r][\n]"
2009/05/29 12:09:53:616 PDT [DEBUG] header - >> "[\r][\n]"
2009/05/29 12:09:53:663 PDT [DEBUG] header - << "HTTP/1.1 200
OK[\r][\n]"
2009/05/29 12:09:53:663 PDT [DEBUG] header - << "HTTP/1.1 200
OK[\r][\n]"
2009/05/29 12:09:53:663 PDT [DEBUG] header - << "Cache-Control: private,
max-age=0[\r][\n]"
2009/05/29 12:09:53:663 PDT [DEBUG] header - << "Date: Fri, 29 May 2009
19:09:53 GMT[\r][\n]"
2009/05/29 12:09:53:663 PDT [DEBUG] header - << "Expires: -1[\r][\n]"
2009/05/29 12:09:53:663 PDT [DEBUG] header - << "Content-Type:
text/html; charset=UTF-8[\r][\n]"
2009/05/29 12:09:53:663 PDT [DEBUG] header - << "Set-Cookie:
PREF=ID=1f168d3afb1537d4:TM=1243624193:LM=1243624193:S=fIMcQnLeZnB_XQTt;
expires=Sun, 29-May-2011 19:09:53 GMT; path=/;
domain=.google.com[\r][\n]"
2009/05/29 12:09:53:663 PDT [DEBUG] header - << "Server: gws[\r][\n]"
2009/05/29 12:09:53:663 PDT [DEBUG] header - << "Transfer-Encoding:
chunked[\r][\n]"
2009/05/29 12:09:53:663 PDT [DEBUG] header - << "[\r][\n]"
2009/05/29 12:09:53:757 PDT [DEBUG] HttpMethodBase - Cookie accepted:
"PREF=ID=1f168d3afb1537d4:TM=1243624193:LM=1243624193:S=fIMcQnLeZnB_XQTt
"

This should be a particular setting with IIS. Has anyone get httpclient
to work with Microsoft IIS. If so, can you please send me a header
snipet such that I can compare that with mine.

Regards,

Ridwan

-----Original Message-----
From: Oleg Kalnichevski [mailto:ol...@apache.org] 
Sent: Friday, May 29, 2009 2:01 AM
To: HttpClient User Discussion
Subject: Re: HttpClient Cookies and Exchange Server FBA Authentication

On Thu, May 28, 2009 at 07:25:27PM -0700, Ridwan Tan (ridtan) wrote:
> Hello,
> 
>  
> 
> I am trying to use httpclient to login to Exchange OWA with FBA
> authentication enabled. I am able to perform FBA authentication.
> Exchange kept returning an error saying that cookie is not enabled by
> the browser. I have read the primer and I have seen many posts around
> this area. I have copied some of the solution, but I can't get it to
> work somehow. I have copied the code snipet that I used as well as the
> debug output of the wire. I am just wondering if anyone encounters
> similar issue or know what's wrong with the code below. I have tried
all
> the combination of CookiePolicy as well and I still get the same
> results.
> 
>  
> 
> I thank you in advance for your time.
> 
>  
> 
> Regards,
> 
>  
> 
> Ridwan
> 

Ridwan,

I _suspect_ this problem has nothing to do with the cookie policy used
by
HttpClient. Apparently the site rejects the request based purely on the
content
of the User-Agent header. Try  masquerading HttpClient as a browser such
as IE
by using the same User-Agent string the site is known to work with.

Hope this helps

Oleg


>  
> 
>         StringBuffer sb = new StringBuffer();
> 
>         sb.append("<somehostname>");
> 
>  
> 
>         System.out.println(sb.toString());
> 
>         HttpClient http = new HttpClient();
> 
>         
> 
>         HttpConnectionParams connParams =
> http.getHttpConnectionManager().getParams();
> 
>         connParams.setConnectionTimeout(60*1000);
> 
>  
> 
>         HttpClientParams params = new HttpClientParams();
> 
>         HttpState initialState = new HttpState();
> 
>  
> 
>         // and then added to your HTTP state instance
> 
>         http.setParams(params);
> 
>         http.setState(initialState);
> 
>  
> 
>         GetMethod get = new GetMethod(sb.toString());
> 
>  
> get.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
> 
>        
> 
>         http.executeMethod(get);
> 
>         get.getResponseBodyAsString();
> 
>         get.releaseConnection();
> 
>         //post execution follow
> 
>  
> 
>  
> 
>  
> 
> 2009/05/28 19:04:21:085 PDT [DEBUG] HttpClient - Java version:
1.5.0_07
> 
> 2009/05/28 19:04:21:085 PDT [DEBUG] HttpClient - Java vendor: Sun
> Microsystems Inc.
> 
> 2009/05/28 19:04:21:085 PDT [DEBUG] HttpClient - Java class path:
> 2009/05/28 19:04:21:085 PDT [DEBUG] HttpClient - Operating system
name:
> Windows XP
> 
> 2009/05/28 19:04:21:085 PDT [DEBUG] HttpClient - Operating system
> architecture: x86
> 
> 2009/05/28 19:04:21:085 PDT [DEBUG] HttpClient - Operating system
> version: 5.1
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] HttpClient - SUN 1.5: SUN (DSA
> key/parameter generation; DSA signing; SHA-1, MD5 digests;
SecureRandom;
> X.509 certificates; JKS keystore; PKIX CertPathValidator; PKIX
> CertPathBuilder; LDAP, Collection CertStores)
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] HttpClient - SunRsaSign 1.5: Sun
RSA
> signature provider
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] HttpClient - SunJSSE 1.5: Sun JSSE
> provider(PKCS12, SunX509 key/trust factories, SSLv3, TLSv1)
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] HttpClient - SunJCE 1.5: SunJCE
> Provider (implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR,
RC2,
> PBE, Diffie-Hellman, HMAC)
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] HttpClient - SunJGSS 1.0: Sun
> (Kerberos v5)
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] HttpClient - SunSASL 1.5: Sun SASL
> provider(implements client mechanisms for: DIGEST-MD5, GSSAPI,
EXTERNAL,
> PLAIN, CRAM-MD5; server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5)
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] DefaultHttpParams - Set parameter
> http.useragent = Jakarta Commons-HttpClient/3.1
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] DefaultHttpParams - Set parameter
> http.protocol.version = HTTP/1.1
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] DefaultHttpParams - Set parameter
> http.connection-manager.class = class
> org.apache.commons.httpclient.SimpleHttpConnectionManager
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] DefaultHttpParams - Set parameter
> http.protocol.cookie-policy = default
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] DefaultHttpParams - Set parameter
> http.protocol.element-charset = US-ASCII
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] DefaultHttpParams - Set parameter
> http.protocol.content-charset = ISO-8859-1
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] DefaultHttpParams - Set parameter
> http.method.retry-handler =
> org.apache.commons.httpclient.defaulthttpmethodretryhand...@c05d3b
> 
> 2009/05/28 19:04:21:163 PDT [DEBUG] DefaultHttpParams - Set parameter
> http.dateparser.patterns = [EEE, dd MMM yyyy HH:mm:ss zzz, EEEE,
> dd-MMM-yy HH:mm:ss zzz, EEE MMM d HH:mm:ss yyyy, EEE, dd-MMM-yyyy
> HH:mm:ss z, EEE, dd-MMM-yyyy HH-mm-ss z, EEE, dd MMM yy HH:mm:ss z,
EEE
> dd-MMM-yyyy HH:mm:ss z, EEE dd MMM yyyy HH:mm:ss z, EEE dd-MMM-yyyy
> HH-mm-ss z, EEE dd-MMM-yy HH:mm:ss z, EEE dd MMM yy HH:mm:ss z,
> EEE,dd-MMM-yy HH:mm:ss z, EEE,dd-MMM-yyyy HH:mm:ss z, EEE, dd-MM-yyyy
> HH:mm:ss z]
> 
> 2009/05/28 19:04:21:178 PDT [DEBUG] DefaultHttpParams - Set parameter
> http.connection.timeout = 60000
> 
> 2009/05/28 19:04:21:210 PDT [DEBUG] DefaultHttpParams - Set parameter
> http.protocol.cookie-policy = compatibility
> 
> 2009/05/28 19:04:21:225 PDT [DEBUG] HttpConnection - Open connection
to
> <hostname>
> 
> 2009/05/28 19:04:21:256 PDT [DEBUG] header - >> "GET
> /owa/auth/logon.aspx HTTP/1.1[\r][\n]"
> 
> 2009/05/28 19:04:21:256 PDT [DEBUG] HttpMethodBase - Adding Host
request
> header
> 
> 2009/05/28 19:04:21:272 PDT [DEBUG] header - >> "User-Agent: Jakarta
> Commons-HttpClient/3.1[\r][\n]"
> 
> 2009/05/28 19:04:21:272 PDT [DEBUG] header - >> "Host:
> <somehostname>[\r][\n]"
> 
> 2009/05/28 19:04:21:272 PDT [DEBUG] header - >> "[\r][\n]"
> 
> 2009/05/28 19:04:21:272 PDT [DEBUG] header - << "HTTP/1.1 200
> OK[\r][\n]"
> 
> 2009/05/28 19:04:21:272 PDT [DEBUG] header - << "HTTP/1.1 200
> OK[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] header - << "Cache-Control:
> no-cache[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] header - << "Pragma:
> no-cache[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] header - << "Content-Length:
> 8346[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] header - << "Content-Type:
> text/html; charset=utf-8[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] header - << "Expires: -1[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] header - << "Server:
> Microsoft-IIS/6.0[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] header - << "X-Powered-By:
> ASP.NET[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] header - << "X-AspNet-Version:
> 2.0.50727[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] header - << "X-OWA-Version:
> 8.1.240.5[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] header - << "Date: Fri, 29 May
2009
> 02:03:58 GMT[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] header - << "[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] HttpMethodBase - Buffering
response
> body
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] content - << "<!-- Copyright (c)
> 2006 Microsoft Corporation.  All rights reserved. -->[\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] content - << "<!-- OwaPage =
> ASP.auth_logon_aspx -->[\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] content - << "[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] content - << "<!--
> {57A118C6-2DA9-419d-BE9A-F92B0F9A418B} --> [\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] content - << "[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] content - << "<!DOCTYPE HTML
PUBLIC
> "-//W3C//DTD HTML 4.0 Transitional//EN"> [\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] content - << "<html>[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] content - << "<head>[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] content - << "<meta
> http-equiv="Content-Type" content="text/html; CHARSET=utf-8">[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] content - << "<meta name="Robots"
> content="NOINDEX, NOFOLLOW">[\r][\n]"
> 
> 2009/05/28 19:04:21:288 PDT [DEBUG] content - << "<title>Microsoft
> Exchange - Outlook Web Access</title>[\r][\n]"
> 
> ... //the login page
> 
> 009/05/28 19:04:21:303 PDT [DEBUG] content - <<
> "[0x9][0x9][0x9][0x9][0x9]<td><br>Please enable cookies for this web
> site.<br><br>Cookies are currently disabled by your browser. Outlook
Web
> Access requires that cookies be enabled. <br><br>If you are using
> Microsoft Internet Explorer 6 or later, open Internet Options from the
> Tools menu. Click the Privacy tab, and then click Sites. Type the
> address for Outlook Web Access into the field, click Allow, and then
> click OK to save your changes.<br><br><br></td>[\r][\n]"
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] content - <<
> "[0x9][0x9][0x9][0x9]</tr>[\r][\n]"
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] content - <<
> "[0x9][0x9][0x9][0x9]<tr><td><hr></td></tr>[\r][\n]"
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] content - <<
> "[0x9][0x9][0x9][0x9]<tr>[\r][\n]"
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] content - <<
> "[0x9][0x9][0x9][0x9][0x9]<td align="right" class="txtpad">[\r][\n]"
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] content - <<
> "[0x9][0x9][0x9][0x9][0x9][\r][\n]"
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] content - <<
> "[0x9][0x9][0x9][0x9][0x9][0x9]<input type="button" class="btn"
> style="float: right" value="Retry" onclick="clkRtry()">[\r][\n]"
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] content - <<
> "[0x9][0x9][0x9][0x9][0x9][\r][\n]"
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] content - <<
> "[0x9][0x9][0x9][0x9][0x9]</td>[\r][\n]"
> 
> ...
> 
> 009/05/28 19:04:21:303 PDT [DEBUG] content - << "</table>[\r][\n]"
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] content - << "</form>[\r][\n]"
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] content - << "[\r][\n]"
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] content - << "</body>[\r][\n]"
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] content - << "</html>[\r][\n]"
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] HttpMethodBase - Resorting to
> protocol version default close connection policy
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] HttpMethodBase - Should NOT close
> connection, using HTTP/1.1
> 
> 2009/05/28 19:04:21:303 PDT [DEBUG] HttpConnection - Releasing
> connection back to connection manager.
> 
>  
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org

Reply via email to