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/03 18:45:53 UTC

svn commit: r1528928 - in /zookeeper/trunk: CHANGES.txt src/contrib/zooinspector/config/defaultConnectionSettings.cfg src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/manager/ZooInspectorManagerImpl.java

Author: phunt
Date: Thu Oct  3 16:45:52 2013
New Revision: 1528928

URL: http://svn.apache.org/r1528928
Log:
ZOOKEEPER-1771. ZooInspector authentication (Benjamin Jaton via phunt)

Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/src/contrib/zooinspector/config/defaultConnectionSettings.cfg
    zookeeper/trunk/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/manager/ZooInspectorManagerImpl.java

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1528928&r1=1528927&r2=1528928&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Thu Oct  3 16:45:52 2013
@@ -600,6 +600,9 @@ 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.0 - 
 
 Non-backward compatible changes:

Modified: zookeeper/trunk/src/contrib/zooinspector/config/defaultConnectionSettings.cfg
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/zooinspector/config/defaultConnectionSettings.cfg?rev=1528928&r1=1528927&r2=1528928&view=diff
==============================================================================
--- zookeeper/trunk/src/contrib/zooinspector/config/defaultConnectionSettings.cfg (original)
+++ zookeeper/trunk/src/contrib/zooinspector/config/defaultConnectionSettings.cfg Thu Oct  3 16:45:52 2013
@@ -2,3 +2,5 @@
 hosts=localhost\:2181
 encryptionManager=org.apache.zookeeper.inspector.encryption.BasicDataEncryptionManager
 timeout=5000
+authScheme=
+authData=
\ No newline at end of file

Modified: zookeeper/trunk/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/manager/ZooInspectorManagerImpl.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/manager/ZooInspectorManagerImpl.java?rev=1528928&r1=1528927&r2=1528928&view=diff
==============================================================================
--- zookeeper/trunk/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/manager/ZooInspectorManagerImpl.java (original)
+++ zookeeper/trunk/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/manager/ZooInspectorManagerImpl.java Thu Oct  3 16:45:52 2013
@@ -82,6 +82,15 @@ 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/defaultNodeViewers.cfg");
@@ -98,6 +107,8 @@ public class ZooInspectorManagerImpl imp
     private String defaultEncryptionManager;
     private String defaultTimeout;
     private String defaultHosts;
+    private String defaultAuthScheme;
+    private String defaultAuthValue;
 
     /**
      * @throws IOException
@@ -124,6 +135,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 +169,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 +590,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);
     }
@@ -738,10 +763,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 = "";
         }
     }