HTTPCLIENT-1718, HTTPCLEINT-1719: credentials fix to allow proxy authetication

Contributed by 212427891 <munene.kiruja at ge.com>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1730838 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2016-02-17 14:00:52 +00:00
parent 8e8cfc41ad
commit 129fc09f42
3 changed files with 3 additions and 4 deletions

View File

@ -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);
}
}
}
}

View File

@ -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 = "";

View File

@ -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"});