HTTPCLIENT-1732: SystemDefaultCredentialsProvider to take http.proxyHost and http.proxyPort system properties into account

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.5.x@1737485 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2016-04-02 10:26:41 +00:00
parent 7e38f831d5
commit cbf517ace6
1 changed files with 23 additions and 5 deletions

View File

@ -111,12 +111,30 @@ public class SystemDefaultCredentialsProvider implements CredentialsProvider {
if (localcreds != null) {
return localcreds;
}
if (authscope.getHost() != null) {
PasswordAuthentication systemcreds = getSystemCreds(
authscope, Authenticator.RequestorType.SERVER);
final String host = authscope.getHost();
if (host != null) {
PasswordAuthentication systemcreds = getSystemCreds(authscope, Authenticator.RequestorType.SERVER);
if (systemcreds == null) {
systemcreds = getSystemCreds(
authscope, Authenticator.RequestorType.PROXY);
systemcreds = getSystemCreds(authscope, Authenticator.RequestorType.PROXY);
}
if (systemcreds == null) {
final String proxyHost = System.getProperty("http.proxyHost");
if (proxyHost != null) {
final String proxyPort = System.getProperty("http.proxyPort");
if (proxyPort != null) {
try {
final AuthScope systemScope = new AuthScope(proxyHost, Integer.parseInt(proxyPort));
if (authscope.match(systemScope) >= 0) {
final String proxyUser = System.getProperty("http.proxyUser");
if (proxyUser != null) {
final String proxyPassword = System.getProperty("http.proxyPassword");
systemcreds = new PasswordAuthentication(proxyUser, proxyPassword != null ? proxyPassword.toCharArray() : new char[] {});
}
}
} catch (NumberFormatException ex) {
}
}
}
}
if (systemcreds != null) {
final String domain = System.getProperty("http.auth.ntlm.domain");