From 129fc09f42e290e7162fc18020693d64c19a936c Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Wed, 17 Feb 2016 14:00:52 +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/trunk@1730838 13f79535-47bb-0310-9956-ffa450edef68 --- .../hc/client5/http/osgi/impl/OSGiCredentialsProvider.java | 3 +-- .../hc/client5/http/osgi/impl/OSGiProxyConfiguration.java | 2 +- .../hc/client5/http/osgi/impl/OSGiProxyConfigurationTest.java | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/OSGiCredentialsProvider.java b/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/OSGiCredentialsProvider.java index f08c02d46..9fc410c3f 100644 --- a/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/OSGiCredentialsProvider.java +++ b/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/OSGiCredentialsProvider.java @@ -72,12 +72,11 @@ final class OSGiCredentialsProvider implements CredentialsStore { final ProxyConfiguration proxyConfiguration = (ProxyConfiguration) proxyConfigurationObject; if (proxyConfiguration.isEnabled()) { final AuthScope actual = new AuthScope(proxyConfiguration.getHostname(), proxyConfiguration.getPort()); - if (authscope.equals(actual)) { + if (authscope.match(actual) >= 12) { final String username = proxyConfiguration.getUsername(); final String password = proxyConfiguration.getPassword(); return new UsernamePasswordCredentials(username, password != null ? password.toCharArray() : null); } - } } } diff --git a/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/OSGiProxyConfiguration.java b/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/OSGiProxyConfiguration.java index b0416b050..a8bef07ef 100644 --- a/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/OSGiProxyConfiguration.java +++ b/httpclient5-osgi/src/main/java/org/apache/hc/client5/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/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/OSGiProxyConfigurationTest.java b/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/OSGiProxyConfigurationTest.java index 961492d3f..7d99ff42b 100644 --- a/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/OSGiProxyConfigurationTest.java +++ b/httpclient5-osgi/src/test/java/org/apache/hc/client5/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"});