use of org.apache.hadoop.registry.client.impl.RegistryOperationsClient in project hadoop by apache.
the class RegistryOperationsFactory method createInstance.
/**
* Create and initialize a registry operations instance.
* Access rights will be determined from the configuration
* @param name name of the instance
* @param conf configuration
* @return a registry operations instance
* @throws ServiceStateException on any failure to initialize
*/
public static RegistryOperations createInstance(String name, Configuration conf) {
Preconditions.checkArgument(conf != null, "Null configuration");
RegistryOperationsClient operations = new RegistryOperationsClient(name);
operations.init(conf);
return operations;
}
use of org.apache.hadoop.registry.client.impl.RegistryOperationsClient in project hadoop by apache.
the class TestSecureRMRegistryOperations method testDigestAccess.
@Test
public void testDigestAccess() throws Throwable {
RMRegistryOperationsService registryAdmin = startRMRegistryOperations();
String id = "username";
String pass = "password";
registryAdmin.addWriteAccessor(id, pass);
List<ACL> clientAcls = registryAdmin.getClientAcls();
LOG.info("Client ACLS=\n{}", RegistrySecurity.aclsToString(clientAcls));
String base = "/digested";
registryAdmin.mknode(base, false);
List<ACL> baseACLs = registryAdmin.zkGetACLS(base);
String aclset = RegistrySecurity.aclsToString(baseACLs);
LOG.info("Base ACLs=\n{}", aclset);
ACL found = null;
for (ACL acl : baseACLs) {
if (ZookeeperConfigOptions.SCHEME_DIGEST.equals(acl.getId().getScheme())) {
found = acl;
break;
}
}
assertNotNull("Did not find digest entry in ACLs " + aclset, found);
zkClientConf.set(KEY_REGISTRY_USER_ACCOUNTS, "sasl:somebody@EXAMPLE.COM, sasl:other");
RegistryOperations operations = RegistryOperationsFactory.createAuthenticatedInstance(zkClientConf, id, pass);
addToTeardown(operations);
operations.start();
RegistryOperationsClient operationsClient = (RegistryOperationsClient) operations;
List<ACL> digestClientACLs = operationsClient.getClientAcls();
LOG.info("digest client ACLs=\n{}", RegistrySecurity.aclsToString(digestClientACLs));
operations.stat(base);
operations.mknode(base + "/subdir", false);
ZKPathDumper pathDumper = registryAdmin.dumpPath(true);
LOG.info(pathDumper.toString());
}
Aggregations