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

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

Snapshots do not get published to the repository automatically, so one usually 
should build and install from source locally. However I just built and 
published the latest snapshot to the repository to make testing easier for you.

I am not entirely sure that enhancing AuthScope with an extra attribute is the 
right thing to do. Can someone explain me why one would want to assign 
different credentials for the same unique combination of host, port, realm and 
auth scheme, when the port is perfectly enough to distinguish proxy and server 
running on the same host?

If my latest patch fails to address the issue my plan is simply to call the 
Authenticator#requestPasswordAuthentication twice, once with 
RequestorType.PROXY and another one with RequestorType.SERVER parameter.

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
>             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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to