You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by ph...@apache.org on 2013/10/08 07:38:48 UTC
svn commit: r1530160 - in /zookeeper/branches/branch-3.4: CHANGES.txt
src/contrib/zooinspector/config/defaultConnectionSettings.cfg
src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/manager/ZooInspectorManagerImpl.java
Author: phunt
Date: Tue Oct 8 05:38:47 2013
New Revision: 1530160
URL: http://svn.apache.org/r1530160
Log:
ZOOKEEPER-1771. ZooInspector authentication (Benjamin Jaton via phunt)
Modified:
zookeeper/branches/branch-3.4/CHANGES.txt
zookeeper/branches/branch-3.4/src/contrib/zooinspector/config/defaultConnectionSettings.cfg
zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/manager/ZooInspectorManagerImpl.java
Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1530160&r1=1530159&r2=1530160&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Tue Oct 8 05:38:47 2013
@@ -149,6 +149,8 @@ IMPROVEMENTS:
ZOOKEEPER-1758. Add documentation for zookeeper.observer.syncEnabled flag
(thawan, fpj via thawan)
+ ZOOKEEPER-1771. ZooInspector authentication (Benjamin Jaton via phunt)
+
Release 3.4.5 - 2012-09-30
Backward compatible changes:
Modified: zookeeper/branches/branch-3.4/src/contrib/zooinspector/config/defaultConnectionSettings.cfg
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/contrib/zooinspector/config/defaultConnectionSettings.cfg?rev=1530160&r1=1530159&r2=1530160&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/contrib/zooinspector/config/defaultConnectionSettings.cfg (original)
+++ zookeeper/branches/branch-3.4/src/contrib/zooinspector/config/defaultConnectionSettings.cfg Tue Oct 8 05:38:47 2013
@@ -14,7 +14,8 @@
# limitations under the License.
#
#Default connection for ZooInspector
-#Sun Feb 28 14:46:55 GMT 2010
hosts=localhost\:2181
encryptionManager=org.apache.zookeeper.inspector.encryption.BasicDataEncryptionManager
timeout=5000
+authScheme=
+authData=
Modified: zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/manager/ZooInspectorManagerImpl.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/manager/ZooInspectorManagerImpl.java?rev=1530160&r1=1530159&r2=1530160&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/manager/ZooInspectorManagerImpl.java (original)
+++ zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/manager/ZooInspectorManagerImpl.java Tue Oct 8 05:38:47 2013
@@ -82,6 +82,14 @@ public class ZooInspectorManagerImpl imp
* file
*/
public static final String DATA_ENCRYPTION_MANAGER = "encryptionManager";
+ /**
+ * The key used for the authentication scheme in the connection properties file
+ */
+ public static final String AUTH_SCHEME_KEY = "authScheme";
+ /**
+ * The key used for the authentication data in the connection properties file
+ */
+ public static final String AUTH_DATA_KEY = "authData";
private static final File defaultNodeViewersFile = new File(
"./config/defaultNodeVeiwers.cfg");
@@ -98,6 +106,8 @@ public class ZooInspectorManagerImpl imp
private String defaultEncryptionManager;
private String defaultTimeout;
private String defaultHosts;
+ private String defaultAuthScheme;
+ private String defaultAuthValue;
/**
* @throws IOException
@@ -124,6 +134,11 @@ public class ZooInspectorManagerImpl imp
.getProperty(SESSION_TIMEOUT);
String encryptionManager = connectionProps
.getProperty(DATA_ENCRYPTION_MANAGER);
+ String authScheme = connectionProps
+ .getProperty(AUTH_SCHEME_KEY);
+ String authData = connectionProps
+ .getProperty(AUTH_DATA_KEY);
+
if (connectString == null || sessionTimeout == null) {
throw new IllegalArgumentException(
"Both connect string and session timeout are required.");
@@ -153,6 +168,9 @@ public class ZooInspectorManagerImpl imp
}
}
});
+ if (authData != null && authData.length() > 0){
+ this.zooKeeper.addAuthInfo(authScheme, authData.getBytes());
+ }
((ZooKeeperRetry) this.zooKeeper).setRetryLimit(10);
connected = ((ZooKeeperRetry) this.zooKeeper).testConnection();
return connected;
@@ -571,10 +589,16 @@ public class ZooInspectorManagerImpl imp
.asList(new String[] { defaultTimeout }));
template.put(DATA_ENCRYPTION_MANAGER, Arrays
.asList(new String[] { defaultEncryptionManager }));
+ template.put(AUTH_SCHEME_KEY, Arrays
+ .asList(new String[] { defaultAuthScheme }));
+ template.put(AUTH_DATA_KEY, Arrays
+ .asList(new String[] { defaultAuthValue }));
Map<String, String> labels = new LinkedHashMap<String, String>();
labels.put(CONNECT_STRING, "Connect String");
labels.put(SESSION_TIMEOUT, "Session Timeout");
labels.put(DATA_ENCRYPTION_MANAGER, "Data Encryption Manager");
+ labels.put(AUTH_SCHEME_KEY, "Authentication Scheme");
+ labels.put(AUTH_DATA_KEY, "Authentication Data");
return new Pair<Map<String, List<String>>, Map<String, String>>(
template, labels);
}
@@ -707,7 +731,7 @@ public class ZooInspectorManagerImpl imp
try {
while (buff.ready()) {
String line = buff.readLine();
- if (line != null && line.length() > 0) {
+ if (line != null && line.length() > 0 && !line.startsWith("#")) {
result.add(line);
}
}
@@ -738,10 +762,16 @@ public class ZooInspectorManagerImpl imp
: props.getProperty(SESSION_TIMEOUT);
defaultHosts = props.getProperty(CONNECT_STRING) == null ? "localhost:2181"
: props.getProperty(CONNECT_STRING);
+ defaultAuthScheme = props.getProperty(AUTH_SCHEME_KEY) == null ? ""
+ : props.getProperty(AUTH_SCHEME_KEY);
+ defaultAuthValue = props.getProperty(AUTH_DATA_KEY) == null ? ""
+ : props.getProperty(AUTH_DATA_KEY);
} else {
defaultEncryptionManager = "org.apache.zookeeper.inspector.encryption.BasicDataEncryptionManager";
defaultTimeout = "5000";
defaultHosts = "localhost:2181";
+ defaultAuthScheme = "";
+ defaultAuthValue = "";
}
}