hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1737484 - /httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java
Date Sat, 02 Apr 2016 10:26:12 GMT
Author: olegk
Date: Sat Apr  2 10:26:11 2016
New Revision: 1737484

URL: http://svn.apache.org/viewvc?rev=1737484&view=rev
Log:
HTTPCLIENT-1732: SystemDefaultCredentialsProvider to take http.proxyHost and http.proxyPort
system properties into account

Modified:
    httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java

Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java?rev=1737484&r1=1737483&r2=1737484&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java
Sat Apr  2 10:26:11 2016
@@ -112,12 +112,30 @@ public class SystemDefaultCredentialsPro
         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");



Mime
View raw message