You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/11/26 15:47:50 UTC
httpcomponents-client git commit: HTTPCLIENT-1883:
SystemDefaultCredentialsProvider to use https.proxy* system properties for
origins with port 443
Repository: httpcomponents-client
Updated Branches:
refs/heads/4.5.x e24994324 -> 8c4e081ec
HTTPCLIENT-1883: SystemDefaultCredentialsProvider to use https.proxy* system properties for origins with port 443
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/8c4e081e
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/8c4e081e
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/8c4e081e
Branch: refs/heads/4.5.x
Commit: 8c4e081ecd02e575dff2ab4172962c96846ae8f7
Parents: e249943
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Nov 26 16:47:29 2017 +0100
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Nov 26 16:47:29 2017 +0100
----------------------------------------------------------------------
.../SystemDefaultCredentialsProvider.java | 24 +++++++++-----------
1 file changed, 11 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8c4e081e/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
index 9473ab2..f977d05 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
@@ -87,17 +87,13 @@ public class SystemDefaultCredentialsProvider implements CredentialsProvider {
}
private static PasswordAuthentication getSystemCreds(
+ final String protocol,
final AuthScope authscope,
final Authenticator.RequestorType requestorType) {
- final String hostname = authscope.getHost();
- final int port = authscope.getPort();
- final HttpHost origin = authscope.getOrigin();
- final String protocol = origin != null ? origin.getSchemeName() :
- (port == 443 ? "https" : "http");
return Authenticator.requestPasswordAuthentication(
- hostname,
+ authscope.getHost(),
null,
- port,
+ authscope.getPort(),
protocol,
null,
translateScheme(authscope.getScheme()),
@@ -114,21 +110,23 @@ public class SystemDefaultCredentialsProvider implements CredentialsProvider {
}
final String host = authscope.getHost();
if (host != null) {
- PasswordAuthentication systemcreds = getSystemCreds(authscope, Authenticator.RequestorType.SERVER);
+ final HttpHost origin = authscope.getOrigin();
+ final String protocol = origin != null ? origin.getSchemeName() : (origin.getPort() == 443 ? "https" : "http");
+ PasswordAuthentication systemcreds = getSystemCreds(protocol, authscope, Authenticator.RequestorType.SERVER);
if (systemcreds == null) {
- systemcreds = getSystemCreds(authscope, Authenticator.RequestorType.PROXY);
+ systemcreds = getSystemCreds(protocol, authscope, Authenticator.RequestorType.PROXY);
}
if (systemcreds == null) {
- final String proxyHost = System.getProperty("http.proxyHost");
+ final String proxyHost = System.getProperty(protocol + ".proxyHost");
if (proxyHost != null) {
- final String proxyPort = System.getProperty("http.proxyPort");
+ final String proxyPort = System.getProperty(protocol + ".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");
+ final String proxyUser = System.getProperty(protocol + ".proxyUser");
if (proxyUser != null) {
- final String proxyPassword = System.getProperty("http.proxyPassword");
+ final String proxyPassword = System.getProperty(protocol + ".proxyPassword");
systemcreds = new PasswordAuthentication(proxyUser, proxyPassword != null ? proxyPassword.toCharArray() : new char[] {});
}
}