Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2009-03-16 17:37:39 -0400
committerslewis2009-03-16 17:37:39 -0400
commit1c4635eded95de3e387ed8d4aeebc3c6bf3f4ea2 (patch)
treeffb553e581592ea0dad07709c7b5aa8c747f91cf /providers/bundles/org.eclipse.ecf.provider.filetransfer
parent422492f98543977f7837b05833d307d089f5460e (diff)
downloadorg.eclipse.ecf-1c4635eded95de3e387ed8d4aeebc3c6bf3f4ea2.tar.gz
org.eclipse.ecf-1c4635eded95de3e387ed8d4aeebc3c6bf3f4ea2.tar.xz
org.eclipse.ecf-1c4635eded95de3e387ed8d4aeebc3c6bf3f4ea2.zip
Released patches from 268844 and 268758 to HEAD.
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.filetransfer')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/AbstractFileSystemBrowser.java7
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/outgoing/AbstractOutgoingFileTransfer.java46
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java7
3 files changed, 50 insertions, 10 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/AbstractFileSystemBrowser.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/AbstractFileSystemBrowser.java
index fa0b39e66..331bedcdc 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/AbstractFileSystemBrowser.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/AbstractFileSystemBrowser.java
@@ -12,6 +12,7 @@
package org.eclipse.ecf.provider.filetransfer.browse;
+import java.net.URI;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
@@ -240,9 +241,9 @@ public abstract class AbstractFileSystemBrowser {
// Only do this if platform service exists
if (proxyService != null && proxyService.isProxiesEnabled()) {
// Setup via proxyService entry
- URL target = directoryOrFile;
- final IProxyData[] proxies = proxyService.getProxyDataForHost(target.getHost());
- IProxyData selectedProxy = selectProxyFromProxies(target.getProtocol(), proxies);
+ 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());
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/outgoing/AbstractOutgoingFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/outgoing/AbstractOutgoingFileTransfer.java
index 4ff4c359b..fca6b417d 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/outgoing/AbstractOutgoingFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/outgoing/AbstractOutgoingFileTransfer.java
@@ -14,6 +14,7 @@ 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;
@@ -368,14 +369,15 @@ public abstract class AbstractOutgoingFileTransfer implements IOutgoingFileTrans
// Only do this if platform service exists
if (proxyService != null && proxyService.isProxiesEnabled()) {
// Setup via proxyService entry
- URL target = getRemoteFileURL();
+ URI target = new URI(getRemoteFileURL().toExternalForm());
String type = IProxyData.SOCKS_PROXY_TYPE;
- if (target.getProtocol().equalsIgnoreCase(IProxyData.HTTP_PROXY_TYPE)) {
+ if (target.getScheme().equalsIgnoreCase(IProxyData.HTTP_PROXY_TYPE)) {
type = IProxyData.HTTP_PROXY_TYPE;
- } else if (target.getProtocol().equalsIgnoreCase(IProxyData.HTTPS_PROXY_TYPE)) {
+ } else if (target.getScheme().equalsIgnoreCase(IProxyData.HTTPS_PROXY_TYPE)) {
type = IProxyData.HTTPS_PROXY_TYPE;
}
- final IProxyData proxyData = proxyService.getProxyDataForHost(target.getHost(), 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());
}
@@ -393,6 +395,42 @@ public abstract class AbstractOutgoingFileTransfer implements IOutgoingFileTrans
}
+ /**
+ * 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. Subclasses may
+ * override if desired.
+ *
+ * @param protocol the target protocol (e.g. http, https, scp, etc). Will not be <code>null</code>.
+ * @param proxies the proxies to select from. May be <code>null</code> or array of length 0.
+ * @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];
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ecf.filetransfer.ISendFileTransferContainerAdapter#sendOutgoingRequest(org.eclipse.ecf.filetransfer.identity.IFileID, org.eclipse.ecf.filetransfer.IFileTransferInfo, org.eclipse.ecf.filetransfer.IFileTransferListener, java.util.Map)
*/
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java
index af7a93d2e..345c171ee 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java
@@ -18,6 +18,7 @@ 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.text.DecimalFormat;
import java.util.Date;
@@ -871,9 +872,9 @@ public abstract class AbstractRetrieveFileTransfer implements IIncomingFileTrans
// Only do this if platform service exists
if (proxyService != null && proxyService.isProxiesEnabled()) {
// Setup via proxyService entry
- URL target = getRemoteFileURL();
- final IProxyData[] proxies = proxyService.getProxyDataForHost(target.getHost());
- IProxyData selectedProxy = selectProxyFromProxies(target.getProtocol(), proxies);
+ 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());
}

Back to the top