@Test public void testInitializeAcl() throws Exception { final ZooKeeperClient zkClient = new DefaultZooKeeperClient(zk.curatorWithSuperAuth()); zkClient.ensurePath(Paths.configId(CLUSTER_ID)); new MasterZooKeeperRegistrar("helios-master").tryToRegister(zkClient); for (final String path : zkClient.listRecursive("/")) { assertEquals(ZooDefs.Ids.OPEN_ACL_UNSAFE, zkClient.getAcl(path)); } ZooKeeperAclInitializer.initializeAcl(zk.connectString(), CLUSTER_ID, MASTER_USER, MASTER_PASSWORD, AGENT_USER, AGENT_PASSWORD); for (final String path : zkClient.listRecursive("/")) { final List<ACL> expected = aclProvider.getAclForPath(path); final List<ACL> actual = zkClient.getAcl(path); assertEquals(expected.size(), actual.size()); assertTrue(expected.containsAll(actual)); } }
static void initializeAcl(final String zooKeeperConnectionString, final String zooKeeperClusterId, final String masterUser, final String masterPassword, final String agentUser, final String agentPassword) throws KeeperException { final ACLProvider aclProvider = heliosAclProvider( masterUser, digest(masterUser, masterPassword), agentUser, digest(agentUser, agentPassword)); final List<AuthInfo> authorization = Lists.newArrayList(new AuthInfo( "digest", String.format("%s:%s", masterUser, masterPassword).getBytes())); final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3); final CuratorFramework curator = new CuratorClientFactoryImpl().newClient( zooKeeperConnectionString, (int) TimeUnit.SECONDS.toMillis(60), (int) TimeUnit.SECONDS.toMillis(15), zooKeeperRetryPolicy, aclProvider, authorization); final ZooKeeperClient client = new DefaultZooKeeperClient(curator, zooKeeperClusterId); try { client.start(); initializeAclRecursive(client, "/", aclProvider); } finally { client.close(); } }
ZooKeeperAclInitializer { static void initializeAcl(final String zooKeeperConnectionString, final String zooKeeperClusterId, final String masterUser, final String masterPassword, final String agentUser, final String agentPassword) throws KeeperException { final ACLProvider aclProvider = heliosAclProvider( masterUser, digest(masterUser, masterPassword), agentUser, digest(agentUser, agentPassword)); final List<AuthInfo> authorization = Lists.newArrayList(new AuthInfo( "digest", String.format("%s:%s", masterUser, masterPassword).getBytes())); final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3); final CuratorFramework curator = new CuratorClientFactoryImpl().newClient( zooKeeperConnectionString, (int) TimeUnit.SECONDS.toMillis(60), (int) TimeUnit.SECONDS.toMillis(15), zooKeeperRetryPolicy, aclProvider, authorization); final ZooKeeperClient client = new DefaultZooKeeperClient(curator, zooKeeperClusterId); try { client.start(); initializeAclRecursive(client, "/", aclProvider); } finally { client.close(); } } }
ZooKeeperAclInitializer { static void initializeAcl(final String zooKeeperConnectionString, final String zooKeeperClusterId, final String masterUser, final String masterPassword, final String agentUser, final String agentPassword) throws KeeperException { final ACLProvider aclProvider = heliosAclProvider( masterUser, digest(masterUser, masterPassword), agentUser, digest(agentUser, agentPassword)); final List<AuthInfo> authorization = Lists.newArrayList(new AuthInfo( "digest", String.format("%s:%s", masterUser, masterPassword).getBytes())); final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3); final CuratorFramework curator = new CuratorClientFactoryImpl().newClient( zooKeeperConnectionString, (int) TimeUnit.SECONDS.toMillis(60), (int) TimeUnit.SECONDS.toMillis(15), zooKeeperRetryPolicy, aclProvider, authorization); final ZooKeeperClient client = new DefaultZooKeeperClient(curator, zooKeeperClusterId); try { client.start(); initializeAclRecursive(client, "/", aclProvider); } finally { client.close(); } }  }
ZooKeeperAclInitializer { static void initializeAcl(final String zooKeeperConnectionString, final String zooKeeperClusterId, final String masterUser, final String masterPassword, final String agentUser, final String agentPassword) throws KeeperException { final ACLProvider aclProvider = heliosAclProvider( masterUser, digest(masterUser, masterPassword), agentUser, digest(agentUser, agentPassword)); final List<AuthInfo> authorization = Lists.newArrayList(new AuthInfo( "digest", String.format("%s:%s", masterUser, masterPassword).getBytes())); final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3); final CuratorFramework curator = new CuratorClientFactoryImpl().newClient( zooKeeperConnectionString, (int) TimeUnit.SECONDS.toMillis(60), (int) TimeUnit.SECONDS.toMillis(15), zooKeeperRetryPolicy, aclProvider, authorization); final ZooKeeperClient client = new DefaultZooKeeperClient(curator, zooKeeperClusterId); try { client.start(); initializeAclRecursive(client, "/", aclProvider); } finally { client.close(); } }  static void main(final String[] args); }
ZooKeeperAclInitializer { static void initializeAcl(final String zooKeeperConnectionString, final String zooKeeperClusterId, final String masterUser, final String masterPassword, final String agentUser, final String agentPassword) throws KeeperException { final ACLProvider aclProvider = heliosAclProvider( masterUser, digest(masterUser, masterPassword), agentUser, digest(agentUser, agentPassword)); final List<AuthInfo> authorization = Lists.newArrayList(new AuthInfo( "digest", String.format("%s:%s", masterUser, masterPassword).getBytes())); final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3); final CuratorFramework curator = new CuratorClientFactoryImpl().newClient( zooKeeperConnectionString, (int) TimeUnit.SECONDS.toMillis(60), (int) TimeUnit.SECONDS.toMillis(15), zooKeeperRetryPolicy, aclProvider, authorization); final ZooKeeperClient client = new DefaultZooKeeperClient(curator, zooKeeperClusterId); try { client.start(); initializeAclRecursive(client, "/", aclProvider); } finally { client.close(); } }  static void main(final String[] args);  }