hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject httpcomponents-client git commit: HTTPCLIENT-1883: SystemDefaultCredentialsProvider to use https.proxy* system properties for origins with port 443
Date Sun, 26 Nov 2017 15:51:24 GMT
Repository: httpcomponents-client
Updated Branches:
  refs/heads/4.6.x e9c2a0f6b -> 7b7cdd1fd


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/7b7cdd1f
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/7b7cdd1f
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/7b7cdd1f

Branch: refs/heads/4.6.x
Commit: 7b7cdd1fd8a6a95e4461ccd3ba12f9501d51c496
Parents: e9c2a0f
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Sun Nov 26 16:47:29 2017 +0100
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Sun Nov 26 16:48:01 2017 +0100

----------------------------------------------------------------------
 .../SystemDefaultCredentialsProvider.java       | 24 +++++++++-----------
 1 file changed, 11 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/7b7cdd1f/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[] {});
                                 }
                             }


Mime
View raw message