hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Kalnichevski (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1412) SystemDefaultCredentialsProvider doesn't specify RequestorType.PROXY for proxy authentication requests
Date Fri, 04 Oct 2013 20:50:42 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13786604#comment-13786604
] 

Oleg Kalnichevski commented on HTTPCLIENT-1412:
-----------------------------------------------

Mike,
The problem is that HttpClient does not differentiate proxy and server credentials because
basically one cannot have both listening on the same port.

I committed the following change to SVN trunk which may or may not fix the problem

http://svn.apache.org/viewvc?view=revision&revision=r1529291

Could you please re-test your application with the latest SVN snapshot?

Oleg

> SystemDefaultCredentialsProvider doesn't specify RequestorType.PROXY for proxy authentication
requests
> ------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1412
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1412
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.3 Final
>            Reporter: Mike Youngstrom
>            Priority: Minor
>
> I have a custom java.net.Authenticator that uses system properties to provide authentication
for proxy requests.  When using SystemDefaultCredentialsProvider with useSystemProperties()
my custom authenticator doesn't work because the getRequestorType() is set to SERVER and not
PROXY as it should be for a proxy auth request.
> Below is a simple test case that illustrates the problem if you have a proxy that requires
basic auth that you can connect to.
> {code:java}
> 	public static void main(String[] args) throws Exception {
> 		System.setProperty("http.proxyHost", "some.basic.auth.proxy");
> 		System.setProperty("http.proxyPort", "1080");
> 		System.setProperty("http.proxyUser", "someUser");
> 		System.setProperty("http.proxyPassword", "somePassword");
> 		Authenticator.setDefault(new Authenticator() {
> 			protected PasswordAuthentication getPasswordAuthentication() {
> 				//getRequestorType() == SERVER not PROXY
> 				if (getRequestorType() == RequestorType.PROXY) {
> 					String prot = getRequestingProtocol().toLowerCase();
> 					String host = System.getProperty(prot + ".proxyHost", "");
> 					String port = System.getProperty(prot + ".proxyPort", "");
> 					String user = System.getProperty(prot + ".proxyUser", "");
> 					String password = System.getProperty(prot + ".proxyPassword", "");
> 					if (getRequestingHost().equalsIgnoreCase(host)) {
> 						if (Integer.parseInt(port) == getRequestingPort()) {
> 							// We're connecting to the proxy.  Go ahead and send credentials.
> 							return new PasswordAuthentication(user,
> 									password.toCharArray());
> 						}
> 					}
> 				}
> 				return null;
> 			}
> 		});
> 		HttpClient client = HttpClients.custom().useSystemProperties().build();
> 		client.execute(new HttpHost("www.google.com"), new HttpGet("/")).getEntity().writeTo(System.out);
> 	}
> {code}



--
This message was sent by Atlassian JIRA
(v6.1#6144)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message