### Eclipse Workspace Patch 1.0 #P org.eclipse.ecf.provider.filetransfer Index: src/org/eclipse/ecf/provider/filetransfer/browse/AbstractFileSystemBrowser.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.ecf/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/AbstractFileSystemBrowser.java,v retrieving revision 1.12 diff -u -r1.12 AbstractFileSystemBrowser.java --- src/org/eclipse/ecf/provider/filetransfer/browse/AbstractFileSystemBrowser.java 16 Mar 2009 21:37:39 -0000 1.12 +++ src/org/eclipse/ecf/provider/filetransfer/browse/AbstractFileSystemBrowser.java 23 Apr 2010 22:12:57 -0000 @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2007, 2009 Composent, Inc., IBM and others. + * Copyright (c) 2007, 2010 Composent, Inc., IBM and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,12 +12,12 @@ package org.eclipse.ecf.provider.filetransfer.browse; -import java.net.URI; +import org.eclipse.ecf.provider.filetransfer.util.ProxySetupHelper; + import java.net.URL; import java.util.Arrays; import java.util.List; import org.eclipse.core.net.proxy.IProxyData; -import org.eclipse.core.net.proxy.IProxyService; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -25,7 +25,6 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.ecf.core.security.IConnectContext; import org.eclipse.ecf.core.util.Proxy; -import org.eclipse.ecf.core.util.ProxyAddress; import org.eclipse.ecf.filetransfer.IRemoteFile; import org.eclipse.ecf.filetransfer.IRemoteFileSystemListener; import org.eclipse.ecf.filetransfer.IRemoteFileSystemRequest; @@ -33,7 +32,6 @@ import org.eclipse.ecf.filetransfer.events.IRemoteFileSystemBrowseEvent; import org.eclipse.ecf.filetransfer.events.IRemoteFileSystemEvent; import org.eclipse.ecf.filetransfer.identity.IFileID; -import org.eclipse.ecf.internal.provider.filetransfer.Activator; import org.eclipse.ecf.internal.provider.filetransfer.Messages; /** @@ -211,50 +209,13 @@ * @return proxy data selected from the proxies provided. */ protected IProxyData selectProxyFromProxies(String protocol, IProxyData[] proxies) { - if (proxies == null || proxies.length == 0) - return null; - // If only one proxy is available, then use that - if (proxies.length == 1) - return proxies[0]; - // If more than one proxy is available, then if http/https protocol then look for that - // one...if not found then use first - if (protocol.equalsIgnoreCase("http")) { //$NON-NLS-1$ - for (int i = 0; i < proxies.length; i++) { - if (proxies[i].getType().equals(IProxyData.HTTP_PROXY_TYPE)) - return proxies[i]; - } - } else if (protocol.equalsIgnoreCase("https")) { //$NON-NLS-1$ - for (int i = 0; i < proxies.length; i++) { - if (proxies[i].getType().equals(IProxyData.HTTPS_PROXY_TYPE)) - return proxies[i]; - } - } - // If we haven't found it yet, then return the first one. - return proxies[0]; + return ProxySetupHelper.selectProxyFromProxies(protocol, proxies); } protected void setupProxies() { // If it's been set directly (via ECF API) then this overrides platform settings if (proxy == null) { - try { - IProxyService proxyService = Activator.getDefault().getProxyService(); - // Only do this if platform service exists - if (proxyService != null && proxyService.isProxiesEnabled()) { - // Setup via proxyService entry - URI target = new URI(directoryOrFile.toExternalForm()); - final IProxyData[] proxies = proxyService.select(target); - IProxyData selectedProxy = selectProxyFromProxies(target.getScheme(), proxies); - if (selectedProxy != null) { - proxy = new Proxy(((selectedProxy.getType().equalsIgnoreCase(IProxyData.SOCKS_PROXY_TYPE)) ? Proxy.Type.SOCKS : Proxy.Type.HTTP), new ProxyAddress(selectedProxy.getHost(), selectedProxy.getPort()), selectedProxy.getUserId(), selectedProxy.getPassword()); - } - } - } catch (Exception e) { - // If we don't even have the classes for this (i.e. the org.eclipse.core.net plugin not available) - // then we simply log and ignore - Activator.logNoProxyWarning(e); - } catch (NoClassDefFoundError e) { - Activator.logNoProxyWarning(e); - } + proxy = ProxySetupHelper.getProxy(directoryOrFile.toExternalForm()); } if (proxy != null) setupProxy(proxy); Index: src/org/eclipse/ecf/provider/filetransfer/outgoing/AbstractOutgoingFileTransfer.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.ecf/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/outgoing/AbstractOutgoingFileTransfer.java,v retrieving revision 1.13 diff -u -r1.13 AbstractOutgoingFileTransfer.java --- src/org/eclipse/ecf/provider/filetransfer/outgoing/AbstractOutgoingFileTransfer.java 22 Oct 2009 15:22:25 -0000 1.13 +++ src/org/eclipse/ecf/provider/filetransfer/outgoing/AbstractOutgoingFileTransfer.java 23 Apr 2010 22:12:58 -0000 @@ -1,24 +1,25 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 Composent, Inc. All rights reserved. This + * Copyright (c) 2004, 2010 Composent, Inc. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: Composent, Inc. - initial API and implementation * Cloudsmith, Inc. - additional API and implementation + * Henrich Kraemer - bug 295030, Update Manager doesn't work with SOCKS proxy ******************************************************************************/ package org.eclipse.ecf.provider.filetransfer.outgoing; +import org.eclipse.ecf.provider.filetransfer.util.ProxySetupHelper; + import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.MalformedURLException; -import java.net.URI; import java.net.URL; import java.util.Map; import org.eclipse.core.net.proxy.IProxyData; -import org.eclipse.core.net.proxy.IProxyService; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IAdapterManager; import org.eclipse.core.runtime.IProgressMonitor; @@ -30,7 +31,6 @@ import org.eclipse.ecf.core.identity.Namespace; import org.eclipse.ecf.core.security.IConnectContext; import org.eclipse.ecf.core.util.Proxy; -import org.eclipse.ecf.core.util.ProxyAddress; import org.eclipse.ecf.filetransfer.FileTransferInfo; import org.eclipse.ecf.filetransfer.FileTransferJob; import org.eclipse.ecf.filetransfer.IFileTransferInfo; @@ -357,31 +357,7 @@ protected void setupProxies() { // If it's been set directly (via ECF API) then this overrides platform settings if (proxy == null) { - try { - IProxyService proxyService = Activator.getDefault().getProxyService(); - // Only do this if platform service exists - if (proxyService != null && proxyService.isProxiesEnabled()) { - // Setup via proxyService entry - URI target = new URI(getRemoteFileURL().toExternalForm()); - String type = IProxyData.SOCKS_PROXY_TYPE; - if (target.getScheme().equalsIgnoreCase(IProxyData.HTTP_PROXY_TYPE)) { - type = IProxyData.HTTP_PROXY_TYPE; - } else if (target.getScheme().equalsIgnoreCase(IProxyData.HTTPS_PROXY_TYPE)) { - type = IProxyData.HTTPS_PROXY_TYPE; - } - final IProxyData[] proxyDatas = proxyService.select(target); - final IProxyData proxyData = selectProxyFromProxies(target.getScheme(), proxyDatas); - if (proxyData != null) { - proxy = new Proxy(((type.equalsIgnoreCase(IProxyData.SOCKS_PROXY_TYPE)) ? Proxy.Type.SOCKS : Proxy.Type.HTTP), new ProxyAddress(proxyData.getHost(), proxyData.getPort()), proxyData.getUserId(), proxyData.getPassword()); - } - } - } catch (Exception e) { - // If we don't even have the classes for this (i.e. the org.eclipse.core.net plugin not available) - // then we simply log and ignore - Activator.logNoProxyWarning(e); - } catch (NoClassDefFoundError e) { - Activator.logNoProxyWarning(e); - } + proxy = ProxySetupHelper.getProxy(getRemoteFileURL().toExternalForm()); } if (proxy != null) setupProxy(proxy); Index: src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.ecf/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java,v retrieving revision 1.50 diff -u -r1.50 AbstractRetrieveFileTransfer.java --- src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java 27 Feb 2010 10:37:35 -0000 1.50 +++ src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java 23 Apr 2010 22:12:58 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 Composent, Inc. and others. + * Copyright (c) 2004, 2010 Composent, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,9 +8,12 @@ * Contributors: * Composent, Inc. - initial API and implementation * Benjamin Cabe - bug 220258 + * Henrich Kraemer - bug 295030, Update Manager doesn't work with SOCKS proxy ******************************************************************************/ package org.eclipse.ecf.provider.filetransfer.retrieve; +import org.eclipse.ecf.provider.filetransfer.util.ProxySetupHelper; + import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; @@ -18,13 +21,11 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.MalformedURLException; -import java.net.URI; import java.net.URL; import java.text.DecimalFormat; import java.util.Date; import java.util.Map; import org.eclipse.core.net.proxy.IProxyData; -import org.eclipse.core.net.proxy.IProxyService; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IAdapterManager; import org.eclipse.core.runtime.IPath; @@ -39,7 +40,6 @@ import org.eclipse.ecf.core.identity.Namespace; import org.eclipse.ecf.core.security.IConnectContext; import org.eclipse.ecf.core.util.Proxy; -import org.eclipse.ecf.core.util.ProxyAddress; import org.eclipse.ecf.filetransfer.FileTransferJob; import org.eclipse.ecf.filetransfer.IFileRangeSpecification; import org.eclipse.ecf.filetransfer.IFileTransferListener; @@ -941,26 +941,7 @@ // If it's been set directly (via ECF API) then this overrides platform // settings if (proxy == null) { - try { - IProxyService proxyService = Activator.getDefault().getProxyService(); - // Only do this if platform service exists - if (proxyService != null && proxyService.isProxiesEnabled()) { - // Setup via proxyService entry - URI target = new URI(getRemoteFileURL().toExternalForm()); - final IProxyData[] proxies = proxyService.select(target); - IProxyData selectedProxy = selectProxyFromProxies(target.getScheme(), proxies); - if (selectedProxy != null) { - proxy = new Proxy(((selectedProxy.getType().equalsIgnoreCase(IProxyData.SOCKS_PROXY_TYPE)) ? Proxy.Type.SOCKS : Proxy.Type.HTTP), new ProxyAddress(selectedProxy.getHost(), selectedProxy.getPort()), selectedProxy.getUserId(), selectedProxy.getPassword()); - } - } - } catch (Exception e) { - // If we don't even have the classes for this (i.e. the - // org.eclipse.core.net plugin not available) - // then we simply log and ignore - Activator.logNoProxyWarning(e); - } catch (NoClassDefFoundError e) { - Activator.logNoProxyWarning(e); - } + proxy = ProxySetupHelper.getProxy(getRemoteFileURL().toExternalForm()); } if (proxy != null) setupProxy(proxy); Index: src/org/eclipse/ecf/provider/filetransfer/util/JREProxyHelper.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.ecf/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/util/JREProxyHelper.java,v retrieving revision 1.1 diff -u -r1.1 JREProxyHelper.java --- src/org/eclipse/ecf/provider/filetransfer/util/JREProxyHelper.java 10 Dec 2007 18:59:00 -0000 1.1 +++ src/org/eclipse/ecf/provider/filetransfer/util/JREProxyHelper.java 23 Apr 2010 22:12:58 -0000 @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2007 Composent, Inc. and others. + * Copyright (c) 2007, 2010 Composent, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Composent, Inc. - initial API and implementation + * Henrich Kraemer - bug 295030, Update Manager doesn't work with SOCKS proxy *****************************************************************************/ package org.eclipse.ecf.provider.filetransfer.util; @@ -48,6 +49,7 @@ if (proxyPort != -1) systemProperties.setProperty(proxyPortProperty, proxyPort + ""); //$NON-NLS-1$ final String username = proxy2.getUsername(); + boolean setAuthenticator = false; if (username != null && !username.equals("")) { //$NON-NLS-1$ final String password = (proxy2.getPassword() == null) ? "" : proxy2.getPassword(); //$NON-NLS-1$ if (proxy2.hasCredentials()) { @@ -59,8 +61,19 @@ return new PasswordAuthentication(username, password.toCharArray()); } }); + setAuthenticator = true; } } + if (!setAuthenticator) { + Authenticator.setDefault(new Authenticator() { + /* (non-Javadoc) + * @see java.net.Authenticator#getPasswordAuthentication() + */ + protected PasswordAuthentication getPasswordAuthentication() { + return null; + } + }); + } } public void dispose() { Index: src/org/eclipse/ecf/provider/filetransfer/util/ProxySetupHelper.java =================================================================== RCS file: src/org/eclipse/ecf/provider/filetransfer/util/ProxySetupHelper.java diff -N src/org/eclipse/ecf/provider/filetransfer/util/ProxySetupHelper.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/ecf/provider/filetransfer/util/ProxySetupHelper.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,96 @@ +/******************************************************************************* +* Copyright (c) 2010 IBM, and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* IBM Corporation - initial API and implementation +******************************************************************************/ +package org.eclipse.ecf.provider.filetransfer.util; + +import java.net.URI; +import java.net.URL; +import org.eclipse.core.net.proxy.IProxyData; +import org.eclipse.core.net.proxy.IProxyService; +import org.eclipse.ecf.core.util.Proxy; +import org.eclipse.ecf.core.util.ProxyAddress; +import org.eclipse.ecf.internal.provider.filetransfer.Activator; + +/** + * Proxy setup utilities. + * + * @noextend This class is not intended to be extended by clients. + */ +public class ProxySetupHelper { + public static Proxy getProxy(String url) { + Proxy proxy = null; + try { + IProxyService proxyService = Activator.getDefault().getProxyService(); + // Only do this if platform service exists + if (proxyService != null && proxyService.isProxiesEnabled()) { + // Setup via proxyService entry + URI uri = new URI(url); + final IProxyData[] proxies = proxyService.select(uri); + IProxyData selectedProxy = selectProxyFromProxies(uri.getScheme(), proxies); + if (selectedProxy != null) { + proxy = new Proxy(((selectedProxy.getType().equalsIgnoreCase(IProxyData.SOCKS_PROXY_TYPE)) ? Proxy.Type.SOCKS : Proxy.Type.HTTP), new ProxyAddress(selectedProxy.getHost(), selectedProxy.getPort()), selectedProxy.getUserId(), selectedProxy.getPassword()); + } + } + } catch (Exception e) { + // If we don't even have the classes for this (i.e. the org.eclipse.core.net plugin not available) + // then we simply log and ignore + Activator.logNoProxyWarning(e); + } catch (NoClassDefFoundError e) { + Activator.logNoProxyWarning(e); + } + return proxy; + } + + public static Proxy getSocksProxy(URL url) { + String host = url.getHost(); + int port = url.getPort(); + String strURL = IProxyData.SOCKS_PROXY_TYPE + "://" + host; //$NON-NLS-1$ + if (port != -1) { + strURL += ":" + port; //$NON-NLS-1$ + } + return ProxySetupHelper.getProxy(strURL); + } + + /** + * Select a single proxy from a set of proxies available for the given host. This implementation + * selects in the following manner: 1) If proxies provided is null or array of 0 length, null + * is returned. If only one proxy is available (array of length 1) then the entry is returned. + * If proxies provided is length > 1, then if the type of a proxy in the array matches the given + * protocol (e.g. http, https), then the first matching proxy is returned. If the protocol does + * not match any of the proxies, then the *first* proxy (i.e. proxies[0]) is returned. + * + * @param protocol the target protocol (e.g. http, https, scp, etc). Will not be null. + * @param proxies the proxies to select from. May be null or array of length 0. + * @return proxy data selected from the proxies provided. + */ + public static IProxyData selectProxyFromProxies(String protocol, IProxyData[] proxies) { + if (proxies == null || proxies.length == 0) + return null; + // If only one proxy is available, then use that + if (proxies.length == 1) + return proxies[0]; + // If more than one proxy is available, then if http/https protocol then look for that + // one...if not found then use first + if (protocol.equalsIgnoreCase("http")) { //$NON-NLS-1$ + for (int i = 0; i < proxies.length; i++) { + if (proxies[i].getType().equals(IProxyData.HTTP_PROXY_TYPE)) + return proxies[i]; + } + } else if (protocol.equalsIgnoreCase("https")) { //$NON-NLS-1$ + for (int i = 0; i < proxies.length; i++) { + if (proxies[i].getType().equals(IProxyData.HTTPS_PROXY_TYPE)) + return proxies[i]; + } + } + // If we haven't found it yet, then return the first one. + return proxies[0]; + } + +} #P org.eclipse.ecf.provider.filetransfer.httpclient Index: src/org/eclipse/ecf/internal/provider/filetransfer/httpclient/HttpClientProxyCredentialProvider.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.ecf/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient/HttpClientProxyCredentialProvider.java,v retrieving revision 1.2 diff -u -r1.2 HttpClientProxyCredentialProvider.java --- src/org/eclipse/ecf/internal/provider/filetransfer/httpclient/HttpClientProxyCredentialProvider.java 18 Aug 2009 22:44:31 -0000 1.2 +++ src/org/eclipse/ecf/internal/provider/filetransfer/httpclient/HttpClientProxyCredentialProvider.java 23 Apr 2010 22:12:59 -0000 @@ -10,6 +10,9 @@ *******************************************************************************/ package org.eclipse.ecf.internal.provider.filetransfer.httpclient; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.auth.AuthScheme; @@ -23,6 +26,20 @@ abstract protected Credentials getNTLMCredentials(Proxy proxy); + private Collection provided; + + public HttpClientProxyCredentialProvider() { + provided = new HashSet(); + } + + private Object makeProvidedKey(AuthScheme scheme, String host, int port, boolean isProxyAuthenticating) { + ArrayList list = new ArrayList(3); + list.add(host); + list.add(new Integer(port)); + list.add(Boolean.valueOf(isProxyAuthenticating)); + return list; + } + /** * @throws CredentialsNotAvailableException */ @@ -34,6 +51,16 @@ if (proxy == null) { return null; } + + Object provideKey = makeProvidedKey(scheme, host, port, isProxyAuthenticating); + if (provided.contains(provideKey)) { + // HttpClient asks about credentials only once. + // If already provided don't use them again. + return null; + } + + provided.add(provideKey); + if ("ntlm".equalsIgnoreCase(scheme.getSchemeName())) { //$NON-NLS-1$ return getNTLMCredentials(proxy); } else if ("basic".equalsIgnoreCase(scheme.getSchemeName()) || //$NON-NLS-1$ Index: src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientFileSystemBrowser.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.ecf/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientFileSystemBrowser.java,v retrieving revision 1.17 diff -u -r1.17 HttpClientFileSystemBrowser.java --- src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientFileSystemBrowser.java 26 Oct 2009 19:18:35 -0000 1.17 +++ src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientFileSystemBrowser.java 23 Apr 2010 22:13:00 -0000 @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2008, 2009 Composent, Inc., IBM and others. + * Copyright (c) 2008, 2010 Composent, Inc., IBM and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,6 +12,8 @@ package org.eclipse.ecf.provider.filetransfer.httpclient; +import org.eclipse.ecf.provider.filetransfer.util.ProxySetupHelper; + import java.io.IOException; import java.net.HttpURLConnection; import java.net.Socket; @@ -158,6 +160,19 @@ return (System.getProperties().getProperty(HttpClientOptions.FORCE_NTLM_PROP) != null); } + protected void setupProxies() { + // If it's been set directly (via ECF API) then this overrides platform settings + if (proxy == null) { + // give SOCKS priority see https://bugs.eclipse.org/bugs/show_bug.cgi?id=295030#c61 + proxy = ProxySetupHelper.getSocksProxy(directoryOrFile); + if (proxy == null) { + proxy = ProxySetupHelper.getProxy(directoryOrFile.toExternalForm()); + } + } + if (proxy != null) + setupProxy(proxy); + } + /* (non-Javadoc) * @see org.eclipse.ecf.provider.filetransfer.browse.AbstractFileSystemBrowser#runRequest() */ Index: src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.ecf/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java,v retrieving revision 1.69 diff -u -r1.69 HttpClientRetrieveFileTransfer.java --- src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java 27 Feb 2010 10:37:31 -0000 1.69 +++ src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java 23 Apr 2010 22:13:00 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 Composent, Inc., IBM All rights reserved. This + * Copyright (c) 2004, 2010 Composent, Inc., IBM All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -12,6 +12,8 @@ ******************************************************************************/ package org.eclipse.ecf.provider.filetransfer.httpclient; +import org.eclipse.ecf.provider.filetransfer.util.ProxySetupHelper; + import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; @@ -418,6 +420,19 @@ return new UsernamePasswordCredentials(username, password); } + protected void setupProxies() { + // If it's been set directly (via ECF API) then this overrides platform settings + if (proxy == null) { + // give SOCKS priority see https://bugs.eclipse.org/bugs/show_bug.cgi?id=295030#c61 + proxy = ProxySetupHelper.getSocksProxy(getRemoteFileURL()); + if (proxy == null) { + proxy = ProxySetupHelper.getProxy(getRemoteFileURL().toExternalForm()); + } + } + if (proxy != null) + setupProxy(proxy); + } + protected void setupAuthentication(String urlString) throws UnsupportedCallbackException, IOException { Credentials credentials = null; if (username == null) {