You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by ma...@apache.org on 2013/09/28 01:25:51 UTC
svn commit: r1527130 - in /zookeeper/branches/branch-3.4: CHANGES.txt
src/java/main/org/apache/zookeeper/client/ZooKeeperSaslClient.java
Author: mahadev
Date: Fri Sep 27 23:25:51 2013
New Revision: 1527130
URL: http://svn.apache.org/r1527130
Log:
ZOOKEEPER-1696. Fail to run zookeeper client on Weblogic application server. (Jeffrey Zhong via mahade
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=1527130&r1=1527129&r2=1527130&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Fri Sep 27 23:25:51 2013
@@ -113,6 +113,8 @@ BUGFIXES:
ZOOKEEPER-1603. StaticHostProviderTest testUpdateClientMigrateOrNot hangs (fpj)
+ ZOOKEEPER-1696. Fail to run zookeeper client on Weblogic application server.
+ (Jeffrey Zhong via mahadev)
IMPROVEMENTS:
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=1527130&r1=1527129&r2=1527130&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 Fri Sep 27 23:25:51 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];
@@ -113,12 +114,17 @@ 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) {
// handle below: might be harmless if the user doesn't intend to use JAAS authentication.
- securityException = e;
+ runtimeException = e;
+ } catch (IllegalArgumentException e) {
+ // third party customized getAppConfigurationEntry could throw IllegalArgumentException when JAAS
+ // configuration isn't set. We can reevaluate whether to catch RuntimeException instead when more
+ // different types of RuntimeException found
+ runtimeException = e;
}
if (entries != null) {
this.configStatus = "Will attempt to SASL-authenticate using Login Context section '" + clientSection + "'";
@@ -131,11 +137,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 +150,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 + ")";
} 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 +175,7 @@ public class ZooKeeperSaslClient {
}
}
}
-
+
/**
* @return informational message indicating the current configuration status.
*/
@@ -528,6 +535,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).