org.apache.zookeeper.data.ACL.setPerms()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(59)

本文整理了Java中org.apache.zookeeper.data.ACL.setPerms()方法的一些代码示例,展示了ACL.setPerms()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ACL.setPerms()方法的具体详情如下:
包路径:org.apache.zookeeper.data.ACL
类名称:ACL
方法名:setPerms

ACL.setPerms介绍

暂无

代码示例

代码示例来源:origin: apache/zookeeper

/**
 * 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;
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

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;
  }
}

代码示例来源:origin: apache/hive

/**
 * Parse comma separated list of ACL entries to secure generated nodes, e.g.
 * <code>sasl:hive/host1@MY.DOMAIN:cdrwa,sasl:hive/host2@MY.DOMAIN:cdrwa</code>
 * @param aclString
 * @return ACL list
 */
public static List<ACL> parseACLs(String aclString) {
 String[] aclComps = StringUtils.splitByWholeSeparator(aclString, ",");
 List<ACL> acl = new ArrayList<ACL>(aclComps.length);
 for (String a : aclComps) {
  if (StringUtils.isBlank(a)) {
    continue;
  }
  a = a.trim();
  // from ZooKeeperMain private method
  int firstColon = a.indexOf(':');
  int lastColon = a.lastIndexOf(':');
  if (firstColon == -1 || lastColon == -1 || firstColon == lastColon) {
    LOGGER.error(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;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

newAcl.setId(new Id(a.substring(0, firstColon), a.substring(
  firstColon + 1, lastColon)));
newAcl.setPerms(getPermFromString(a.substring(lastColon + 1)));
acl.add(newAcl);

代码示例来源:origin: apache/zookeeper

path = "/" + j;
ACL acl = new ACL();
acl.setPerms(0);
Id id = new Id();
id.setId("1.1.1."+j);
path = "/" + j;
ACL acl = new ACL();
acl.setPerms(0);
Id id = new Id();
id.setId("1.1.1."+j);

代码示例来源:origin: apache/phoenix

@Override
public List<ACL> getAcls() {
  ACL acl = new ACL();
  acl.setId(new Id("digest",getZkLbUserName()+":"+getZkLbPassword()));
  acl.setPerms(ZooDefs.Perms.READ);
  return Arrays.asList(acl);
}

代码示例来源:origin: org.apache.activemq/activemq-leveldb-store

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;
}

代码示例来源:origin: org.apache.activemq/activemq-all

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;
}

代码示例来源:origin: org.fusesource.fabric/fabric-zookeeper-commands

protected 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;
}

代码示例来源:origin: jboss-fuse/fabric8

/**
 * Parses a {@link String} representation of the {@link ACL} list.
 */
private 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) {
      LOGGER.warn(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;
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

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;
}

代码示例来源:origin: org.apache.hadoop/zookeeper

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;
  }
}

代码示例来源:origin: io.fabric8/fabric-zookeeper

/**
 * Parses a {@link String} representation of the {@link ACL} list.
 */
private 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) {
      LOGGER.warn(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;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-registry

/**
 * Parse the IDs, adding a realm if needed, setting the permissions
 * @param principalList id string
 * @param realm realm to add
 * @param perms permissions
 * @return the relevant ACLs
 * @throws IOException
 */
public List<ACL> buildACLs(String principalList, String realm, int perms)
  throws IOException {
 List<String> aclPairs = splitAclPairs(principalList, realm);
 List<ACL> ids = new ArrayList<ACL>(aclPairs.size());
 for (String aclPair : aclPairs) {
  ACL newAcl = new ACL();
  newAcl.setId(parse(aclPair, realm));
  newAcl.setPerms(perms);
  ids.add(newAcl);
 }
 return ids;
}

代码示例来源:origin: io.hops/hadoop-yarn-registry

/**
 * Parse the IDs, adding a realm if needed, setting the permissions
 * @param principalList id string
 * @param realm realm to add
 * @param perms permissions
 * @return the relevant ACLs
 * @throws IOException
 */
public List<ACL> buildACLs(String principalList, String realm, int perms)
  throws IOException {
 List<String> aclPairs = splitAclPairs(principalList, realm);
 List<ACL> ids = new ArrayList<ACL>(aclPairs.size());
 for (String aclPair : aclPairs) {
  ACL newAcl = new ACL();
  newAcl.setId(parse(aclPair, realm));
  newAcl.setPerms(perms);
  ids.add(newAcl);
 }
 return ids;
}

代码示例来源:origin: strimzi/strimzi-kafka-operator

/**
 * Set the given permissions for the given user authenticated with the given password.
 */
public AclBuilder addDigest(String username, String password, Permission... permissions) {
  Map<String, ACL> digests = getDigests();
  ACL a = digests.get(username);
  if (a == null) {
    a = new ACL();
    digests.put(username, a);
  }
  a.setId(new Id("digest", username + ":" + password));
  a.setPerms(Permission.encode(permissions));
  return this;
}

代码示例来源:origin: strimzi/strimzi-kafka-operator

/**
 * Set the given permissions for users connecting from the given host
 * (as resolved on the Zookeeper server, from the client's IP address).
 */
public AclBuilder addHost(String host, Permission... permissions) {
  Map<String, ACL> hosts = getHosts();
  ACL a = hosts.get(host);
  if (a == null) {
    a = new ACL();
    hosts.put(host, a);
  }
  a.setId(new Id("host", host));
  a.setPerms(Permission.encode(permissions));
  return this;
}

代码示例来源:origin: strimzi/strimzi-kafka-operator

/**
 * Set the given permissions for authenticated users.
 */
public AclBuilder setAuthenticated(Permission... permissions) {
  if (auth == null) {
    auth = new ACL();
  }
  auth.setId(new Id("auth", null));
  auth.setPerms(Permission.encode(permissions));
  return this;
}

代码示例来源:origin: strimzi/strimzi-kafka-operator

/**
 * Set the given permissions for users connecting from the most
 * significant {@code bits} given IP {@code address}.
 */
public AclBuilder addIp(String address, int bits, Permission... permissions) {
  Map<String, ACL> ips = getIps();
  String cidr = address + "/" + bits;
  ACL a = ips.get(cidr);
  if (a == null) {
    a = new ACL();
    ips.put(cidr, a);
  }
  a.setId(new Id("ip", cidr));
  a.setPerms(Permission.encode(permissions));
  return this;
}

代码示例来源:origin: strimzi/strimzi-kafka-operator

/**
 * Set the given permissions for all users (including unauthenticated users).
 */
public AclBuilder setWorld(Permission... permissions) {
  if (world == null) {
    world = new ACL();
  }
  world.setId(new Id("world", "anyone"));
  world.setPerms(Permission.encode(permissions));
  return this;
}

相关文章