【发布时间】:2015-01-07 13:48:49
【问题描述】:
我正在尝试为节点创建 acl:
ZooKeeper client = new ZooKeeper("host:port/rootNode", 3000, null);
ACL acl = new ACL(Perms.CREATE,new Id("digest","user:pass"));
client.create("/testNode",new String("test").getBytes(), Arrays.asList(acl), CreateMode.PERSISTENT);
client.close();
然后我尝试访问该节点并在“testNode”下创建一个节点:
ZooKeeper client = new ZooKeeper(" host:port/rootNode", 3000, null);
client.addAuthInfo("digest", new String("user:pass").getBytes());
Stat stat;
try {
stat = client.exists("/testNode", false);
if(stat!=null){
client.create("/testNode/clientTest", new String("clienttest").getBytes(),Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
}
} catch (KeeperException e) {
e.printStackTrace();
}
client.close();
但它给了我:
org.apache.zookeeper.KeeperException$NoAuthException: KeeperErrorCode = NoAuth for /testNode/clientTest
我什么时候错了?
谢谢!
【问题讨论】:
-
面临同样的问题。
标签: java authentication apache-zookeeper digest-authentication