Example usage for org.apache.zookeeper.server.auth DigestAuthenticationProvider generateDigest

List of usage examples for org.apache.zookeeper.server.auth DigestAuthenticationProvider generateDigest

Introduction

In this page you can find the example usage for org.apache.zookeeper.server.auth DigestAuthenticationProvider generateDigest.

Prototype

public static String generateDigest(String idPassword) throws NoSuchAlgorithmException 

Source Link

Usage

From source file:org.trustedanalytics.auth.gateway.engine.ZookeeperTest.java

License:Apache License

@Before
public void setUp() throws Exception {
    curatorFramework = CuratorFrameworkFactory.builder().connectString(testingServer.getConnectString())
            .retryPolicy(new RetryNTimes(3, 1000)).authorization("digest", "myuser:mypass".getBytes()).build();
    curatorFramework.start();//  www  .j  a v  a 2 s.  com
    acl = new ACL(ZooDefs.Perms.ALL,
            new Id("digest", DigestAuthenticationProvider.generateDigest("myuser:mypass")));
    client = new ZookeeperClient(curatorFramework, acl, BASE_DIR);
    client.init();
    // different zookeeper root node for each test - to avoid test server restart between tests
    znode = "/" + getClass().getSimpleName() + "_" + testName.getMethodName();
}

From source file:org.trustedanalytics.auth.gateway.zookeeper.ZookeeperClientConfig.java

License:Apache License

@Bean(initMethod = "init", destroyMethod = "destroy")
public ZookeeperClient getZookeeperClient() throws NoSuchAlgorithmException {
    ACL acl;//  w  w w. ja v a2 s. com
    if (zookeeperConfig.isKerberos())
        acl = new ACL(ZooDefs.Perms.ALL, new Id("sasl", zookeeperConfig.getUsername()));
    else
        acl = new ACL(ZooDefs.Perms.ALL, new Id("digest", DigestAuthenticationProvider.generateDigest(
                String.format("%s:%s", zookeeperConfig.getUsername(), zookeeperConfig.getPassword()))));
    return new ZookeeperClient(curator, acl, zookeeperConfig.getNode());
}

From source file:org.trustedanalytics.cfbroker.store.zookeeper.service.integration.ZookeeperClientBuilderTest.java

License:Apache License

private void testZookeeperClientWithRootCreation() throws Exception {
    String digest = DigestAuthenticationProvider.generateDigest(String.format("%s:%s", USERNAME, PASSWORD));
    List<ACL> acl = Arrays.asList(new ACL(ZooDefs.Perms.ALL, new Id("digest", digest)));

    ZookeeperClient zkClient = new ZookeeperClientBuilder(connectionString, USERNAME, PASSWORD, ROOT_DIR)
            .withRootCreation(acl).build();
    zkClient.init();/*from ww w . j a  v a 2  s .  c o  m*/
    zkClient.exists(ROOT_DIR);
    zkClient.destroy();
}