Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 197853 - Support all platform proxy features
Summary: Support all platform proxy features
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 2.1   Edit
Assignee: Robert Elves CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-25 14:48 EDT by Mark Phippard CLA
Modified: 2007-09-24 14:14 EDT (History)
1 user (show)

See Also:


Attachments
authenticated platform proxy support (6.08 KB, text/plain)
2007-09-11 22:35 EDT, Robert Elves CLA
no flags Details
mylyn/context/zip (13.50 KB, application/octet-stream)
2007-09-11 22:36 EDT, Robert Elves CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Phippard CLA 2007-07-25 14:48:02 EDT
WebClientUtil has code to setup proxy information for an HTTP connection.  It appears that the getPlatformProxy() method only has code for handling unauthenticated HTTP proxies.  The Eclipse preference also allows you to configure SOCKS and SSL proxy with or without authentication.  It seem like it ought to support all of these.
Comment 1 Mik Kersten CLA 2007-07-26 22:38:45 EDT
Current work-around is to use the global proxy settings instead of the repository specific ones, but agreed that this would be nice to have.  
Comment 2 Mark Phippard CLA 2007-07-26 22:57:20 EDT
Mik,  I see the opposite.  It is the global settings that do not support this.  Well, technically the settings themselves do, but the Mylyn code that looks at them will only setup an HTTP proxy without authentication.

I see some signs that in the repository-specific settings you will attempt to do this.
Comment 3 Mik Kersten CLA 2007-07-26 23:04:21 EDT
Ahhh, oops, thanks for clarifying.
Comment 4 Mik Kersten CLA 2007-09-11 13:29:55 EDT
Steffen is interested in investigating for 3.0.
Comment 5 Robert Elves CLA 2007-09-11 16:00:45 EDT
I intend to look at this one this week. 
Comment 6 Steffen Pingel CLA 2007-09-11 16:13:03 EDT
Cool :). 

Implementationwise I was thinking about adding an abstract class NetworkConfiguration that should be passed to WebClientUtil and have appropriate getters for all what is needed (socks/http/ssl proxies, list of excluded hosts...) instead of adding more parameters to setupHttpClient().
Comment 7 Robert Elves CLA 2007-09-11 16:21:29 EDT
Sounds good. I'll take a pass at it asap.
Comment 8 Robert Elves CLA 2007-09-11 22:35:05 EDT
Created attachment 78136 [details]
authenticated platform proxy support

Here's a first pass at constructing the appropriate authenticated proxy from those returned by platform given a host. Steffen, if you have a minute, could you review? 
According to the java specs we're suppose to default to higher level proxies if available so I default to https, http (then socks).  But, socks gets set by the platform if the user specifies it so for all purposes my patch configures http/s proxies with credentials if provided.

Thanks.
Comment 9 Robert Elves CLA 2007-09-11 22:36:23 EDT
Created attachment 78137 [details]
mylyn/context/zip

Context...
Comment 10 Steffen Pingel CLA 2007-09-12 11:49:33 EDT
Patch looks good. Two remarks:

- The HTTP proxy should be used for urls starting with http:// (even if an SSL proxy is also set).
- The exception list only works for HTTP/HTTPS proxies but not for socks. This needs to be handled in the socket factory otherwise the default socket factory will set the socks proxy for all hosts. It's probably a good idea to take a look at the update manager code to check if/how they explictly handle this case.
- If a SOCKS proxy is set by the user as well as an HTTP/HTTPS proxy both should be used (which is the case now).
Comment 11 Robert Elves CLA 2007-09-12 13:34:55 EDT
Thanks for reviewing Steffen. Fixed point 1 and committed. I can confirm point 2 so currently we don't honor the exception list for SOCKS. Update site appears to use socks and upon failure retrys without the SOCKS proxy. Retry in this case appears to be handled by the sun httpclient so we will have to do this manually as you suggest.
Comment 12 Robert Elves CLA 2007-09-12 14:39:13 EDT
I may not get to fixing the SOCKS exception list issue this week.  Steffen, if you have time and feel like taking this on, holler.
Comment 13 Steffen Pingel CLA 2007-09-12 14:48:47 EDT
Ok, I'll try to take a look next week.
Comment 14 Robert Elves CLA 2007-09-12 15:15:53 EDT
Great.
Comment 15 Steffen Pingel CLA 2007-09-12 15:42:54 EDT
Another thing that should be addressed:

- notify repositories that use global proxy settings of changes in proxy configuration by registering a listener with IProxyService
Comment 16 Robert Elves CLA 2007-09-12 16:06:48 EDT
 (In reply to comment #15)
> - notify repositories that use global proxy settings of changes in proxy
> configuration by registering a listener with IProxyService

This was fixed on bug#196444
Comment 17 Eugene Kuleshov CLA 2007-09-13 14:48:13 EDT
It seems like you've changed public API, i.e. meaning of the parameter of getPlatformProxy() method. It is probably minor but need to be documented.
Comment 18 Steffen Pingel CLA 2007-09-13 14:51:22 EDT
No, the old method still exists. The new method is missing an @since tag though.
Comment 19 Robert Elves CLA 2007-09-13 18:49:47 EDT
Thanks guys. I added a since 2.1 tag to the new method and added deprecation of getPlatformProxy() to Mylyn 3.0 porting guide pending changes.
Comment 20 Steffen Pingel CLA 2007-09-18 00:55:26 EDT
I have investigated this a bit further and come up with two optoins:

- Proxy configuration can only be passed in the constructor of the Socket class. That means we need to implement a custom ProtocolSocketFactory for HttpClient similar to the one we already have. 
In order to get this working with SSLSocketFactory which constructs the sockets we need to establish the proxy connection ourselves and then layer the SSL protocol on top of that:

	Socket proxySocket = new Socket(new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("proxy", 1080)));
	proxySocket.bind(new InetSocketAddress(clientHost, clientPort));
	proxySocket.connect(new InetSocketAddress(remoteHost, remotePort), 30);
			
	Socket socket = getSocketFactory().createSocket(proxySocket, remoteHost, remotePort, true);
	return socket;

- Java 5.0 introduced a ProxySelector class which allows to select proxies on a host basis. Unfortunatelly it needs to be installed JVM wide and will affect all socket communication.

I strongly prefer the first option and will try to implement the proposed approach by the end of this week.
Comment 21 Steffen Pingel CLA 2007-09-21 17:25:01 EDT
Rob, I could take a pass at this during the weekend, but the changes might be to disruptive so close to the release. Since the black list is now supported for HTTP proxies and socks proxies are configurable through the global preferences I would suggest to push the remainig enhancements to the next release cycle and continue discussion on bug 202274.
Comment 22 Robert Elves CLA 2007-09-24 14:14:58 EDT
Thanks for investigating Steffen, I agree with your recommendation regarding socket construction. Marking resolved. Further improvement for SOCKS handling taken up on bug#2202274.