@Test(expected = IllegalStateException.class) public void testMissingAcl() throws Exception { ZooAuthenticationKeyDistributor distributor = new ZooAuthenticationKeyDistributor(zrw, baseNode); expect(zrw.exists(baseNode)).andReturn(true); expect(zrw.getACL(eq(baseNode), anyObject(Stat.class))).andReturn(Collections.emptyList()); replay(zrw); try { distributor.initialize(); } finally { verify(zrw); } }
public synchronized void initialize() throws KeeperException, InterruptedException { if (initialized.get()) { return; } if (zk.exists(baseNode)) { List<ACL> acls = zk.getACL(baseNode, new Stat()); if (acls.size() == 1) { ACL actualAcl = acls.get(0), expectedAcl = ZooUtil.PRIVATE.get(0); Id actualId = actualAcl.getId(); if (actualAcl.getPerms() == expectedAcl.getPerms() && actualId.getScheme().equals("digest") && actualId.getId().startsWith("accumulo:")) { initialized.set(true); return; } } else { log.error("Saw more than one ACL on the node"); } log.error("Expected {} to have ACLs {} but was {}", baseNode, ZooUtil.PRIVATE, acls); throw new IllegalStateException( "Delegation token secret key node in ZooKeeper is not protected."); } else { if (!zk.putPrivatePersistentData(baseNode, new byte[0], NodeExistsPolicy.FAIL)) { throw new AssertionError("Got false from putPrivatePersistentData method"); } } initialized.set(true); }
ZooAuthenticationKeyDistributor { public synchronized void initialize() throws KeeperException, InterruptedException { if (initialized.get()) { return; } if (zk.exists(baseNode)) { List<ACL> acls = zk.getACL(baseNode, new Stat()); if (acls.size() == 1) { ACL actualAcl = acls.get(0), expectedAcl = ZooUtil.PRIVATE.get(0); Id actualId = actualAcl.getId(); if (actualAcl.getPerms() == expectedAcl.getPerms() && actualId.getScheme().equals("digest") && actualId.getId().startsWith("accumulo:")) { initialized.set(true); return; } } else { log.error("Saw more than one ACL on the node"); } log.error("Expected {} to have ACLs {} but was {}", baseNode, ZooUtil.PRIVATE, acls); throw new IllegalStateException( "Delegation token secret key node in ZooKeeper is not protected."); } else { if (!zk.putPrivatePersistentData(baseNode, new byte[0], NodeExistsPolicy.FAIL)) { throw new AssertionError("Got false from putPrivatePersistentData method"); } } initialized.set(true); } }
ZooAuthenticationKeyDistributor { public synchronized void initialize() throws KeeperException, InterruptedException { if (initialized.get()) { return; } if (zk.exists(baseNode)) { List<ACL> acls = zk.getACL(baseNode, new Stat()); if (acls.size() == 1) { ACL actualAcl = acls.get(0), expectedAcl = ZooUtil.PRIVATE.get(0); Id actualId = actualAcl.getId(); if (actualAcl.getPerms() == expectedAcl.getPerms() && actualId.getScheme().equals("digest") && actualId.getId().startsWith("accumulo:")) { initialized.set(true); return; } } else { log.error("Saw more than one ACL on the node"); } log.error("Expected {} to have ACLs {} but was {}", baseNode, ZooUtil.PRIVATE, acls); throw new IllegalStateException( "Delegation token secret key node in ZooKeeper is not protected."); } else { if (!zk.putPrivatePersistentData(baseNode, new byte[0], NodeExistsPolicy.FAIL)) { throw new AssertionError("Got false from putPrivatePersistentData method"); } } initialized.set(true); } ZooAuthenticationKeyDistributor(ZooReaderWriter zk, String baseNode); }
ZooAuthenticationKeyDistributor { public synchronized void initialize() throws KeeperException, InterruptedException { if (initialized.get()) { return; } if (zk.exists(baseNode)) { List<ACL> acls = zk.getACL(baseNode, new Stat()); if (acls.size() == 1) { ACL actualAcl = acls.get(0), expectedAcl = ZooUtil.PRIVATE.get(0); Id actualId = actualAcl.getId(); if (actualAcl.getPerms() == expectedAcl.getPerms() && actualId.getScheme().equals("digest") && actualId.getId().startsWith("accumulo:")) { initialized.set(true); return; } } else { log.error("Saw more than one ACL on the node"); } log.error("Expected {} to have ACLs {} but was {}", baseNode, ZooUtil.PRIVATE, acls); throw new IllegalStateException( "Delegation token secret key node in ZooKeeper is not protected."); } else { if (!zk.putPrivatePersistentData(baseNode, new byte[0], NodeExistsPolicy.FAIL)) { throw new AssertionError("Got false from putPrivatePersistentData method"); } } initialized.set(true); } ZooAuthenticationKeyDistributor(ZooReaderWriter zk, String baseNode); synchronized void initialize(); List<AuthenticationKey> getCurrentKeys(); synchronized void advertise(AuthenticationKey newKey); synchronized void remove(AuthenticationKey key); }
ZooAuthenticationKeyDistributor { public synchronized void initialize() throws KeeperException, InterruptedException { if (initialized.get()) { return; } if (zk.exists(baseNode)) { List<ACL> acls = zk.getACL(baseNode, new Stat()); if (acls.size() == 1) { ACL actualAcl = acls.get(0), expectedAcl = ZooUtil.PRIVATE.get(0); Id actualId = actualAcl.getId(); if (actualAcl.getPerms() == expectedAcl.getPerms() && actualId.getScheme().equals("digest") && actualId.getId().startsWith("accumulo:")) { initialized.set(true); return; } } else { log.error("Saw more than one ACL on the node"); } log.error("Expected {} to have ACLs {} but was {}", baseNode, ZooUtil.PRIVATE, acls); throw new IllegalStateException( "Delegation token secret key node in ZooKeeper is not protected."); } else { if (!zk.putPrivatePersistentData(baseNode, new byte[0], NodeExistsPolicy.FAIL)) { throw new AssertionError("Got false from putPrivatePersistentData method"); } } initialized.set(true); } ZooAuthenticationKeyDistributor(ZooReaderWriter zk, String baseNode); synchronized void initialize(); List<AuthenticationKey> getCurrentKeys(); synchronized void advertise(AuthenticationKey newKey); synchronized void remove(AuthenticationKey key);  }