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:
parent
7e38f831d5
commit
cbf517ace6
|
@ -111,12 +111,30 @@ public class SystemDefaultCredentialsProvider implements CredentialsProvider {
|
||||||
if (localcreds != null) {
|
if (localcreds != null) {
|
||||||
return localcreds;
|
return localcreds;
|
||||||
}
|
}
|
||||||
if (authscope.getHost() != null) {
|
final String host = authscope.getHost();
|
||||||
PasswordAuthentication systemcreds = getSystemCreds(
|
if (host != null) {
|
||||||
authscope, Authenticator.RequestorType.SERVER);
|
PasswordAuthentication systemcreds = getSystemCreds(authscope, Authenticator.RequestorType.SERVER);
|
||||||
if (systemcreds == null) {
|
if (systemcreds == null) {
|
||||||
systemcreds = getSystemCreds(
|
systemcreds = getSystemCreds(authscope, Authenticator.RequestorType.PROXY);
|
||||||
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) {
|
if (systemcreds != null) {
|
||||||
final String domain = System.getProperty("http.auth.ntlm.domain");
|
final String domain = System.getProperty("http.auth.ntlm.domain");
|
||||||
|
|
Loading…
Reference in New Issue