Search in sources :

Example 16 with ACL

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project pulsar by yahoo.

the class MockedPulsarServiceBaseTest method createMockZooKeeper.

private MockZooKeeper createMockZooKeeper() throws Exception {
    MockZooKeeper zk = MockZooKeeper.newInstance(MoreExecutors.sameThreadExecutor());
    List<ACL> dummyAclList = new ArrayList<ACL>(0);
    ZkUtils.createFullPathOptimistic(zk, "/ledgers/available/192.168.1.1:" + 5000, "".getBytes(ZookeeperClientFactoryImpl.ENCODING_SCHEME), dummyAclList, CreateMode.PERSISTENT);
    zk.create("/ledgers/LAYOUT", "1\nflat:1".getBytes(ZookeeperClientFactoryImpl.ENCODING_SCHEME), dummyAclList, CreateMode.PERSISTENT);
    return zk;
}
Also used : MockZooKeeper(org.apache.zookeeper.MockZooKeeper) ArrayList(java.util.ArrayList) ACL(org.apache.zookeeper.data.ACL)

Example 17 with ACL

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project lucene-solr by apache.

the class SolrZkClientTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    final String SCHEME = "digest";
    final String AUTH = "user:pass";
    String zkDir = createTempDir().toString();
    log.info("ZooKeeper dataDir:" + zkDir);
    zkServer = new ZkTestServer(zkDir);
    zkServer.run();
    try (SolrZkClient client = new SolrZkClient(zkServer.getZkHost(), AbstractZkTestCase.TIMEOUT)) {
        // Set up chroot
        client.makePath("/solr", false, true);
    }
    defaultClient = new SolrZkClient(zkServer.getZkAddress(), AbstractZkTestCase.TIMEOUT);
    defaultClient.makePath(PATH, true);
    aclClient = new SolrZkClient(zkServer.getZkAddress(), AbstractZkTestCase.TIMEOUT) {

        @Override
        protected ZkACLProvider createZkACLProvider() {
            return new DefaultZkACLProvider() {

                @Override
                protected List<ACL> createGlobalACLsToAdd() {
                    try {
                        Id id = new Id(SCHEME, DigestAuthenticationProvider.generateDigest(AUTH));
                        return Collections.singletonList(new ACL(ZooDefs.Perms.ALL, id));
                    } catch (NoSuchAlgorithmException e) {
                        throw new RuntimeException(e);
                    }
                }
            };
        }
    };
    credentialsClient = new SolrZkClient(zkServer.getZkAddress(), AbstractZkTestCase.TIMEOUT) {

        @Override
        protected ZkCredentialsProvider createZkCredentialsToAddAutomatically() {
            return new DefaultZkCredentialsProvider() {

                @Override
                protected Collection<ZkCredentials> createCredentials() {
                    return Collections.singleton(new ZkCredentials(SCHEME, AUTH.getBytes(StandardCharsets.UTF_8)));
                }
            };
        }
    };
}
Also used : ZkTestServer(org.apache.solr.cloud.ZkTestServer) ACL(org.apache.zookeeper.data.ACL) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Collection(java.util.Collection) List(java.util.List) Id(org.apache.zookeeper.data.Id)

Example 18 with ACL

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project lucene-solr by apache.

the class SaslZkACLProvider method createSecurityACLsToAdd.

@Override
protected List<ACL> createSecurityACLsToAdd() {
    List<ACL> ret = new ArrayList<ACL>();
    ret.add(new ACL(ZooDefs.Perms.ALL, new Id("sasl", superUser)));
    return ret;
}
Also used : ArrayList(java.util.ArrayList) ACL(org.apache.zookeeper.data.ACL) Id(org.apache.zookeeper.data.Id)

Example 19 with ACL

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project camel by apache.

the class CreateOperationTest method createNodeWithSpecificAccess.

@Test
public void createNodeWithSpecificAccess() throws Exception {
    CreateOperation create = new CreateOperation(connection, "/four");
    create.setData(testPayload.getBytes());
    List<ACL> perms = Collections.singletonList(new ACL(Perms.CREATE, Ids.ANYONE_ID_UNSAFE));
    create.setPermissions(perms);
    OperationResult<String> result = create.get();
    assertEquals("/four", result.getResult());
    verifyAccessControlList("/four", perms);
}
Also used : ACL(org.apache.zookeeper.data.ACL) Test(org.junit.Test)

Example 20 with ACL

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project hadoop by apache.

the class ZKUtil method parseACLs.

/**
   * Parse comma separated list of ACL entries to secure generated nodes, e.g.
   * <code>sasl:hdfs/host1@MY.DOMAIN:cdrwa,sasl:hdfs/host2@MY.DOMAIN:cdrwa</code>
   *
   * @return ACL list
   * @throws {@link BadAclFormatException} if an ACL is invalid
   */
public static List<ACL> parseACLs(String aclString) throws BadAclFormatException {
    List<ACL> acl = Lists.newArrayList();
    if (aclString == null) {
        return acl;
    }
    List<String> aclComps = Lists.newArrayList(Splitter.on(',').omitEmptyStrings().trimResults().split(aclString));
    for (String a : aclComps) {
        // from ZooKeeperMain private method
        int firstColon = a.indexOf(':');
        int lastColon = a.lastIndexOf(':');
        if (firstColon == -1 || lastColon == -1 || firstColon == lastColon) {
            throw new BadAclFormatException("ACL '" + a + "' not of expected form scheme:id:perm");
        }
        ACL newAcl = new ACL();
        newAcl.setId(new Id(a.substring(0, firstColon), a.substring(firstColon + 1, lastColon)));
        newAcl.setPerms(getPermFromString(a.substring(lastColon + 1)));
        acl.add(newAcl);
    }
    return acl;
}
Also used : ACL(org.apache.zookeeper.data.ACL) Id(org.apache.zookeeper.data.Id)

Aggregations

ACL (org.apache.zookeeper.data.ACL)215 Id (org.apache.zookeeper.data.Id)85 ArrayList (java.util.ArrayList)61 Test (org.junit.Test)56 Stat (org.apache.zookeeper.data.Stat)45 KeeperException (org.apache.zookeeper.KeeperException)35 Test (org.testng.annotations.Test)32 CuratorFramework (org.apache.curator.framework.CuratorFramework)20 Test (org.junit.jupiter.api.Test)18 Configuration (org.apache.hadoop.conf.Configuration)17 ZooKeeper (org.apache.zookeeper.ZooKeeper)16 ACLProvider (org.apache.curator.framework.api.ACLProvider)15 List (java.util.List)11 IOException (java.io.IOException)10 CountDownLatch (java.util.concurrent.CountDownLatch)9 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)8 TestableZooKeeper (org.apache.zookeeper.TestableZooKeeper)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 HashMap (java.util.HashMap)6 CreateMode (org.apache.zookeeper.CreateMode)6