本文整理了Java中org.apache.zookeeper.data.ACL.<init>()
方法的一些代码示例,展示了ACL.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ACL.<init>()
方法的具体详情如下:
包路径:org.apache.zookeeper.data.ACL
类名称:ACL
方法名:<init>
暂无
代码示例来源:origin: org.apache.hadoop/hadoop-common
private SASLOwnerACLProvider(String principal) {
this.saslACL = Collections.singletonList(
new ACL(Perms.ALL, new Id("sasl", principal)));
}
代码示例来源:origin: apache/zookeeper
private List<ACL> createACL(String id) {
List<ACL> acl1 = new ArrayList<ACL>();
acl1.add(new ACL(ZooDefs.Perms.ADMIN, new Id("scheme", id)));
return acl1;
}
}
代码示例来源:origin: apache/zookeeper
@Test
public void testSuperIsSuper() throws Exception {
ZooKeeper zk = createClient();
try {
zk.create("/digest_read", null, Arrays.asList(new ACL(Perms.READ, otherDigestUser)), CreateMode.PERSISTENT);
zk.create("/digest_read/sub", null, Arrays.asList(new ACL(Perms.READ, otherDigestUser)), CreateMode.PERSISTENT);
zk.create("/sasl_read", null, Arrays.asList(new ACL(Perms.READ, otherSaslUser)), CreateMode.PERSISTENT);
zk.create("/sasl_read/sub", null, Arrays.asList(new ACL(Perms.READ, otherSaslUser)), CreateMode.PERSISTENT);
zk.delete("/digest_read/sub", -1);
zk.delete("/digest_read", -1);
zk.delete("/sasl_read/sub", -1);
zk.delete("/sasl_read", -1);
//If the test failes it will most likely fail with a NoAuth exception before it ever gets to this assertion
Assert.assertEquals(authFailed.get(), 0);
} finally {
zk.close();
}
}
}
代码示例来源:origin: apache/zookeeper
public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
a_.startRecord(tag);
{
Index vidx1 = a_.startVector("acl");
if (vidx1!= null) { acl=new java.util.ArrayList<org.apache.zookeeper.data.ACL>();
for (; !vidx1.done(); vidx1.incr()) {
org.apache.zookeeper.data.ACL e1;
e1= new org.apache.zookeeper.data.ACL();
a_.readRecord(e1,"e1");
acl.add(e1);
}
}
a_.endVector("acl");
}
stat= new org.apache.zookeeper.data.Stat();
a_.readRecord(stat,"stat");
a_.endRecord(tag);
}
public String toString() {
代码示例来源:origin: apache/zookeeper
@Test
public void testValidSaslIds() throws Exception {
ZooKeeper zk = createClient();
List<String> validIds = new ArrayList<String>();
validIds.add("user");
validIds.add("service/host.name.com");
validIds.add("user@KERB.REALM");
validIds.add("service/host.name.com@KERB.REALM");
int i = 0;
for(String validId: validIds) {
List<ACL> aclList = new ArrayList<ACL>();
ACL acl = new ACL(0,new Id("sasl",validId));
aclList.add(acl);
zk.create("/valid"+i,null,aclList,CreateMode.PERSISTENT);
i++;
}
}
代码示例来源:origin: apache/zookeeper
@Test
public void testWhetherOrderingMatters() {
List<ACL> testACL = new ArrayList<ACL>();
testACL.add(new ACL(ZooDefs.Perms.READ, new Id("scheme", "ro")));
testACL.add(new ACL(ZooDefs.Perms.WRITE, new Id("scheme", "rw")));
ReferenceCountedACLCache cache = new ReferenceCountedACLCache();
Long aclId = cache.convertAcls(testACL);
List<ACL> testACL2 = new ArrayList<ACL>();
testACL2.add(new ACL(ZooDefs.Perms.WRITE, new Id("scheme", "rw")));
testACL2.add(new ACL(ZooDefs.Perms.READ, new Id("scheme", "ro")));
assertFalse(aclId.equals(cache.convertAcls(testACL2)));
}
代码示例来源:origin: apache/zookeeper
public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
a_.startRecord(tag);
path=a_.readString("path");
{
Index vidx1 = a_.startVector("acl");
if (vidx1!= null) { acl=new java.util.ArrayList<org.apache.zookeeper.data.ACL>();
for (; !vidx1.done(); vidx1.incr()) {
org.apache.zookeeper.data.ACL e1;
e1= new org.apache.zookeeper.data.ACL();
a_.readRecord(e1,"e1");
acl.add(e1);
}
}
a_.endVector("acl");
}
version=a_.readInt("version");
a_.endRecord(tag);
}
public String toString() {
代码示例来源:origin: apache/zookeeper
public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
a_.startRecord(tag);
path=a_.readString("path");
{
Index vidx1 = a_.startVector("acl");
if (vidx1!= null) { acl=new java.util.ArrayList<org.apache.zookeeper.data.ACL>();
for (; !vidx1.done(); vidx1.incr()) {
org.apache.zookeeper.data.ACL e1;
e1= new org.apache.zookeeper.data.ACL();
a_.readRecord(e1,"e1");
acl.add(e1);
}
}
a_.endVector("acl");
}
version=a_.readInt("version");
a_.endRecord(tag);
}
public String toString() {
代码示例来源:origin: apache/zookeeper
@Test
public void testInvalidSaslIds() throws Exception {
ZooKeeper zk = createClient();
List<String> invalidIds = new ArrayList<String>();
invalidIds.add("user@KERB.REALM/server.com");
invalidIds.add("user@KERB.REALM1@KERB.REALM2");
int i = 0;
for(String invalidId: invalidIds) {
List<ACL> aclList = new ArrayList<ACL>();
try {
ACL acl = new ACL(0,new Id("sasl",invalidId));
aclList.add(acl);
zk.create("/invalid"+i,null,aclList,CreateMode.PERSISTENT);
Assert.fail("SASLAuthenticationProvider.isValid() failed to catch invalid Id.");
}
catch (KeeperException.InvalidACLException e) {
// ok.
}
finally {
i++;
}
}
}
代码示例来源:origin: apache/zookeeper
public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
a_.startRecord(tag);
path=a_.readString("path");
data=a_.readBuffer("data");
{
Index vidx1 = a_.startVector("acl");
if (vidx1!= null) { acl=new java.util.ArrayList<org.apache.zookeeper.data.ACL>();
for (; !vidx1.done(); vidx1.incr()) {
org.apache.zookeeper.data.ACL e1;
e1= new org.apache.zookeeper.data.ACL();
a_.readRecord(e1,"e1");
acl.add(e1);
}
}
a_.endVector("acl");
}
flags=a_.readInt("flags");
a_.endRecord(tag);
}
public String toString() {
代码示例来源:origin: apache/zookeeper
public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
a_.startRecord(tag);
path=a_.readString("path");
data=a_.readBuffer("data");
{
Index vidx1 = a_.startVector("acl");
if (vidx1!= null) { acl=new java.util.ArrayList<org.apache.zookeeper.data.ACL>();
for (; !vidx1.done(); vidx1.incr()) {
org.apache.zookeeper.data.ACL e1;
e1= new org.apache.zookeeper.data.ACL();
a_.readRecord(e1,"e1");
acl.add(e1);
}
}
a_.endVector("acl");
}
ephemeral=a_.readBool("ephemeral");
a_.endRecord(tag);
}
public String toString() {
代码示例来源:origin: apache/zookeeper
public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
a_.startRecord(tag);
path=a_.readString("path");
data=a_.readBuffer("data");
{
Index vidx1 = a_.startVector("acl");
if (vidx1!= null) { acl=new java.util.ArrayList<org.apache.zookeeper.data.ACL>();
for (; !vidx1.done(); vidx1.incr()) {
org.apache.zookeeper.data.ACL e1;
e1= new org.apache.zookeeper.data.ACL();
a_.readRecord(e1,"e1");
acl.add(e1);
}
}
a_.endVector("acl");
}
parentCVersion=a_.readInt("parentCVersion");
a_.endRecord(tag);
}
public String toString() {
代码示例来源:origin: apache/hbase
@Test
public void testSecuritySingleSuperuser() throws ZooKeeperConnectionException, IOException {
Configuration conf = HBaseConfiguration.create();
conf.set(Superusers.SUPERUSER_CONF_KEY, "user1");
String node = "/hbase/testSecuritySingleSuperuser";
ZKWatcher watcher = new ZKWatcher(conf, node, null, false);
List<ACL> aclList = ZKUtil.createACL(watcher, node, true);
assertEquals(2, aclList.size()); // 1+1, since ACL will be set for the creator by default
assertTrue(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "user1"))));
assertTrue(aclList.contains(Ids.CREATOR_ALL_ACL.iterator().next()));
}
代码示例来源:origin: apache/zookeeper
public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
a_.startRecord(tag);
path=a_.readString("path");
data=a_.readBuffer("data");
{
Index vidx1 = a_.startVector("acl");
if (vidx1!= null) { acl=new java.util.ArrayList<org.apache.zookeeper.data.ACL>();
for (; !vidx1.done(); vidx1.incr()) {
org.apache.zookeeper.data.ACL e1;
e1= new org.apache.zookeeper.data.ACL();
a_.readRecord(e1,"e1");
acl.add(e1);
}
}
a_.endVector("acl");
}
ephemeral=a_.readBool("ephemeral");
parentCVersion=a_.readInt("parentCVersion");
a_.endRecord(tag);
}
public String toString() {
代码示例来源:origin: apache/hbase
@Test
public void testCreateACL() throws ZooKeeperConnectionException, IOException {
Configuration conf = HBaseConfiguration.create();
conf.set(Superusers.SUPERUSER_CONF_KEY, "user1,@group1,user2,@group2,user3");
String node = "/hbase/testCreateACL";
ZKWatcher watcher = new ZKWatcher(conf, node, null, false);
List<ACL> aclList = ZKUtil.createACL(watcher, node, true);
assertEquals(4, aclList.size()); // 3+1, since ACL will be set for the creator by default
assertFalse(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "@group1"))));
assertFalse(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "@group2"))));
assertTrue(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "user1"))));
assertTrue(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "user2"))));
assertTrue(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "user3"))));
}
代码示例来源:origin: apache/zookeeper
public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
a_.startRecord(tag);
path=a_.readString("path");
data=a_.readBuffer("data");
{
Index vidx1 = a_.startVector("acl");
if (vidx1!= null) { acl=new java.util.ArrayList<org.apache.zookeeper.data.ACL>();
for (; !vidx1.done(); vidx1.incr()) {
org.apache.zookeeper.data.ACL e1;
e1= new org.apache.zookeeper.data.ACL();
a_.readRecord(e1,"e1");
acl.add(e1);
}
}
a_.endVector("acl");
}
flags=a_.readInt("flags");
ttl=a_.readLong("ttl");
a_.endRecord(tag);
}
public String toString() {
代码示例来源:origin: apache/zookeeper
public void deserialize(InputArchive a_, String tag) throws java.io.IOException {
a_.startRecord(tag);
path=a_.readString("path");
data=a_.readBuffer("data");
{
Index vidx1 = a_.startVector("acl");
if (vidx1!= null) { acl=new java.util.ArrayList<org.apache.zookeeper.data.ACL>();
for (; !vidx1.done(); vidx1.incr()) {
org.apache.zookeeper.data.ACL e1;
e1= new org.apache.zookeeper.data.ACL();
a_.readRecord(e1,"e1");
acl.add(e1);
}
}
a_.endVector("acl");
}
parentCVersion=a_.readInt("parentCVersion");
ttl=a_.readLong("ttl");
a_.endRecord(tag);
}
public String toString() {
代码示例来源:origin: apache/hbase
@Test
public void testCreateACLWithSameUser() throws ZooKeeperConnectionException, IOException {
Configuration conf = HBaseConfiguration.create();
conf.set(Superusers.SUPERUSER_CONF_KEY, "user4,@group1,user5,user6");
UserGroupInformation.setLoginUser(UserGroupInformation.createRemoteUser("user4"));
String node = "/hbase/testCreateACL";
ZKWatcher watcher = new ZKWatcher(conf, node, null, false);
List<ACL> aclList = ZKUtil.createACL(watcher, node, true);
assertEquals(3, aclList.size()); // 3, since service user the same as one of superuser
assertFalse(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "@group1"))));
assertTrue(aclList.contains(new ACL(Perms.ALL, new Id("auth", ""))));
assertTrue(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "user5"))));
assertTrue(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "user6"))));
}
代码示例来源:origin: apache/zookeeper
@Test(timeout = 10000)
public void testReconfigEnabledWithAuthAndACL() throws InterruptedException {
resetZKAdmin();
try {
zkAdmin.addAuthInfo("digest", "super:test".getBytes());
ArrayList<ACL> acls = new ArrayList<ACL>(
Collections.singletonList(
new ACL(ZooDefs.Perms.WRITE,
new Id("digest", "user:tl+z3z0vO6PfPfEENfLF96E6pM0="/* password is test */))));
zkAdmin.setACL(ZooDefs.CONFIG_NODE, acls, -1);
resetZKAdmin();
zkAdmin.addAuthInfo("digest", "user:test".getBytes());
Assert.assertTrue(reconfigPort());
} catch (KeeperException e) {
Assert.fail("Reconfig should not fail, but failed with exception : " + e.getMessage());
}
}
代码示例来源:origin: apache/zookeeper
@Test(timeout = 10000)
public void testReconfigEnabledWithAuthAndWrongACL() throws InterruptedException {
resetZKAdmin();
try {
zkAdmin.addAuthInfo("digest", "super:test".getBytes());
// There is ACL however the permission is wrong - need WRITE permission at leaste.
ArrayList<ACL> acls = new ArrayList<ACL>(
Collections.singletonList(
new ACL(ZooDefs.Perms.READ,
new Id("digest", "user:tl+z3z0vO6PfPfEENfLF96E6pM0="/* password is test */))));
zkAdmin.setACL(ZooDefs.CONFIG_NODE, acls, -1);
resetZKAdmin();
zkAdmin.addAuthInfo("digest", "user:test".getBytes());
reconfigPort();
Assert.fail("Reconfig should fail with an ACL that is read only!");
} catch (KeeperException e) {
Assert.assertTrue(e.code() == KeeperException.Code.NOAUTH);
}
}
内容来源于网络,如有侵权,请联系作者删除!