From 9ef786b400910de230f25483bda6bbd3e6c31b4b Mon Sep 17 00:00:00 2001 From: relves Date: Wed, 6 Dec 2006 04:12:49 +0000 Subject: NEW - bug 166540: Task repositories cannot be used through an auth proxy https://bugs.eclipse.org/bugs/show_bug.cgi?id=166540 --- .../eclipse/mylyn/internal/tasks/core/WebClientUtil.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'org.eclipse.mylyn.tasks.core') diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WebClientUtil.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WebClientUtil.java index 8b869d3a0..f3522af7e 100644 --- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WebClientUtil.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WebClientUtil.java @@ -15,6 +15,7 @@ import java.net.InetSocketAddress; import java.net.Proxy; import java.net.Proxy.Type; +import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.auth.AuthScope; @@ -115,6 +116,18 @@ public class WebClientUtil { //System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug"); + if (proxySettings != null && !Proxy.NO_PROXY.equals(proxySettings) && !WebClientUtil.repositoryUsesHttps(repositoryUrl) && proxySettings.address() instanceof InetSocketAddress) { + InetSocketAddress address = (InetSocketAddress) proxySettings.address(); + client.getHostConfiguration().setProxy(WebClientUtil.getDomain(address.getHostName()), address.getPort()); + if (proxySettings instanceof AuthenticatedProxy) { + AuthenticatedProxy authProxy = (AuthenticatedProxy) proxySettings; + Credentials credentials = new UsernamePasswordCredentials(authProxy.getUserName(), authProxy + .getPassword()); + AuthScope proxyAuthScope = new AuthScope(address.getHostName(), address.getPort(), AuthScope.ANY_REALM); + client.getState().setProxyCredentials(proxyAuthScope, credentials); + } + } + if (user != null && password != null) { AuthScope authScope = new AuthScope(WebClientUtil.getDomain(repositoryUrl), WebClientUtil .getPort(repositoryUrl), AuthScope.ANY_REALM); -- cgit v1.2.3