From 96c4a550291bfaf4aae8de755e59493f5ea3e5e9 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Wed, 17 Feb 2016 13:54:29 +0000 Subject: [PATCH] HTTPCLIENT-1718, HTTPCLEINT-1719: credentials fix to allow proxy authetication Contributed by 212427891 git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.5.x@1730836 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/http/osgi/impl/OSGiCredentialsProvider.java | 6 ++---- .../org/apache/http/osgi/impl/OSGiProxyConfiguration.java | 2 +- .../apache/http/osgi/impl/OSGiProxyConfigurationTest.java | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiCredentialsProvider.java b/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiCredentialsProvider.java index f2af64011..e9d6e5147 100644 --- a/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiCredentialsProvider.java +++ b/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiCredentialsProvider.java @@ -72,11 +72,9 @@ final class OSGiCredentialsProvider implements CredentialsProvider { final ProxyConfiguration proxyConfiguration = (ProxyConfiguration) proxyConfigurationObject; if (proxyConfiguration.isEnabled()) { final AuthScope actual = new AuthScope(proxyConfiguration.getHostname(), proxyConfiguration.getPort()); - if (authscope.equals(actual)) { - return new UsernamePasswordCredentials(proxyConfiguration.getUsername(), - proxyConfiguration.getPassword()); + if (authscope.match(actual) >= 12) { + return new UsernamePasswordCredentials(proxyConfiguration.getUsername(), proxyConfiguration.getPassword()); } - } } } diff --git a/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiProxyConfiguration.java b/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiProxyConfiguration.java index 00ae3a0be..a132c735a 100644 --- a/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiProxyConfiguration.java +++ b/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiProxyConfiguration.java @@ -63,7 +63,7 @@ public final class OSGiProxyConfiguration implements ProxyConfiguration { /** * Property representing the username to authenticate with towards the proxy. Defaults to empty. */ - private static final String PROPERTYNAME_PROXY_USERNAME = "proxy.username"; + private static final String PROPERTYNAME_PROXY_USERNAME = "proxy.user"; private static final String PROPERTYDEFAULT_PROXY_USERNAME = ""; diff --git a/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/OSGiProxyConfigurationTest.java b/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/OSGiProxyConfigurationTest.java index 55b117497..57505f6b2 100644 --- a/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/OSGiProxyConfigurationTest.java +++ b/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/OSGiProxyConfigurationTest.java @@ -43,7 +43,7 @@ public class OSGiProxyConfigurationTest { config.put("proxy.enabled", false); config.put("proxy.host", "h"); config.put("proxy.port", 1); - config.put("proxy.username", "u"); + config.put("proxy.user", "u"); config.put("proxy.password", "p"); config.put("proxy.exceptions", new String[]{"e"});