diff options
author | slewis | 2010-04-23 23:22:51 +0000 |
---|---|---|
committer | slewis | 2010-04-23 23:22:51 +0000 |
commit | a6759754bb3ab92c5b2f8ba99006dd298264937a (patch) | |
tree | 4a3bc038a8458ab72e7c1f452f77c2c9916a2531 | |
parent | 5dc74547559ec72a207355eb4e518144da857448 (diff) | |
download | org.eclipse.ecf-a6759754bb3ab92c5b2f8ba99006dd298264937a.tar.gz org.eclipse.ecf-a6759754bb3ab92c5b2f8ba99006dd298264937a.tar.xz org.eclipse.ecf-a6759754bb3ab92c5b2f8ba99006dd298264937a.zip |
Fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=295030. Applied from patch https://bugs.eclipse.org/bugs/attachment.cgi?id=165981 from Henrich Kraemer.
3 files changed, 59 insertions, 2 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient/HttpClientProxyCredentialProvider.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient/HttpClientProxyCredentialProvider.java index 8606dc832..d0e09565f 100644 --- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient/HttpClientProxyCredentialProvider.java +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient/HttpClientProxyCredentialProvider.java @@ -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 @@ public abstract class HttpClientProxyCredentialProvider implements CredentialsPr 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 @@ public abstract class HttpClientProxyCredentialProvider implements CredentialsPr 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$ diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientFileSystemBrowser.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientFileSystemBrowser.java index 36880c0d5..5afc916fe 100644 --- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientFileSystemBrowser.java +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientFileSystemBrowser.java @@ -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 @@ public class HttpClientFileSystemBrowser extends AbstractFileSystemBrowser { 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() */ diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java index 821021c10..0b8db5e9e 100644 --- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java @@ -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 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer 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) { |