You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Mike Youngstrom (JIRA)" <ji...@apache.org> on 2013/10/04 19:29:43 UTC

[jira] [Created] (HTTPCLIENT-1412) SystemDefaultCredentialsProvider doesn't specify RequestorType.PROXY for proxy authentication requests

Mike Youngstrom created HTTPCLIENT-1412:
-------------------------------------------

             Summary: 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}
	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}

I am then attempting to use the 



--
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