Return-Path: X-Original-To: apmail-zookeeper-commits-archive@www.apache.org Delivered-To: apmail-zookeeper-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 D7F1010E0C for ; Thu, 26 Sep 2013 00:04:24 +0000 (UTC) Received: (qmail 60256 invoked by uid 500); 26 Sep 2013 00:04:24 -0000 Delivered-To: apmail-zookeeper-commits-archive@zookeeper.apache.org Received: (qmail 60213 invoked by uid 500); 26 Sep 2013 00:04:24 -0000 Mailing-List: contact commits-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ Delivered-To: mailing list commits@zookeeper.apache.org Received: (qmail 60205 invoked by uid 99); 26 Sep 2013 00:04:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Sep 2013 00:04:24 +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; Thu, 26 Sep 2013 00:04:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1EB2A2388831; Thu, 26 Sep 2013 00:04:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1526338 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/java/main/org/apache/zookeeper/client/ZooKeeperSaslClient.java Date: Thu, 26 Sep 2013 00:04:00 -0000 To: commits@zookeeper.apache.org From: mahadev@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130926000400.1EB2A2388831@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mahadev Date: Thu Sep 26 00:03:59 2013 New Revision: 1526338 URL: http://svn.apache.org/r1526338 Log: ZOOKEEPER-1696. Fail to run zookeeper client on Weblogic application server. (Jeffrey Zhong via mahadev) Modified: zookeeper/branches/branch-3.4/CHANGES.txt zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/client/ZooKeeperSaslClient.java Modified: zookeeper/branches/branch-3.4/CHANGES.txt URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1526338&r1=1526337&r2=1526338&view=diff ============================================================================== --- zookeeper/branches/branch-3.4/CHANGES.txt (original) +++ zookeeper/branches/branch-3.4/CHANGES.txt Thu Sep 26 00:03:59 2013 @@ -109,6 +109,9 @@ BUGFIXES: ZOOKEEPER-1096. Leader communication should listen on specified IP, not wildcard address (Jared Cantwell, German Blanco via fpj) + ZOOKEEPER-1696. Fail to run zookeeper client on Weblogic application server. + (Jeffrey Zhong via mahadev). + IMPROVEMENTS: ZOOKEEPER-1564. Allow JUnit test build with IBM Java Modified: zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/client/ZooKeeperSaslClient.java URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/client/ZooKeeperSaslClient.java?rev=1526338&r1=1526337&r2=1526338&view=diff ============================================================================== --- zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/client/ZooKeeperSaslClient.java (original) +++ zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/client/ZooKeeperSaslClient.java Thu Sep 26 00:03:59 2013 @@ -80,6 +80,7 @@ public class ZooKeeperSaslClient { private static final Logger LOG = LoggerFactory.getLogger(ZooKeeperSaslClient.class); private static Login login = null; private SaslClient saslClient; + private boolean isSASLConfigured = true; private byte[] saslToken = new byte[0]; @@ -104,7 +105,7 @@ public class ZooKeeperSaslClient { } public ZooKeeperSaslClient(final String serverPrincipal) - throws LoginException { + throws LoginException { /** * ZOOKEEPER-1373: allow system property to specify the JAAS * configuration section that the zookeeper client should use. @@ -113,12 +114,12 @@ public class ZooKeeperSaslClient { String clientSection = System.getProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY, "Client"); // Note that 'Configuration' here refers to javax.security.auth.login.Configuration. AppConfigurationEntry entries[] = null; - SecurityException securityException = null; + RuntimeException runtimeException = null; try { entries = Configuration.getConfiguration().getAppConfigurationEntry(clientSection); - } catch (SecurityException e) { + } catch (RuntimeException e) { // handle below: might be harmless if the user doesn't intend to use JAAS authentication. - securityException = e; + runtimeException = e; } if (entries != null) { this.configStatus = "Will attempt to SASL-authenticate using Login Context section '" + clientSection + "'"; @@ -131,11 +132,11 @@ public class ZooKeeperSaslClient { if (explicitClientSection != null) { // If the user explicitly overrides the default Login Context, they probably expected SASL to // succeed. But if we got here, SASL failed. - if (securityException != null) { + if (runtimeException != null) { throw new LoginException("Zookeeper client cannot authenticate using the " + explicitClientSection + " section of the supplied JAAS configuration: '" + System.getProperty(Environment.JAAS_CONF_KEY) + "' because of a " + - "SecurityException: " + securityException); + "RuntimeException: " + runtimeException); } else { throw new LoginException("Client cannot SASL-authenticate because the specified JAAS configuration " + "section '" + explicitClientSection + "' could not be found."); @@ -144,21 +145,22 @@ public class ZooKeeperSaslClient { // The user did not override the default context. It might be that they just don't intend to use SASL, // so log at INFO, not WARN, since they don't expect any SASL-related information. String msg = "Will not attempt to authenticate using SASL "; - if (securityException != null) { - msg += "(" + securityException.getLocalizedMessage() + ")"; + if (runtimeException != null) { + msg += "(" + runtimeException.getLocalizedMessage() + ")"; } else { msg += "(unknown error)"; } this.configStatus = msg; + this.isSASLConfigured = false; } if (System.getProperty(Environment.JAAS_CONF_KEY) != null) { // Again, the user explicitly set something SASL-related, so they probably expected SASL to succeed. - if (securityException != null) { + if (runtimeException != null) { throw new LoginException("Zookeeper client cannot authenticate using the '" + System.getProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY, "Client") + "' section of the supplied JAAS configuration: '" + System.getProperty(Environment.JAAS_CONF_KEY) + "' because of a " + - "SecurityException: " + securityException); + "RuntimeException: " + runtimeException); } else { throw new LoginException("No JAAS configuration section named '" + System.getProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY, "Client") + @@ -168,7 +170,7 @@ public class ZooKeeperSaslClient { } } } - + /** * @return informational message indicating the current configuration status. */ @@ -528,6 +530,9 @@ public class ZooKeeperSaslClient { } public boolean clientTunneledAuthenticationInProgress() { + if (!isSASLConfigured) { + return false; + } // TODO: Rather than checking a disjunction here, should be a single member // variable or method in this class to determine whether the client is // configured to use SASL. (see also ZOOKEEPER-1455).