|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
using HttpClient4.0 to retrieve files from a website.Hello,
We are trying to use HttpClient 4.0 API to connect to an internet website that requires user authentication to retrieve files. And we connect to the internet through a proxy that also needs a different user credentials. All the samples that I have seen so far, do either proxy authentication or web-site authentication but not both: a) Is the scenario I explained above, achievable using HttpClient? I guess it should be possible, but I am not sure how? Can someone help me with this And for info, the production environment will be on Linux and the development environment is Windows.. Thanks and Regards Mallika Gunturu **** DISCLAIMER**** http://www.belgacom-ics.com/maildisclaimer |
|
|
|
|
|
Re: using HttpClient4.0 to retrieve files from a website.nagamallika.gunturu@... wrote:
> Hello, > > After some more search and reading, here is the sample code that I am trying out: > > HttpClient httpclient = new DefaultHttpClient(); > HttpContext localContext = new BasicHttpContext(); > HttpGet httpget = new HttpGet("targetURL"); > > AuthScope proxyScope = new AuthScope(proxyHost, proxyPort); > AuthScope targetScope = new AuthScope(targetHost, targetPort); > > AuthState proxyAuthState = new AuthState(); > proxyAuthState.setAuthScope(proxyScope); > proxyAuthState.setCredentials(new UsernamePasswordCredentials(proxyUser, proxyPassword) ); > localContext.setAttribute(ClientContext.PROXY_AUTH_STATE, proxyAuthState); > > AuthState targetAuthState = new AuthState(); > targetAuthState.setAuthScope(targetScope); > targetAuthState.setCredentials(new UsernamePasswordCredentials(webSiteUser, webSitePassword) ); > localContext.setAttribute(ClientContext.TARGET_AUTH_STATE, targetAuthState); > > HttpHost proxy = new HttpHost(proxyHost, proxyPort); > httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); > > HttpResponse response = null; > HttpHost targetHost = new HttpHost(targetHost, targetPort, "https"); > try { > response = httpclient.execute(targetHost, httpget); > System.out.println("----------------------------------------"); > System.out.println(response.getStatusLine()); > } > catch(Exception e) { > System.out.println("Exception " + e.toString()); > > } > > And I get the following output: > Oct 26, 2009 12:02:01 PM org.apache.http.impl.client.AbstractAuthenticationHandler selectScheme > WARNING: Authentication scheme ntlm not supported > Oct 26, 2009 12:02:01 PM org.apache.http.impl.client.DefaultRequestDirector createTunnelToTarget > WARNING: Authentication error: Unable to respond to any of these challenges: {kerberos=Proxy-Authenticate: Kerberos, ntlm=Proxy-Authenticate: NTLM, negotiate=Proxy-Authenticate: Negotiate} > ---------------------------------------- > HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) > > > Can anyone please tell me whats wrong in this? > http://hc.apache.org/httpcomponents-client/ntlm.html Oleg > Regards > Mallika > > > From: GUNTURU NAGAMALLIKA (BCS/ITP) > Sent: 26 October 2009 09:38 > To: 'httpclient-users@...' > Subject: using HttpClient4.0 to retrieve files from a website. > > Hello, > > We are trying to use HttpClient 4.0 API to connect to an internet website that requires user authentication to retrieve files. And we connect to the internet through a proxy that also needs a different user credentials. > > All the samples that I have seen so far, do either proxy authentication or web-site authentication but not both: > > > a) Is the scenario I explained above, achievable using HttpClient? I guess it should be possible, but I am not sure how? Can someone help me with this > > And for info, the production environment will be on Linux and the development environment is Windows.. > > Thanks and Regards > Mallika Gunturu > > **** DISCLAIMER**** > http://www.belgacom-ics.com/maildisclaimer > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
RE: using HttpClient4.0 to retrieve files from a website.Hello,
The document at the mentioned location states that " NTLM is a proprietary authentication scheme developed by Microsoft and optimized for Windows operating system" But I am getting the same message even when the code is run on Linux. Should I then understand that the proxy I am trying to connect is Windows? Thanks Mallika -----Original Message----- From: Oleg Kalnichevski [mailto:olegk@...] Sent: 26 October 2009 12:57 To: HttpClient User Discussion Subject: Re: using HttpClient4.0 to retrieve files from a website. nagamallika.gunturu@... wrote: > Hello, > > After some more search and reading, here is the sample code that I am trying out: > > HttpClient httpclient = new DefaultHttpClient(); > HttpContext localContext = new BasicHttpContext(); > HttpGet httpget = new HttpGet("targetURL"); > > AuthScope proxyScope = new AuthScope(proxyHost, proxyPort); > AuthScope targetScope = new AuthScope(targetHost, targetPort); > > AuthState proxyAuthState = new AuthState(); > proxyAuthState.setAuthScope(proxyScope); > proxyAuthState.setCredentials(new UsernamePasswordCredentials(proxyUser, proxyPassword) ); > localContext.setAttribute(ClientContext.PROXY_AUTH_STATE, proxyAuthState); > > AuthState targetAuthState = new AuthState(); > targetAuthState.setAuthScope(targetScope); > targetAuthState.setCredentials(new UsernamePasswordCredentials(webSiteUser, webSitePassword) ); > localContext.setAttribute(ClientContext.TARGET_AUTH_STATE, targetAuthState); > > HttpHost proxy = new HttpHost(proxyHost, proxyPort); > httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); > > HttpResponse response = null; > HttpHost targetHost = new HttpHost(targetHost, targetPort, "https"); > try { > response = httpclient.execute(targetHost, httpget); > System.out.println("----------------------------------------"); > System.out.println(response.getStatusLine()); > } > catch(Exception e) { > System.out.println("Exception " + e.toString()); > > } > > And I get the following output: > Oct 26, 2009 12:02:01 PM org.apache.http.impl.client.AbstractAuthenticationHandler selectScheme > WARNING: Authentication scheme ntlm not supported > Oct 26, 2009 12:02:01 PM org.apache.http.impl.client.DefaultRequestDirector createTunnelToTarget > WARNING: Authentication error: Unable to respond to any of these challenges: {kerberos=Proxy-Authenticate: Kerberos, ntlm=Proxy-Authenticate: NTLM, negotiate=Proxy-Authenticate: Negotiate} > ---------------------------------------- > HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) > > > Can anyone please tell me whats wrong in this? > http://hc.apache.org/httpcomponents-client/ntlm.html Oleg > Regards > Mallika > > > From: GUNTURU NAGAMALLIKA (BCS/ITP) > Sent: 26 October 2009 09:38 > To: 'httpclient-users@...' > Subject: using HttpClient4.0 to retrieve files from a website. > > Hello, > > We are trying to use HttpClient 4.0 API to connect to an internet website that requires user authentication to retrieve files. And we connect to the internet through a proxy that also needs a different user credentials. > > All the samples that I have seen so far, do either proxy authentication or web-site authentication but not both: > > > a) Is the scenario I explained above, achievable using HttpClient? I guess it should be possible, but I am not sure how? Can someone help me with this > > And for info, the production environment will be on Linux and the development environment is Windows.. > > Thanks and Regards > Mallika Gunturu > > **** DISCLAIMER**** > http://www.belgacom-ics.com/maildisclaimer > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... **** DISCLAIMER**** http://www.belgacom-ics.com/maildisclaimer --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: using HttpClient4.0 to retrieve files from a website.nagamallika.gunturu@... wrote:
> Hello, > > The document at the mentioned location states that " NTLM is a proprietary authentication scheme developed by Microsoft and optimized for Windows operating system" > > But I am getting the same message even when the code is run on Linux. Should I then understand that the proxy I am trying to connect is Windows? > The proxy server you are trying to connect supports the following auth schemes: Kerberos, NTLM, Negotiate and identifies itself as 'The ISA Server'. And yes, most likely that means MS Windows. Oleg > Thanks > Mallika > > -----Original Message----- > From: Oleg Kalnichevski [mailto:olegk@...] > Sent: 26 October 2009 12:57 > To: HttpClient User Discussion > Subject: Re: using HttpClient4.0 to retrieve files from a website. > > nagamallika.gunturu@... wrote: >> Hello, >> >> After some more search and reading, here is the sample code that I am trying out: >> >> HttpClient httpclient = new DefaultHttpClient(); >> HttpContext localContext = new BasicHttpContext(); >> HttpGet httpget = new HttpGet("targetURL"); >> >> AuthScope proxyScope = new AuthScope(proxyHost, proxyPort); >> AuthScope targetScope = new AuthScope(targetHost, targetPort); >> >> AuthState proxyAuthState = new AuthState(); >> proxyAuthState.setAuthScope(proxyScope); >> proxyAuthState.setCredentials(new UsernamePasswordCredentials(proxyUser, proxyPassword) ); >> localContext.setAttribute(ClientContext.PROXY_AUTH_STATE, proxyAuthState); >> >> AuthState targetAuthState = new AuthState(); >> targetAuthState.setAuthScope(targetScope); >> targetAuthState.setCredentials(new UsernamePasswordCredentials(webSiteUser, webSitePassword) ); >> localContext.setAttribute(ClientContext.TARGET_AUTH_STATE, targetAuthState); >> >> HttpHost proxy = new HttpHost(proxyHost, proxyPort); >> httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); >> >> HttpResponse response = null; >> HttpHost targetHost = new HttpHost(targetHost, targetPort, "https"); >> try { >> response = httpclient.execute(targetHost, httpget); >> System.out.println("----------------------------------------"); >> System.out.println(response.getStatusLine()); >> } >> catch(Exception e) { >> System.out.println("Exception " + e.toString()); >> >> } >> >> And I get the following output: >> Oct 26, 2009 12:02:01 PM org.apache.http.impl.client.AbstractAuthenticationHandler selectScheme >> WARNING: Authentication scheme ntlm not supported >> Oct 26, 2009 12:02:01 PM org.apache.http.impl.client.DefaultRequestDirector createTunnelToTarget >> WARNING: Authentication error: Unable to respond to any of these challenges: {kerberos=Proxy-Authenticate: Kerberos, ntlm=Proxy-Authenticate: NTLM, negotiate=Proxy-Authenticate: Negotiate} >> ---------------------------------------- >> HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) >> >> >> Can anyone please tell me whats wrong in this? >> > > http://hc.apache.org/httpcomponents-client/ntlm.html > > Oleg > >> Regards >> Mallika >> >> >> From: GUNTURU NAGAMALLIKA (BCS/ITP) >> Sent: 26 October 2009 09:38 >> To: 'httpclient-users@...' >> Subject: using HttpClient4.0 to retrieve files from a website. >> >> Hello, >> >> We are trying to use HttpClient 4.0 API to connect to an internet website that requires user authentication to retrieve files. And we connect to the internet through a proxy that also needs a different user credentials. >> >> All the samples that I have seen so far, do either proxy authentication or web-site authentication but not both: >> >> >> a) Is the scenario I explained above, achievable using HttpClient? I guess it should be possible, but I am not sure how? Can someone help me with this >> >> And for info, the production environment will be on Linux and the development environment is Windows.. >> >> Thanks and Regards >> Mallika Gunturu >> >> **** DISCLAIMER**** >> http://www.belgacom-ics.com/maildisclaimer >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... > > > **** DISCLAIMER**** > http://www.belgacom-ics.com/maildisclaimer > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
RE: using HttpClient4.0 to retrieve files from a website.Thanks for the response.
I have changed my code as suggested in http://hc.apache.org/httpcomponents-client/ntlm.html and now, I just have the following message: HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) Here is my complete code: DefaultHttpClienthttpclient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); HttpGet httpget = new HttpGet("targetURL"); AuthScope proxyScope = new AuthScope(proxyHost, proxyPort); AuthScope targetScope = new AuthScope(targetHost, targetPort); AuthState proxyAuthState = new AuthState(); proxyAuthState.setAuthScope(proxyScope); proxyAuthState.setCredentials(new NTCredentials(proxyUser, proxypassword, localworkstation, Domain) );localContext.setAttribute(ClientContext.PROXY_AUTH_STATE, proxyAuthState); AuthState targetAuthState = new AuthState(); targetAuthState.setAuthScope(targetScope); targetAuthState.setCredentials(new UsernamePasswordCredentials(webSiteUser, webSitePassword) ); localContext.setAttribute(ClientContext.TARGET_AUTH_STATE, targetAuthState); HttpHost proxy = new HttpHost(proxyHost, proxyPort); httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); httpclient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory()); HttpResponse response = null; HttpHost targetHost = new HttpHost(targetHost, targetPort, "https"); try { response = httpclient.execute(targetHost, httpget); System.out.println("----------------------------------------"); System.out.println(response.getStatusLine()); } catch(Exception e) { System.out.println("Exception " + e.toString()); } Can you please help on this? Regards Mallika -----Original Message----- From: Oleg Kalnichevski [mailto:olegk@...] Sent: 26 October 2009 13:36 To: HttpClient User Discussion Subject: Re: using HttpClient4.0 to retrieve files from a website. nagamallika.gunturu@... wrote: > Hello, > > The document at the mentioned location states that " NTLM is a proprietary authentication scheme developed by Microsoft and optimized for Windows operating system" > > But I am getting the same message even when the code is run on Linux. Should I then understand that the proxy I am trying to connect is Windows? > The proxy server you are trying to connect supports the following auth schemes: Kerberos, NTLM, Negotiate and identifies itself as 'The ISA Server'. And yes, most likely that means MS Windows. Oleg > Thanks > Mallika > > -----Original Message----- > From: Oleg Kalnichevski [mailto:olegk@...] > Sent: 26 October 2009 12:57 > To: HttpClient User Discussion > Subject: Re: using HttpClient4.0 to retrieve files from a website. > > nagamallika.gunturu@... wrote: >> Hello, >> >> After some more search and reading, here is the sample code that I am trying out: >> >> HttpClient httpclient = new DefaultHttpClient(); >> HttpContext localContext = new BasicHttpContext(); >> HttpGet httpget = new HttpGet("targetURL"); >> >> AuthScope proxyScope = new AuthScope(proxyHost, proxyPort); >> AuthScope targetScope = new AuthScope(targetHost, targetPort); >> >> AuthState proxyAuthState = new AuthState(); >> proxyAuthState.setAuthScope(proxyScope); >> proxyAuthState.setCredentials(new UsernamePasswordCredentials(proxyUser, proxyPassword) ); >> localContext.setAttribute(ClientContext.PROXY_AUTH_STATE, proxyAuthState); >> >> AuthState targetAuthState = new AuthState(); >> targetAuthState.setAuthScope(targetScope); >> targetAuthState.setCredentials(new UsernamePasswordCredentials(webSiteUser, webSitePassword) ); >> localContext.setAttribute(ClientContext.TARGET_AUTH_STATE, targetAuthState); >> >> HttpHost proxy = new HttpHost(proxyHost, proxyPort); >> httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); >> >> HttpResponse response = null; >> HttpHost targetHost = new HttpHost(targetHost, targetPort, "https"); >> try { >> response = httpclient.execute(targetHost, httpget); >> System.out.println("----------------------------------------"); >> System.out.println(response.getStatusLine()); >> } >> catch(Exception e) { >> System.out.println("Exception " + e.toString()); >> >> } >> >> And I get the following output: >> Oct 26, 2009 12:02:01 PM org.apache.http.impl.client.AbstractAuthenticationHandler selectScheme >> WARNING: Authentication scheme ntlm not supported >> Oct 26, 2009 12:02:01 PM org.apache.http.impl.client.DefaultRequestDirector createTunnelToTarget >> WARNING: Authentication error: Unable to respond to any of these challenges: {kerberos=Proxy-Authenticate: Kerberos, ntlm=Proxy-Authenticate: NTLM, negotiate=Proxy-Authenticate: Negotiate} >> ---------------------------------------- >> HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) >> >> >> Can anyone please tell me whats wrong in this? >> > > http://hc.apache.org/httpcomponents-client/ntlm.html > > Oleg > >> Regards >> Mallika >> >> >> From: GUNTURU NAGAMALLIKA (BCS/ITP) >> Sent: 26 October 2009 09:38 >> To: 'httpclient-users@...' >> Subject: using HttpClient4.0 to retrieve files from a website. >> >> Hello, >> >> We are trying to use HttpClient 4.0 API to connect to an internet website that requires user authentication to retrieve files. And we connect to the internet through a proxy that also needs a different user credentials. >> >> All the samples that I have seen so far, do either proxy authentication or web-site authentication but not both: >> >> >> a) Is the scenario I explained above, achievable using HttpClient? I guess it should be possible, but I am not sure how? Can someone help me with this >> >> And for info, the production environment will be on Linux and the development environment is Windows.. >> >> Thanks and Regards >> Mallika Gunturu >> >> **** DISCLAIMER**** >> http://www.belgacom-ics.com/maildisclaimer >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... > > > **** DISCLAIMER**** > http://www.belgacom-ics.com/maildisclaimer > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... **** DISCLAIMER**** http://www.belgacom-ics.com/maildisclaimer --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: using HttpClient4.0 to retrieve files from a website.nagamallika.gunturu@... wrote:
> Thanks for the response. > > I have changed my code as suggested in http://hc.apache.org/httpcomponents-client/ntlm.html and now, I just have the following message: > > > HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) > > Here is my complete code: > > DefaultHttpClienthttpclient = new DefaultHttpClient(); > HttpContext localContext = new BasicHttpContext(); > HttpGet httpget = new HttpGet("targetURL"); > > AuthScope proxyScope = new AuthScope(proxyHost, proxyPort); > AuthScope targetScope = new AuthScope(targetHost, targetPort); > > AuthState proxyAuthState = new AuthState(); > proxyAuthState.setAuthScope(proxyScope); > proxyAuthState.setCredentials(new NTCredentials(proxyUser, proxypassword, localworkstation, Domain) );localContext.setAttribute(ClientContext.PROXY_AUTH_STATE, proxyAuthState); > > AuthState targetAuthState = new AuthState(); > targetAuthState.setAuthScope(targetScope); > targetAuthState.setCredentials(new UsernamePasswordCredentials(webSiteUser, webSitePassword) ); > localContext.setAttribute(ClientContext.TARGET_AUTH_STATE, targetAuthState); > > HttpHost proxy = new HttpHost(proxyHost, proxyPort); > httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); > httpclient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory()); > > HttpResponse response = null; > HttpHost targetHost = new HttpHost(targetHost, targetPort, "https"); > try { > response = httpclient.execute(targetHost, httpget); > System.out.println("----------------------------------------"); > System.out.println(response.getStatusLine()); > } > catch(Exception e) { > System.out.println("Exception " + e.toString()); > > } > > Can you please help on this? > http://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.0.x/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java http://hc.apache.org/httpcomponents-client/tutorial/html/authentication.html Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
RE: using HttpClient4.0 to retrieve files from a website.Hi Oleg,
Thanks again for the quick response. Even after reading the two links you sent across, I don't see any difference in my sample code and what is said there. However, I am not able to go beyond proxy. I get the same error message "HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )" in all the following cases: a) When no user credentials are set for the proxy b) When an incorrect user/password is set for proxy credentials c) When proper user credentials are set Hence, I deduce that somehow the credentials that I am setting on the proxy are not used. This issue is now on the critical path of the project and your support is highly appreciated. Thanks and Regards Mallika -----Original Message----- From: Oleg Kalnichevski [mailto:olegk@...] Sent: 26 October 2009 14:00 To: HttpClient User Discussion Subject: Re: using HttpClient4.0 to retrieve files from a website. nagamallika.gunturu@... wrote: > Thanks for the response. > > I have changed my code as suggested in http://hc.apache.org/httpcomponents-client/ntlm.html and now, I just have the following message: > > > HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) > > Here is my complete code: > > DefaultHttpClienthttpclient = new DefaultHttpClient(); > HttpContext localContext = new BasicHttpContext(); > HttpGet httpget = new HttpGet("targetURL"); > > AuthScope proxyScope = new AuthScope(proxyHost, proxyPort); > AuthScope targetScope = new AuthScope(targetHost, targetPort); > > AuthState proxyAuthState = new AuthState(); > proxyAuthState.setAuthScope(proxyScope); > proxyAuthState.setCredentials(new NTCredentials(proxyUser, proxypassword, localworkstation, Domain) );localContext.setAttribute(ClientContext.PROXY_AUTH_STATE, proxyAuthState); > > AuthState targetAuthState = new AuthState(); > targetAuthState.setAuthScope(targetScope); > targetAuthState.setCredentials(new UsernamePasswordCredentials(webSiteUser, webSitePassword) ); > localContext.setAttribute(ClientContext.TARGET_AUTH_STATE, targetAuthState); > > HttpHost proxy = new HttpHost(proxyHost, proxyPort); > httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); > httpclient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory()); > > HttpResponse response = null; > HttpHost targetHost = new HttpHost(targetHost, targetPort, "https"); > try { > response = httpclient.execute(targetHost, httpget); > System.out.println("----------------------------------------"); > System.out.println(response.getStatusLine()); > } > catch(Exception e) { > System.out.println("Exception " + e.toString()); > > } > > Can you please help on this? > http://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.0.x/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java http://hc.apache.org/httpcomponents-client/tutorial/html/authentication.html Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... **** DISCLAIMER**** http://www.belgacom-ics.com/maildisclaimer --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: using HttpClient4.0 to retrieve files from a website.nagamallika.gunturu@... wrote:
> Hi Oleg, > > Thanks again for the quick response. > > Even after reading the two links you sent across, I don't see any difference in my sample code and what is said there. However, I am not able to go beyond proxy. > > I get the same error message "HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )" in all the following cases: > > a) When no user credentials are set for the proxy > b) When an incorrect user/password is set for proxy credentials > c) When proper user credentials are set > > Hence, I deduce that somehow the credentials that I am setting on the proxy are not used. This issue is now on the critical path of the project and your support is highly appreciated. > Because you fail to set user credentials correctly. Why are you messing around with AuthState objects instead of just using CredentialsProvider as described in the tutorial and demonstrated in the example? You can also use context / wire logging of HttpClient to see HTTP packets generated by the client as well as to get some contextual details, which can be quite useful when troubleshooting problems. http://hc.apache.org/httpcomponents-client/logging.html Bottom line: reading the f*** manual sometime helps Oleg > Thanks and Regards > Mallika > > -----Original Message----- > From: Oleg Kalnichevski [mailto:olegk@...] > Sent: 26 October 2009 14:00 > To: HttpClient User Discussion > Subject: Re: using HttpClient4.0 to retrieve files from a website. > > nagamallika.gunturu@... wrote: >> Thanks for the response. >> >> I have changed my code as suggested in http://hc.apache.org/httpcomponents-client/ntlm.html and now, I just have the following message: >> >> >> HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) >> >> Here is my complete code: >> >> DefaultHttpClienthttpclient = new DefaultHttpClient(); >> HttpContext localContext = new BasicHttpContext(); >> HttpGet httpget = new HttpGet("targetURL"); >> >> AuthScope proxyScope = new AuthScope(proxyHost, proxyPort); >> AuthScope targetScope = new AuthScope(targetHost, targetPort); >> >> AuthState proxyAuthState = new AuthState(); >> proxyAuthState.setAuthScope(proxyScope); >> proxyAuthState.setCredentials(new NTCredentials(proxyUser, proxypassword, localworkstation, Domain) );localContext.setAttribute(ClientContext.PROXY_AUTH_STATE, proxyAuthState); >> >> AuthState targetAuthState = new AuthState(); >> targetAuthState.setAuthScope(targetScope); >> targetAuthState.setCredentials(new UsernamePasswordCredentials(webSiteUser, webSitePassword) ); >> localContext.setAttribute(ClientContext.TARGET_AUTH_STATE, targetAuthState); >> >> HttpHost proxy = new HttpHost(proxyHost, proxyPort); >> httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); >> httpclient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory()); >> >> HttpResponse response = null; >> HttpHost targetHost = new HttpHost(targetHost, targetPort, "https"); >> try { >> response = httpclient.execute(targetHost, httpget); >> System.out.println("----------------------------------------"); >> System.out.println(response.getStatusLine()); >> } >> catch(Exception e) { >> System.out.println("Exception " + e.toString()); >> >> } >> >> Can you please help on this? >> > > > http://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.0.x/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java > http://hc.apache.org/httpcomponents-client/tutorial/html/authentication.html > > Oleg > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... > > > **** DISCLAIMER**** > http://www.belgacom-ics.com/maildisclaimer > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
| Free embeddable forum powered by Nabble | Forum Help |