Bug 308035 - [Help] Help Contents gets "Connection Refused" when on VPN
or behind authenticated proxy
Change-Id: I7b243c4fe39c8c951f9e0f033c1197dd7d508e0e
Signed-off-by: caustin <ChrisAustin@us.ibm.com>
diff --git a/org.eclipse.help.base/META-INF/MANIFEST.MF b/org.eclipse.help.base/META-INF/MANIFEST.MF
index bd52a88..41cf716 100644
--- a/org.eclipse.help.base/META-INF/MANIFEST.MF
+++ b/org.eclipse.help.base/META-INF/MANIFEST.MF
@@ -44,7 +44,8 @@
org.eclipse.help;bundle-version="[3.5.0,4.0.0)";visibility:=reexport,
org.eclipse.core.expressions;bundle-version="[3.4.200,4.0.0)",
org.apache.lucene.analysis;bundle-version="[3.5.0,4.0.0)",
- org.apache.lucene.core;bundle-version="[3.5.0,4.0.0)"
+ org.apache.lucene.core;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.core.net;bundle-version="1.2.200"
Import-Package: com.ibm.icu.text,
org.eclipse.equinox.http.jetty;resolution:=optional
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/HelpProvider.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/HelpProvider.java
index 6e3c8ab..b5fd3e8 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/base/HelpProvider.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/HelpProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2014 IBM Corporation 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
@@ -15,6 +15,7 @@
import java.net.URL;
import org.eclipse.help.internal.HelpPlugin.IHelpProvider;
+import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.protocols.HelpURLStreamHandler;
/*
@@ -31,7 +32,7 @@
try {
URL helpURL = new URL("help", //$NON-NLS-1$
null, -1, href + "?lang=" + locale, HelpURLStreamHandler.getDefault()); //$NON-NLS-1$
- return helpURL.openStream();
+ return ProxyUtil.getStream(helpURL);
} catch (IOException ioe) {
return null;
}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteContextProvider.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteContextProvider.java
index bf39816..5a0d07b 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteContextProvider.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteContextProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * Copyright (c) 2006, 2014 IBM Corporation 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
@@ -18,6 +18,7 @@
import org.eclipse.help.AbstractContextProvider;
import org.eclipse.help.IContext;
import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.context.Context;
import org.eclipse.help.internal.dynamic.DocumentReader;
@@ -59,7 +60,7 @@
if(protocols[i].equals(PROTOCOL))
{
url = new URL(PROTOCOL, host[i], new Integer(port[i]).intValue(), path[i]+ PATH_CONTEXT + '?' + PARAM_ID + '=' + id + '&' + PARAM_LANG + '=' + locale);
- connection = (HttpURLConnection) url.openConnection();
+ connection = (HttpURLConnection)ProxyUtil.getConnection(url);
if (connection.getResponseCode() == 200) {
in = connection.getInputStream();
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteExtensionProvider.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteExtensionProvider.java
index 4b0388b..2758ae5 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteExtensionProvider.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteExtensionProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2014 IBM Corporation 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
@@ -22,6 +22,7 @@
import org.eclipse.help.IContentExtension;
import org.eclipse.help.internal.UAElement;
import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.dynamic.DocumentReader;
public class RemoteExtensionProvider extends AbstractContentExtensionProvider {
@@ -52,7 +53,7 @@
if(url.getProtocol().equalsIgnoreCase(PROTOCOL_HTTP))
{
- in = url.openStream();
+ in = ProxyUtil.getStream(url);
}
else
{
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteIndexProvider.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteIndexProvider.java
index c8ef685..1cae296 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteIndexProvider.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteIndexProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2014 IBM Corporation 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
@@ -21,6 +21,7 @@
import org.eclipse.help.AbstractIndexProvider;
import org.eclipse.help.IIndexContribution;
import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.base.util.ProxyUtil;
/*
* Provides the TOC data that is located on the remote infocenter, if the system
@@ -65,7 +66,7 @@
if(protocol[ic].equals(PROTOCOL_HTTP))
{
url = RemoteHelp.getURL(ic, PATH_INDEX + '?' + PARAM_LANG + '=' + locale);
- in = url.openStream();
+ in = ProxyUtil.getStream(url);
}
else
{
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteSearchManager.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteSearchManager.java
index 5f9f005..cc2eb70 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteSearchManager.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteSearchManager.java
@@ -1,5 +1,5 @@
/***************************************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others. All rights reserved. This program and the
+ * Copyright (c) 2006, 2014 IBM Corporation 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
@@ -16,6 +16,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.search.ISearchHitCollector;
import org.eclipse.help.internal.search.ISearchQuery;
import org.eclipse.help.internal.search.QueryTooComplexException;
@@ -61,7 +62,7 @@
if(protocols[i].equals(PROTOCOL_HTTP))
{
url = new URL("http", host[i], new Integer(port[i]).intValue(), path[i] + PATH_SEARCH + '?' + PARAM_PHRASE + '=' + URLCoder.encode(searchQuery.getSearchWord()) + '&' + PARAM_LANG + '=' + searchQuery.getLocale()); //$NON-NLS-1$
- in = url.openStream();
+ in = ProxyUtil.getStream(url);
}
else
{
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteTocProvider.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteTocProvider.java
index af42144..30055fb 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteTocProvider.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteTocProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * Copyright (c) 2006, 2014 IBM Corporation 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
@@ -19,6 +19,7 @@
import org.eclipse.help.AbstractTocProvider;
import org.eclipse.help.ITocContribution;
import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.base.util.ProxyUtil;
/*
* Provides the TOC data that is located on the remote infocenter, if the system
@@ -88,7 +89,7 @@
url = new URL(protocol[i], host[i], new Integer(port[i]) .intValue(),
path[i] + PATH_TOC + '?' + PARAM_LANG + '=' + locale);
- in = url.openStream();
+ in = ProxyUtil.getStream(url);
urlStr = PROTOCOL + "://"+host[i] + ":" + port[i] + path[i]; //$NON-NLS-1$ //$NON-NLS-2$
}
else
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/ProxyUtil.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/ProxyUtil.java
new file mode 100644
index 0000000..c5308ab
--- /dev/null
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/ProxyUtil.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2014 IBM Corporation 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.help.internal.base.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.net.Authenticator;
+import java.net.InetSocketAddress;
+import java.net.PasswordAuthentication;
+import java.net.Proxy;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.core.internal.net.ProxyManager;
+import org.eclipse.core.net.proxy.IProxyData;
+import org.eclipse.core.net.proxy.IProxyService;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+
+
+public class ProxyUtil {
+
+ public static boolean isAuthConnSupported()
+ {
+ try {
+ Class.forName("org.eclipse.core.net.proxy.IProxyService"); //$NON-NLS-1$
+ return true;
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public static IProxyData getProxy(URL url)
+ {
+ if (!isAuthConnSupported())
+ return null;
+
+ IProxyService service = ProxyManager.getProxyManager();
+ IProxyData data[];
+
+ if (!service.isProxiesEnabled())
+ return null;
+
+ try {
+ URI uri = url.toURI();
+ if (shouldBypass(uri))
+ return null;
+ data = service.select(uri);
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ if (data.length==0)
+ return null;
+ return data[0];
+ }
+
+ public static boolean shouldBypass(URI uri)
+ {
+ String host = uri.getHost();
+ if (host==null)
+ return true;
+
+ List<String> hosts = getProxyBypassHosts();
+ if (hosts.contains(host))
+ return true;
+ if ((host.equals("localhost") || host.equals("127.0.0.1")) && hosts.contains("<local>")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return true;
+ return false;
+ }
+
+
+ public static List<String> getProxyBypassHosts()
+ {
+ List<String> hosts = new ArrayList<String>();
+ if (!isAuthConnSupported())
+ return hosts;
+
+ IProxyService service = ProxyManager.getProxyManager();
+ String manuals[] = service.getNonProxiedHosts();
+ String natives[] = null;
+ if (service instanceof ProxyManager)
+ natives = ((ProxyManager)service).getNativeNonProxiedHosts();
+
+ for (int m=0;m<manuals.length;m++)
+ hosts.add(manuals[m]);
+ if (natives!=null)
+ for (int n=0;n<natives.length;n++)
+ hosts.add(natives[n]);
+ return hosts;
+ }
+
+ public static URLConnection getConnection(URL url) throws IOException
+ {
+ IProxyData data = getProxy(url);
+ if (data==null)
+ return url.openConnection();
+
+ if (data.isRequiresAuthentication())
+ Authenticator.setDefault(new ProxyAuthenticator(data.getUserId(),data.getPassword()));
+ else
+ Authenticator.setDefault(null);
+
+ Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(data.getHost(), data.getPort()));
+ return url.openConnection(proxy);
+ }
+
+
+ public static InputStream getStream(URL url) throws IOException
+ {
+ return getConnection(url).getInputStream();
+ }
+
+
+ private static class ProxyAuthenticator extends Authenticator {
+
+ private String user, password;
+
+ public ProxyAuthenticator(String user, String password) {
+ this.user = user;
+ this.password = password;
+ }
+
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(user, password.toCharArray());
+ }
+ }
+}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/TestConnectionUtility.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/TestConnectionUtility.java
index b5a30d6..ac84dcb 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/TestConnectionUtility.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/TestConnectionUtility.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2008, 2014 IBM Corporation 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
@@ -65,7 +65,7 @@
{
InputStream in = null;
try{
- URLConnection connection = url.openConnection();
+ URLConnection connection = ProxyUtil.getConnection(url);
setTimeout(connection, SOCKET_TIMEOUT);
connection.connect();
in = connection.getInputStream();
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/protocols/HelpURLConnection.java b/org.eclipse.help.base/src/org/eclipse/help/internal/protocols/HelpURLConnection.java
index c12e02f..00a7abe 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/protocols/HelpURLConnection.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/protocols/HelpURLConnection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation 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
@@ -35,6 +35,7 @@
import org.eclipse.help.internal.base.remote.RemoteContentLocator;
import org.eclipse.help.internal.base.remote.RemoteHelp;
import org.eclipse.help.internal.base.remote.RemoteHelpInputStream;
+import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.util.ResourceLocator;
import org.eclipse.help.internal.util.URLCoder;
import org.osgi.framework.Bundle;
@@ -408,7 +409,7 @@
if(remoteURL.startsWith(PROTOCOL_HTTP))
{
url = new URL(remoteURL + pathSuffix);
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ HttpURLConnection connection = (HttpURLConnection) ProxyUtil.getConnection(url);
in = connection.getInputStream();
}
else
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLDocParser.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLDocParser.java
index 36cc296..9e42fa5 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLDocParser.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLDocParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation 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
@@ -21,6 +21,7 @@
import java.util.StringTokenizer;
import org.apache.lucene.demo.html.HTMLParser;
+import org.eclipse.help.internal.base.util.ProxyUtil;
/**
* Parser HTML documents. Extracts document encoding from header, and delegates
@@ -62,14 +63,14 @@
* @throws IOException
*/
public void openDocument(URL url) throws IOException {
- inputStream = url.openStream();
+ inputStream = ProxyUtil.getStream(url);
String encoding = getCharsetFromHTML(inputStream);
try {
inputStream.close();
} catch (IOException closeIOE) {
}
- inputStream = url.openStream();
+ inputStream = ProxyUtil.getStream(url);
if (encoding != null) {
try {
htmlParser = new HTMLParser(new InputStreamReader(inputStream,
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java
index def26f9..a855870 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * Copyright (c) 2005, 2014 IBM Corporation 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
@@ -19,6 +19,7 @@
import org.eclipse.core.runtime.content.IContentDescriber;
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.xhtml.XHTMLContentDescriber;
import org.eclipse.help.search.IHelpSearchIndex;
import org.eclipse.help.search.ISearchDocument;
@@ -105,7 +106,7 @@
}
InputStream in = null;
try {
- in = url.openStream();
+ in = ProxyUtil.getStream(url);
return (xhtmlDescriber.describe(in, null) == IContentDescriber.VALID);
} catch (Exception e) {
// if anything goes wrong, treat it as not xhtml
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/InfoCenter.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/InfoCenter.java
index 942184e..0722485 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/InfoCenter.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/InfoCenter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation 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
@@ -19,6 +19,7 @@
import org.eclipse.core.runtime.*;
import org.eclipse.help.IHelpResource;
import org.eclipse.help.internal.base.*;
+import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.entityresolver.LocalEntityResolver;
import org.eclipse.help.search.ISearchEngine;
import org.eclipse.help.search.ISearchEngineResult;
@@ -158,7 +159,7 @@
InputStream is = null;
tocs.clear();
try {
- URLConnection connection = url.openConnection();
+ URLConnection connection = ProxyUtil.getConnection(url);
monitor.beginTask(HelpBaseResources.InfoCenter_connecting, 5);
is = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/PluginIndex.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/PluginIndex.java
index a5df71b..9466a90 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/PluginIndex.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/PluginIndex.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2014 IBM Corporation 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
@@ -23,6 +23,7 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.util.ResourceLocator;
import org.osgi.framework.Bundle;
@@ -142,7 +143,7 @@
}
InputStream in = null;
try {
- in = url.openStream();
+ in = ProxyUtil.getStream(url);
Properties prop = new Properties();
prop.load(in);
String lucene = prop
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/EclipseConnection.java b/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/EclipseConnection.java
index 5bab464..80e0126 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/EclipseConnection.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/EclipseConnection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation 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
@@ -17,6 +17,8 @@
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
+import org.eclipse.help.internal.base.util.ProxyUtil;
+
/**
* This program is used to start or stop Eclipse Infocenter application. It
* should be launched from command line.
@@ -49,8 +51,7 @@
public void connect(URL url) throws InterruptedException, Exception {
try {
- HttpURLConnection connection = (HttpURLConnection) url
- .openConnection();
+ HttpURLConnection connection = (HttpURLConnection)ProxyUtil.getConnection(url);
if (connection instanceof HttpsURLConnection) {
HttpsURLConnection secureConnection = (HttpsURLConnection) connection;
// The following allows the connection to
diff --git a/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java b/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java
index 2918c07..fbf4435 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * Copyright (c) 2010, 2014 IBM Corporation 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
@@ -22,6 +22,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.dynamic.DocumentReader;
import org.eclipse.help.internal.dynamic.ExtensionHandler;
import org.eclipse.help.internal.dynamic.IncludeHandler;
@@ -292,7 +293,7 @@
hasFilters = false;
ParsedXMLContent parsed = new ParsedXMLContent(index.getLocale());
XMLHandler handler = new XMLHandler(parsed);
- stream = url.openStream();
+ stream = ProxyUtil.getStream(url);
stream = preprocess(stream, name, index.getLocale());
parser.parse(stream, handler);
doc.addContents(parsed.getContent());
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/StatusProducer.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/StatusProducer.java
index c6f6291..77e82ac 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/StatusProducer.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/StatusProducer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 IBM Corporation and others.
+ * Copyright (c) 2009, 2014 IBM Corporation 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
@@ -25,11 +25,11 @@
import org.eclipse.help.internal.base.HelpBasePlugin;
import org.eclipse.help.internal.base.MissingContentManager;
import org.eclipse.help.internal.base.remote.RemoteStatusData;
+import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.protocols.HelpURLStreamHandler;
import org.eclipse.help.internal.util.ProductPreferences;
import org.eclipse.help.internal.webapp.data.UrlUtil;
import org.eclipse.help.internal.webapp.data.WebappPreferences;
-
import org.eclipse.core.runtime.Platform;
@@ -114,7 +114,7 @@
helpURL = new URL("help", //$NON-NLS-1$
null, -1, errorPage,
HelpURLStreamHandler.getDefault());
- return helpURL.openStream();
+ return ProxyUtil.getStream(helpURL);
} catch (MalformedURLException e) {
HelpWebappPlugin.logError("Unable to locate error page: "+errorPage, e); //$NON-NLS-1$
} catch (IOException e) {
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/TocFragmentParser.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/TocFragmentParser.java
index cd5cca6..a985a68 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/TocFragmentParser.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/TocFragmentParser.java
@@ -17,6 +17,7 @@
import javax.xml.parsers.ParserConfigurationException;
+import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.webapp.utils.JSonHelper;
import org.eclipse.help.internal.webapp.utils.XMLHelper;
import org.xml.sax.Attributes;
@@ -36,7 +37,7 @@
public void parse(URL tocURL, int level)
throws ParserConfigurationException, SAXException, IOException
{
- parse(tocURL.openStream(), level);
+ parse(ProxyUtil.getStream(tocURL), level);
}
public void parse(InputStream in, int level)
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/service/ContentService.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/service/ContentService.java
index e1873a6..3b72eee 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/service/ContentService.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/service/ContentService.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2014 IBM Corporation 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
@@ -24,6 +24,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.webapp.utils.Utils;
/**
@@ -54,7 +55,7 @@
contentURL += '?' + query;
URL url = new URL(contentURL);
- URLConnection con = url.openConnection();
+ URLConnection con = ProxyUtil.getConnection(url);
con.setAllowUserInteraction(false);
con.setDoInput(true);
con.connect();
@@ -78,7 +79,7 @@
Utils.transferContent(is, out);
out.flush();
} else {
- String response = Utils.convertStreamToString(url.openStream());
+ String response = Utils.convertStreamToString(ProxyUtil.getStream(url));
response = Utils.updateResponse(response);
PrintWriter writer = new PrintWriter(new OutputStreamWriter(out, "UTF-8")); //$NON-NLS-1$
writer.write(response);
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/service/NavService.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/service/NavService.java
index 987b239..b634cc1 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/service/NavService.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/service/NavService.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2011, 2014 IBM Corporation 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
@@ -26,6 +26,7 @@
import org.eclipse.help.ITopic;
import org.eclipse.help.base.AbstractHelpScope;
import org.eclipse.help.internal.base.scope.ScopeUtils;
+import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.webapp.data.RequestScope;
import org.eclipse.help.internal.webapp.data.UrlUtil;
import org.eclipse.help.internal.webapp.parser.NavParser;
@@ -104,7 +105,7 @@
if (query != null)
navURL += '?' + query;
URL url = new URL(navURL);
- String response = Utils.convertStreamToString(url.openStream());
+ String response = Utils.convertStreamToString(ProxyUtil.getStream(url));
response = Utils.updateResponse(response);
OutputStream out = resp.getOutputStream();