Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2015-10-06 13:02:46 -0400
committerslewis2015-10-06 13:02:46 -0400
commit0f564abd3db01c32ef168a8399d81c5ced1029e6 (patch)
tree36072362ee4ee5532030e94cd8b9405acea8bdd9
parent925c4a649c5b3b36065cac38c296f889b9126ed5 (diff)
downloadorg.eclipse.ecf-0f564abd3db01c32ef168a8399d81c5ced1029e6.tar.gz
org.eclipse.ecf-0f564abd3db01c32ef168a8399d81c5ced1029e6.tar.xz
org.eclipse.ecf-0f564abd3db01c32ef168a8399d81c5ced1029e6.zip
Patch applied from bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=478655. All tests pass successfully. Also updated bundle version and package version because of presense of new SNIAwareHttpClient class. Change-Id: I84454cf459da9e8dca6915e4d908d6bba10bb7bf
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF4
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientBrowseFileTransferFactory.java21
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransferFactory.java3
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/SNIAwareHttpClient.java73
4 files changed, 77 insertions, 24 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF
index 1b5a2a642..00f934b74 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.ecf.provider.filetransfer.httpclient4;singleton:=true
-Bundle-Version: 1.0.2000.qualifier
+Bundle-Version: 1.1.0.qualifier
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.ecf.internal.provider.filetransfer.httpclient4.Activator
Require-Bundle: org.eclipse.equinox.common,
@@ -40,7 +40,7 @@ Import-Package: org.apache.http;version="4.1.0",
org.osgi.service.url;version="1.0.0",
org.osgi.util.tracker;version="1.3.2"
Export-Package: org.eclipse.ecf.internal.provider.filetransfer.httpclient4;x-internal:=true,
- org.eclipse.ecf.provider.filetransfer.httpclient4;version="1.0.0"
+ org.eclipse.ecf.provider.filetransfer.httpclient4;version="1.1.0"
Bundle-Vendor: %plugin.provider
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientBrowseFileTransferFactory.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientBrowseFileTransferFactory.java
index 6f287eaaa..a9b55f5fa 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientBrowseFileTransferFactory.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientBrowseFileTransferFactory.java
@@ -13,14 +13,6 @@ package org.eclipse.ecf.provider.filetransfer.httpclient4;
import java.net.MalformedURLException;
import java.net.URL;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.scheme.PlainSocketFactory;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.ssl.SSLContexts;
-import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.conn.BasicClientConnectionManager;
import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.Namespace;
@@ -57,18 +49,7 @@ public class HttpClientBrowseFileTransferFactory implements IRemoteFileSystemBro
throw new RemoteFileSystemException(NLS.bind("Exception creating URL for {0}", directoryOrFileId)); //$NON-NLS-1$
}
- HttpClientFileSystemBrowser browser = new HttpClientFileSystemBrowser(new DefaultHttpClient() {
- @Override
- protected ClientConnectionManager createClientConnectionManager() {
- SSLSocketFactory factory = new SSLSocketFactory(SSLContexts.createSystemDefault(), SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
-
- final SchemeRegistry registry = new SchemeRegistry();
- registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
- registry.register(new Scheme("https", 443, factory));
-
- return new BasicClientConnectionManager(registry);
- }
- }, directoryOrFileId, listener, url, connectContext, proxy);
+ HttpClientFileSystemBrowser browser = new HttpClientFileSystemBrowser(new SNIAwareHttpClient(), directoryOrFileId, listener, url, connectContext, proxy);
return browser.sendBrowseRequest();
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransferFactory.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransferFactory.java
index 27276aa20..5f3162364 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransferFactory.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransferFactory.java
@@ -16,7 +16,6 @@ import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLContexts;
import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.SingleClientConnManager;
import org.eclipse.ecf.filetransfer.service.IRetrieveFileTransfer;
import org.eclipse.ecf.filetransfer.service.IRetrieveFileTransferFactory;
@@ -31,6 +30,6 @@ public class HttpClientRetrieveFileTransferFactory implements IRetrieveFileTrans
registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
registry.register(new Scheme("https", 443, factory));
- return new HttpClientRetrieveFileTransfer(new DefaultHttpClient(new SingleClientConnManager(registry)));
+ return new HttpClientRetrieveFileTransfer(new SNIAwareHttpClient(new SingleClientConnManager(registry)));
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/SNIAwareHttpClient.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/SNIAwareHttpClient.java
new file mode 100644
index 000000000..1c531c805
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/SNIAwareHttpClient.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright (c) 2015 University of York. 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:
+* Antonio Garcia-Dominguez - initial API and implementation
+******************************************************************************/
+package org.eclipse.ecf.provider.filetransfer.httpclient4;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import javax.net.ssl.SSLSocket;
+import org.apache.http.HttpHost;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLContexts;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.BasicClientConnectionManager;
+import org.apache.http.impl.conn.SingleClientConnManager;
+import org.apache.http.protocol.HttpContext;
+
+/**
+ * @since 1.1
+ */
+final class SNIAwareHttpClient extends DefaultHttpClient {
+
+ public SNIAwareHttpClient() {
+ // default constructor
+ }
+
+ public SNIAwareHttpClient(SingleClientConnManager singleClientConnManager) {
+ super(singleClientConnManager);
+ }
+
+ @Override
+ protected ClientConnectionManager createClientConnectionManager() {
+ SSLSocketFactory factory = new SSLSocketFactory(SSLContexts.createSystemDefault(), SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER) {
+ @Override
+ public Socket connectSocket(int connectTimeout, Socket socket, HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpContext context) throws IOException, ConnectTimeoutException {
+
+ // This is to work around HttpClient bug as described
+ // in description and comments here:
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=478655
+ if (socket instanceof SSLSocket) {
+ try {
+ final Method mSetHost = socket.getClass().getMethod("setHost", String.class);
+ mSetHost.setAccessible(true);
+ mSetHost.invoke(socket, host.getHostName());
+ } catch (NoSuchMethodException ex) {
+ } catch (IllegalAccessException ex) {
+ } catch (InvocationTargetException ex) {
+ }
+ }
+ return super.connectSocket(connectTimeout, socket, host, remoteAddress, localAddress, context);
+ }
+ };
+
+ final SchemeRegistry registry = new SchemeRegistry();
+ registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
+ registry.register(new Scheme("https", 443, factory));
+
+ return new BasicClientConnectionManager(registry);
+ }
+} \ No newline at end of file

Back to the top