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 23:13:42 UTC

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

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

Mike Youngstrom edited comment on HTTPCLIENT-1412 at 10/4/13 9:11 PM:
----------------------------------------------------------------------

I will test when a snapshot is built.  Are they here? https://repository.apache.org/content/repositories/snapshots/org/apache/httpcomponents/httpclient

That said when looking at the code it appears to me that this will not fix the problem.  Not only will the getRequestorType() == RequestorType.PROXY condition still fail, you may also be breaking anyone depending upon there being a SERVER value for RequestorType (which granted is probably nobody). :)

It seems to me that this could be fixed properly by:

* Enhancing AuthScope to support a requestor type of "proxy" or "target/server".
* Enhance AuthenticationStrategyImpl and ProxyAuthenticationStrategy to create an AuthScope with a "proxy" requestor.
* Everything should default to target/server since that is the current behavior.

It seems to me that a change like this could be done without breaking any current APIs or behavior.

I'd be willing to put together a patch if you think the changes above seem reasonable?


was (Author: youngm):
I will test when a snapshot is built.  Are there here? https://repository.apache.org/content/repositories/snapshots/org/apache/httpcomponents/httpclient

That said when looking at the code it appears to me that this will not fix the problem.  Not only will the getRequestorType() == RequestorType.PROXY condition still fail, you may also be breaking anyone depending upon there being a SERVER value for RequestorType (which granted is probably nobody). :)

It seems to me that this could be fixed properly by:

* Enhancing AuthScope to support a requestor type of "proxy" or "target/server".
* Enhance AuthenticationStrategyImpl and ProxyAuthenticationStrategy to create an AuthScope with a "proxy" requestor.
* Everything should default to target/server since that is the current behavior.

It seems to me that a change like this could be done without breaking any current APIs or behavior.

I'd be willing to put together a patch if you think the changes above seem reasonable?

> 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
>             Fix For: 4.3.2
>
>
> 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