Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6B3D0113D1 for ; Fri, 13 Jun 2014 12:02:12 +0000 (UTC) Received: (qmail 60187 invoked by uid 500); 13 Jun 2014 12:02:12 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 60146 invoked by uid 500); 13 Jun 2014 12:02:12 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 60139 invoked by uid 99); 13 Jun 2014 12:02:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Jun 2014 12:02:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Jun 2014 12:02:12 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 42B042388994 for ; Fri, 13 Jun 2014 12:01:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140613120148.42B042388994@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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); }