hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1790033 - in /httpcomponents/httpclient/branches/4.6.x/httpclient-win/src: main/java/org/apache/http/impl/client/ main/java/org/apache/http/impl/client/win/ test/java/org/apache/http/impl/auth/win/
Date Mon, 03 Apr 2017 18:26:31 GMT
Author: olegk
Date: Mon Apr  3 18:26:31 2017
New Revision: 1790033

URL: http://svn.apache.org/viewvc?rev=1790033&view=rev
Log:
HTTPCLIENT-1837: Moved WinClients to a separate package

Added:
    httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/win/
    httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/win/WinHttpClients.java
      - copied, changed from r1789211, httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/WinHttpClients.java
Modified:
    httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/WinHttpClients.java
    httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/test/java/org/apache/http/impl/auth/win/TestWindowsNegotiateScheme.java

Modified: httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/WinHttpClients.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/WinHttpClients.java?rev=1790033&r1=1790032&r2=1790033&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/WinHttpClients.java
(original)
+++ httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/WinHttpClients.java
Mon Apr  3 18:26:31 2017
@@ -26,27 +26,15 @@
  */
 package org.apache.http.impl.client;
 
-import java.util.Locale;
-
-import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.config.AuthSchemes;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.impl.auth.BasicSchemeFactory;
-import org.apache.http.impl.auth.DigestSchemeFactory;
-import org.apache.http.impl.auth.win.WindowsCredentialsProvider;
-import org.apache.http.impl.auth.win.WindowsNTLMSchemeFactory;
-import org.apache.http.impl.auth.win.WindowsNegotiateSchemeFactory;
-
-import com.sun.jna.platform.win32.Sspi;
-
 /**
  * Factory methods for {@link CloseableHttpClient} instances configured to use integrated
  * Windows authentication by default.
  *
  * @since 4.4
+ *
+ * @deprecated Use {@link org.apache.http.impl.client.win.WinHttpClients}
  */
+@Deprecated
 public class WinHttpClients {
 
     private WinHttpClients() {
@@ -54,41 +42,11 @@ public class WinHttpClients {
     }
 
     public static boolean isWinAuthAvailable() {
-        String os = System.getProperty("os.name");
-        os = os != null ? os.toLowerCase(Locale.ROOT) : null;
-        if (os != null && os.contains("windows")) {
-            try {
-                return Sspi.MAX_TOKEN_SIZE > 0;
-            } catch (final Exception ignore) { // Likely ClassNotFound
-                return false;
-            }
-        }
-        return false;
+        return org.apache.http.impl.client.win.WinHttpClients.isWinAuthAvailable();
     }
 
-    private static HttpClientBuilder createBuilder() {
-        if (isWinAuthAvailable()) {
-            final Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
-                    .register(AuthSchemes.BASIC, new BasicSchemeFactory())
-                    .register(AuthSchemes.DIGEST, new DigestSchemeFactory())
-                    .register(AuthSchemes.NTLM, new WindowsNTLMSchemeFactory(null))
-                    .register(AuthSchemes.SPNEGO, new WindowsNegotiateSchemeFactory(null))
-                    .build();
-            final CredentialsProvider credsProvider = new WindowsCredentialsProvider(new
SystemDefaultCredentialsProvider());
-            return HttpClientBuilder.create()
-                    .setDefaultCredentialsProvider(credsProvider)
-                    .setDefaultAuthSchemeRegistry(authSchemeRegistry);
-        } else {
-            return HttpClientBuilder.create();
-        }
-    }
-
-    /**
-     * Creates builder object for construction of custom
-     * {@link CloseableHttpClient} instances.
-     */
     public static HttpClientBuilder custom() {
-        return createBuilder();
+        return org.apache.http.impl.client.win.WinHttpClients.custom();
     }
 
     /**
@@ -96,7 +54,7 @@ public class WinHttpClients {
      * configuration.
      */
     public static CloseableHttpClient createDefault() {
-        return createBuilder().build();
+        return org.apache.http.impl.client.win.WinHttpClients.custom().build();
     }
 
     /**
@@ -104,8 +62,7 @@ public class WinHttpClients {
      * configuration based on system properties.
      */
     public static CloseableHttpClient createSystem() {
-        return createBuilder().useSystemProperties().build();
+        return org.apache.http.impl.client.win.WinHttpClients.custom().useSystemProperties().build();
     }
 
-
 }

Copied: httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/win/WinHttpClients.java
(from r1789211, httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/WinHttpClients.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/win/WinHttpClients.java?p2=httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/win/WinHttpClients.java&p1=httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/WinHttpClients.java&r1=1789211&r2=1790033&rev=1790033&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/WinHttpClients.java
(original)
+++ httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/main/java/org/apache/http/impl/client/win/WinHttpClients.java
Mon Apr  3 18:26:31 2017
@@ -24,7 +24,7 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.http.impl.client;
+package org.apache.http.impl.client.win;
 
 import java.util.Locale;
 
@@ -38,6 +38,9 @@ import org.apache.http.impl.auth.DigestS
 import org.apache.http.impl.auth.win.WindowsCredentialsProvider;
 import org.apache.http.impl.auth.win.WindowsNTLMSchemeFactory;
 import org.apache.http.impl.auth.win.WindowsNegotiateSchemeFactory;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.SystemDefaultCredentialsProvider;
 
 import com.sun.jna.platform.win32.Sspi;
 
@@ -45,7 +48,7 @@ import com.sun.jna.platform.win32.Sspi;
  * Factory methods for {@link CloseableHttpClient} instances configured to use integrated
  * Windows authentication by default.
  *
- * @since 4.4
+ * @since 4.6
  */
 public class WinHttpClients {
 

Modified: httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/test/java/org/apache/http/impl/auth/win/TestWindowsNegotiateScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/test/java/org/apache/http/impl/auth/win/TestWindowsNegotiateScheme.java?rev=1790033&r1=1790032&r2=1790033&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/test/java/org/apache/http/impl/auth/win/TestWindowsNegotiateScheme.java
(original)
+++ httpcomponents/httpclient/branches/4.6.x/httpclient-win/src/test/java/org/apache/http/impl/auth/win/TestWindowsNegotiateScheme.java
Mon Apr  3 18:26:31 2017
@@ -49,7 +49,7 @@ import org.apache.http.config.RegistryBu
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.impl.client.SystemDefaultCredentialsProvider;
-import org.apache.http.impl.client.WinHttpClients;
+import org.apache.http.impl.client.win.WinHttpClients;
 import org.apache.http.localserver.LocalServerTestBase;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;



Mime
View raw message