当前位置: 首页>>代码示例>>Java>>正文


Java Id类代码示例

本文整理汇总了Java中org.apache.zookeeper.data.Id的典型用法代码示例。如果您正苦于以下问题:Java Id类的具体用法?Java Id怎么用?Java Id使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Id类属于org.apache.zookeeper.data包,在下文中一共展示了Id类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testValidSaslIds

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
@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("[email protected]");
    validIds.add("service/[email protected]");

    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++;
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:20,代码来源:SaslAuthTest.java

示例2: getZnodeAclFromTable

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
public List<ACL> getZnodeAclFromTable() {

        Table table = getTable();
        TableItem[] items = table.getItems();

        Set<ACL> aclSet = new HashSet<ACL>(items.length);
        for (TableItem item : items) {

            int perms = getItemPerms(item);
            Id id = getItemId(item);

            ACL acl = new ACL(perms, id);
            aclSet.add(acl);
        }
        return new ArrayList<ACL>(aclSet);
    }
 
开发者ID:baloise,项目名称:eZooKeeper,代码行数:17,代码来源:ZnodeAclComposite.java

示例3: parseACLs

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
private static List<ACL> parseACLs(String aclString) {
    List<ACL> acl;
    String acls[] = aclString.split(",");
    acl = new ArrayList<ACL>();
    for (String a : acls) {
        int firstColon = a.indexOf(':');
        int lastColon = a.lastIndexOf(':');
        if (firstColon == -1 || lastColon == -1 || firstColon == lastColon) {
            System.err
            .println(a + " does not have the form scheme:id:perm");
            continue;
        }
        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;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:21,代码来源:ZooKeeperMain.java

示例4: handleAuthentication

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
public KeeperException.Code 
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
    String id = new String(authData);
    try {
        String digest = generateDigest(id);
        if (digest.equals(superDigest)) {
            cnxn.addAuthInfo(new Id("super", ""));
        }
        cnxn.addAuthInfo(new Id(getScheme(), digest));
        return KeeperException.Code.OK;
    } catch (NoSuchAlgorithmException e) {
        LOG.error("Missing algorithm",e);
    }
    return KeeperException.Code.AUTHFAILED;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:17,代码来源:DigestAuthenticationProvider.java

示例5: NIOServerCnxn

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
public NIOServerCnxn(ZooKeeperServer zk, SocketChannel sock,
        SelectionKey sk, NIOServerCnxnFactory factory) throws IOException {
    this.zkServer = zk;
    this.sock = sock;
    this.sk = sk;
    this.factory = factory;
    if (this.factory.login != null) {
        this.zooKeeperSaslServer = new ZooKeeperSaslServer(factory.login);
    }
    if (zk != null) { 
        outstandingLimit = zk.getGlobalOutstandingLimit();
    }
    sock.socket().setTcpNoDelay(true);
    /* set socket linger to false, so that socket close does not
     * block */
    sock.socket().setSoLinger(false, -1);
    InetAddress addr = ((InetSocketAddress) sock.socket()
            .getRemoteSocketAddress()).getAddress();
    authInfo.add(new Id("ip", addr.getHostAddress()));
    sk.interestOps(SelectionKey.OP_READ);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:22,代码来源:NIOServerCnxn.java

示例6: testInvalidSaslIds

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
@Test
public void testInvalidSaslIds() throws Exception {
    ZooKeeper zk = createClient();

    List<String> invalidIds = new ArrayList<String>();
    invalidIds.add("[email protected]/server.com");
    invalidIds.add("[email protected]@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++;
        }
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:26,代码来源:SaslAuthTest.java

示例7: NIOServerCnxn

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
public NIOServerCnxn(ZooKeeperServer zk, SocketChannel sock,
                     SelectionKey sk, NIOServerCnxnFactory factory,
                     SelectorThread selectorThread) throws IOException {
    this.zkServer = zk;
    this.sock = sock;
    this.sk = sk;
    this.factory = factory;
    this.selectorThread = selectorThread;
    if (this.factory.login != null) {
        this.zooKeeperSaslServer = new ZooKeeperSaslServer(factory.login);
    }
    if (zk != null) {
        outstandingLimit = zk.getGlobalOutstandingLimit();
    } else {
        outstandingLimit = 1;
    }
    sock.socket().setTcpNoDelay(true);
    /* set socket linger to false, so that socket close does not block */
    sock.socket().setSoLinger(false, -1);
    InetAddress addr = ((InetSocketAddress) sock.socket()
            .getRemoteSocketAddress()).getAddress();
    addAuthInfo(new Id("ip", addr.getHostAddress()));
    this.sessionTimeout = factory.sessionlessCnxnTimeout;
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:25,代码来源:NIOServerCnxn.java

示例8: parse

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
/**
 * parse string into list of ACL
 * @param aclString
 * @return 
 */
public static List<ACL> parse(String aclString) {
    List<ACL> acl;
    String acls[] = aclString.split(",");
    acl = new ArrayList<ACL>();
    for (String a : acls) {
        int firstColon = a.indexOf(':');
        int lastColon = a.lastIndexOf(':');
        if (firstColon == -1 || lastColon == -1 || firstColon == lastColon) {
            System.err.println(a + " does not have the form scheme:id:perm");
            continue;
        }
        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;
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:25,代码来源:AclParser.java

示例9: setupStatic

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
@BeforeClass
public static void setupStatic() throws Exception {
    oldAuthProvider = System.setProperty("zookeeper.authProvider.1","org.apache.zookeeper.server.auth.SASLAuthenticationProvider");

    File tmpDir = createTmpDir();
    File saslConfFile = new File(tmpDir, "jaas.conf");
    FileWriter fwriter = new FileWriter(saslConfFile);

    fwriter.write("" +
            "Server {\n" +
            "          org.apache.zookeeper.server.auth.DigestLoginModule required\n" +
            "          user_super_duper=\"test\";\n" +
            "};\n" +
            "Client {\n" +
            "       org.apache.zookeeper.server.auth.DigestLoginModule required\n" +
            "       username=\"super_duper\"\n" +
            "       password=\"test\";\n" +
            "};" + "\n");
    fwriter.close();
    oldLoginConfig = System.setProperty("java.security.auth.login.config",saslConfFile.getAbsolutePath());
    oldSuperUser = System.setProperty("zookeeper.superUser","super_duper");
    otherDigestUser = new Id ("digest", DigestAuthenticationProvider.generateDigest("jack:jack"));
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:24,代码来源:SaslSuperUserTest.java

示例10: testReconfigEnabledWithAuthAndWrongACL

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:21,代码来源:ReconfigExceptionTest.java

示例11: testReconfigEnabledWithAuthAndACL

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:19,代码来源:ReconfigExceptionTest.java

示例12: constructZkRootNodeACL

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
/**
 * Given the {@link Configuration} and {@link ACL}s used (zkAcl) for
 * ZooKeeper access, construct the {@link ACL}s for the store's root node.
 * In the constructed {@link ACL}, all the users allowed by zkAcl are given
 * rwa access, while the current RM has exclude create-delete access.
 *
 * To be called only when HA is enabled and the configuration doesn't set ACL
 * for the root node.
 */
@VisibleForTesting
@Private
@Unstable
protected List<ACL> constructZkRootNodeACL(
    Configuration conf, List<ACL> sourceACLs) throws NoSuchAlgorithmException {
  List<ACL> zkRootNodeAcl = new ArrayList<ACL>();
  for (ACL acl : sourceACLs) {
    zkRootNodeAcl.add(new ACL(
        ZKUtil.removeSpecificPerms(acl.getPerms(), CREATE_DELETE_PERMS),
        acl.getId()));
  }

  zkRootNodeUsername = HAUtil.getConfValueForRMInstance(
      YarnConfiguration.RM_ADDRESS,
      YarnConfiguration.DEFAULT_RM_ADDRESS, conf);
  Id rmId = new Id(zkRootNodeAuthScheme,
      DigestAuthenticationProvider.generateDigest(
          zkRootNodeUsername + ":" + zkRootNodePassword));
  zkRootNodeAcl.add(new ACL(CREATE_DELETE_PERMS, rmId));
  return zkRootNodeAcl;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:ZKRMStateStore.java

示例13: parse

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
/**
 * Parse a string down to an ID, adding a realm if needed
 * @param idPair id:data tuple
 * @param realm realm to add
 * @return the ID.
 * @throws IllegalArgumentException if the idPair is invalid
 */
public Id parse(String idPair, String realm) {
  int firstColon = idPair.indexOf(':');
  int lastColon = idPair.lastIndexOf(':');
  if (firstColon == -1 || lastColon == -1 || firstColon != lastColon) {
    throw new IllegalArgumentException(
        "ACL '" + idPair + "' not of expected form scheme:id");
  }
  String scheme = idPair.substring(0, firstColon);
  String id = idPair.substring(firstColon + 1);
  if (id.endsWith("@")) {
    Preconditions.checkArgument(
        StringUtils.isNotEmpty(realm),
        "@ suffixed account but no realm %s", id);
    id = id + realm;
  }
  return new Id(scheme, id);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:RegistrySecurity.java

示例14: testUserHomedirsPermissionsRestricted

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
@Test
public void testUserHomedirsPermissionsRestricted() throws Throwable {
  // test that the /users/$user permissions are restricted
  RMRegistryOperationsService rmRegistryOperations =
      startRMRegistryOperations();
  // create Alice's dir, so it should have an ACL for Alice
  final String home = rmRegistryOperations.initUserRegistry(ALICE);
  List<ACL> acls = rmRegistryOperations.zkGetACLS(home);
  ACL aliceACL = null;
  for (ACL acl : acls) {
    LOG.info(RegistrySecurity.aclToString(acl));
    Id id = acl.getId();
    if (id.getScheme().equals(ZookeeperConfigOptions.SCHEME_SASL)
        && id.getId().startsWith(ALICE)) {

      aliceACL = acl;
      break;
    }
  }
  assertNotNull(aliceACL);
  assertEquals(RegistryAdminService.USER_HOMEDIR_ACL_PERMISSIONS,
      aliceACL.getPerms());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestSecureRMRegistryOperations.java

示例15: createZookeeper

import org.apache.zookeeper.data.Id; //导入依赖的package包/类
private void createZookeeper(final CountDownLatch connectionLatch) throws Exception {
	zk = new ZooKeeper(this.properties.getProperty(keys.zkConnectString
			.toString()), Integer.parseInt(this.properties
			.getProperty(keys.zkSessionTimeout.toString())),
			new Watcher() {
				public void process(WatchedEvent event) {
					sessionEvent(connectionLatch, event);
				}
			});
	String authString = this.properties.getProperty(keys.userName.toString())
			+ ":"+ this.properties.getProperty(keys.password.toString());
	this.isCheckParentPath = Boolean.parseBoolean(this.properties.getProperty(keys.isCheckParentPath.toString(),"true"));
	zk.addAuthInfo("digest", authString.getBytes());
	acl.clear();
	acl.add(new ACL(ZooDefs.Perms.ALL, new Id("digest",
			DigestAuthenticationProvider.generateDigest(authString))));
	acl.add(new ACL(ZooDefs.Perms.READ, Ids.ANYONE_ID_UNSAFE));
}
 
开发者ID:hungki,项目名称:tbschedule-wed,代码行数:19,代码来源:ZKManager.java


注:本文中的org.apache.zookeeper.data.Id类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。