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 16:13:19 GMT
Repository: httpcomponents-client
Updated Branches:
  refs/heads/master 2584dbd31 -> 2b2dd593a


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

Branch: refs/heads/master
Commit: 2b2dd593a356a57bb6d49be582f635c459c0ffce
Parents: 2584dbd
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 17:09:59 2017 +0100

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


http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/2b2dd593/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java
b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java
index 958644e..eafab1c 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java
@@ -94,13 +94,10 @@ public class SystemDefaultCredentialsProvider implements CredentialsStore
{
     }
 
     private static PasswordAuthentication getSystemCreds(
+            final String protocol,
             final AuthScope authscope,
             final Authenticator.RequestorType requestorType,
             final HttpClientContext context) {
-        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");
         final HttpRequest request = context != null ? context.getRequest() : null;
         URL targetHostURL;
         try {
@@ -111,9 +108,9 @@ public class SystemDefaultCredentialsProvider implements CredentialsStore
{
         }
         // use null addr, because the authentication fails if it does not exactly match the
expected realm's host
         return Authenticator.requestPasswordAuthentication(
-                hostname,
+                authscope.getHost(),
                 null,
-                port,
+                authscope.getPort(),
                 protocol,
                 authscope.getRealm(),
                 translateAuthScheme(authscope.getScheme()),
@@ -131,23 +128,26 @@ public class SystemDefaultCredentialsProvider implements CredentialsStore
{
         final String host = authscope.getHost();
         if (host != null) {
             final HttpClientContext clientContext = context != null ? HttpClientContext.adapt(context)
: null;
+            final int port = authscope.getPort();
+            final HttpHost origin = authscope.getOrigin();
+            final String protocol = origin != null ? origin.getSchemeName() : (port == 443
? "https" : "http");
             PasswordAuthentication systemcreds = getSystemCreds(
-                    authscope, Authenticator.RequestorType.SERVER, clientContext);
+                    protocol, authscope, Authenticator.RequestorType.SERVER, clientContext);
             if (systemcreds == null) {
                 systemcreds = getSystemCreds(
-                        authscope, Authenticator.RequestorType.PROXY, clientContext);
+                        protocol, authscope, Authenticator.RequestorType.PROXY, clientContext);
             }
             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