hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1602397 - in /httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win: CurrentWindowsCredentials.java WindowsCredentialsProvider.java
Date Fri, 13 Jun 2014 12:01:48 GMT
Author: olegk
Date: Fri Jun 13 12:01:47 2014
New Revision: 1602397

URL: http://svn.apache.org/r1602397
Log:
HTTPCLIENT-1394: minor improvements in CurrentWindowsCredentials

Modified:
    httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/CurrentWindowsCredentials.java
    httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsCredentialsProvider.java

Modified: httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/CurrentWindowsCredentials.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/CurrentWindowsCredentials.java?rev=1602397&r1=1602396&r2=1602397&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/CurrentWindowsCredentials.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/CurrentWindowsCredentials.java
Fri Jun 13 12:01:47 2014
@@ -33,8 +33,8 @@ import java.security.Principal;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.auth.Credentials;
 
-import com.sun.jna.platform.win32.Secur32Util;
 import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT;
+import com.sun.jna.platform.win32.Secur32Util;
 
 /**
  * Returns the current Windows user credentials
@@ -44,10 +44,12 @@ import com.sun.jna.platform.win32.Secur3
  * @since 4.4
  */
 @Immutable
-public class CurrentWindowsCredentials implements Credentials, Serializable, Principal {
+public final class CurrentWindowsCredentials implements Credentials, Serializable, Principal
{
 
     private static final long serialVersionUID = 4361166468529298169L;
 
+    public static final CurrentWindowsCredentials INSTANCE = new CurrentWindowsCredentials();
+
     /**
      * Get the SAM-compatible username of the currently logged-on user.
      *
@@ -60,14 +62,6 @@ public class CurrentWindowsCredentials i
     private CurrentWindowsCredentials() {
     }
 
-    private static class LazyHolder {
-        private static final CurrentWindowsCredentials INSTANCE = new CurrentWindowsCredentials();
-    }
-
-    public static CurrentWindowsCredentials get() {
-        return LazyHolder.INSTANCE;
-    }
-
     @Override
     public Principal getUserPrincipal() {
         return this;
@@ -75,16 +69,18 @@ public class CurrentWindowsCredentials i
 
     @Override
     public int hashCode() {
-        return 245678; // always the same?
+        return getClass().hashCode();
     }
 
     @Override
     public boolean equals(final Object o) {
-        if (this == o) return true;
-        if (o instanceof CurrentWindowsCredentials) {
+        if (this == o) {
             return true;
         }
-        return false;
+        if (o == null) {
+            return false;
+        }
+        return getClass().equals(o.getClass());
     }
 
     @Override

Modified: httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsCredentialsProvider.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsCredentialsProvider.java?rev=1602397&r1=1602396&r2=1602397&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsCredentialsProvider.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsCredentialsProvider.java
Fri Jun 13 12:01:47 2014
@@ -48,7 +48,7 @@ public class WindowsCredentialsProvider 
     public Credentials getCredentials(final AuthScope authscope) {
         final String scheme = authscope.getScheme();
         if (AuthSchemes.NTLM.equalsIgnoreCase(scheme) || AuthSchemes.SPNEGO.equalsIgnoreCase(scheme))
{
-            return CurrentWindowsCredentials.get();
+            return CurrentWindowsCredentials.INSTANCE;
         } else {
             return super.getCredentials(authscope);
         }



Mime
View raw message