org.apache.hadoop.hbase.zookeeper.ZKUtil.isSecureZooKeeper()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(125)

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

ZKUtil.isSecureZooKeeper介绍

[英]Returns whether or not secure authentication is enabled (whether hbase.security.authentication is set to kerberos.
[中]返回是否启用了安全身份验证(是否将hbase.security.authentication设置为kerberos

代码示例

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

  1. private static ArrayList<ACL> createACL(ZKWatcher zkw, String node) {
  2. return createACL(zkw, node, isSecureZooKeeper(zkw.getConfiguration()));
  3. }

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

  1. String loginContextProperty, String loginContextName)
  2. throws IOException {
  3. if (!isSecureZooKeeper(conf)) {
  4. return;

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

  1. /**
  2. * On master start, we check the znode ACLs under the root directory and set the ACLs properly
  3. * if needed. If the cluster goes from an unsecure setup to a secure setup, this step is needed
  4. * so that the existing znodes created with open permissions are now changed with restrictive
  5. * perms.
  6. */
  7. public void checkAndSetZNodeAcls() {
  8. if (!ZKUtil.isSecureZooKeeper(getConfiguration())) {
  9. LOG.info("not a secure deployment, proceeding");
  10. return;
  11. }
  12. // Check the base znodes permission first. Only do the recursion if base znode's perms are not
  13. // correct.
  14. try {
  15. List<ACL> actualAcls = recoverableZooKeeper.getAcl(znodePaths.baseZNode, new Stat());
  16. if (!isBaseZnodeAclSetup(actualAcls)) {
  17. LOG.info("setting znode ACLs");
  18. setZnodeAclsRecursive(znodePaths.baseZNode);
  19. }
  20. } catch(KeeperException.NoNodeException nne) {
  21. return;
  22. } catch(InterruptedException ie) {
  23. interruptedExceptionNoThrow(ie, false);
  24. } catch (IOException|KeeperException e) {
  25. LOG.warn("Received exception while checking and setting zookeeper ACLs", e);
  26. }
  27. }

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

  1. /**
  2. * Check if ZooKeeper JaasConfiguration is valid.
  3. */
  4. @Test
  5. public void testIsZooKeeperSecure() throws Exception {
  6. boolean testJaasConfig =
  7. ZKUtil.isSecureZooKeeper(new Configuration(TEST_UTIL.getConfiguration()));
  8. assertEquals(testJaasConfig, secureZKAvailable);
  9. // Define Jaas configuration without ZooKeeper Jaas config
  10. File saslConfFile = File.createTempFile("tmp", "fakeJaas.conf");
  11. FileWriter fwriter = new FileWriter(saslConfFile);
  12. fwriter.write("");
  13. fwriter.close();
  14. System.setProperty("java.security.auth.login.config",
  15. saslConfFile.getAbsolutePath());
  16. testJaasConfig = ZKUtil.isSecureZooKeeper(new Configuration(TEST_UTIL.getConfiguration()));
  17. assertFalse(testJaasConfig);
  18. saslConfFile.delete();
  19. }

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

  1. /**
  2. * Check if Programmatic way of setting zookeeper security settings is valid.
  3. */
  4. @Test
  5. public void testIsZooKeeperSecureWithProgrammaticConfig() throws Exception {
  6. javax.security.auth.login.Configuration.setConfiguration(new DummySecurityConfiguration());
  7. Configuration config = new Configuration(HBaseConfiguration.create());
  8. boolean testJaasConfig = ZKUtil.isSecureZooKeeper(config);
  9. assertFalse(testJaasConfig);
  10. // Now set authentication scheme to Kerberos still it should return false
  11. // because no configuration set
  12. config.set("hbase.security.authentication", "kerberos");
  13. testJaasConfig = ZKUtil.isSecureZooKeeper(config);
  14. assertFalse(testJaasConfig);
  15. // Now set programmatic options related to security
  16. config.set(HConstants.ZK_CLIENT_KEYTAB_FILE, "/dummy/file");
  17. config.set(HConstants.ZK_CLIENT_KERBEROS_PRINCIPAL, "dummy");
  18. config.set(HConstants.ZK_SERVER_KEYTAB_FILE, "/dummy/file");
  19. config.set(HConstants.ZK_SERVER_KERBEROS_PRINCIPAL, "dummy");
  20. testJaasConfig = ZKUtil.isSecureZooKeeper(config);
  21. assertTrue(testJaasConfig);
  22. }

代码示例来源:origin: co.cask.hbase/hbase

  1. private static ArrayList<ACL> createACL(ZooKeeperWatcher zkw, String node) {
  2. if (isSecureZooKeeper(zkw.getConfiguration())) {
  3. // Certain znodes are accessed directly by the client,
  4. // so they must be readable by non-authenticated clients
  5. if ((node.equals(zkw.baseZNode) == true) ||
  6. (node.equals(zkw.rootServerZNode) == true) ||
  7. (node.equals(zkw.masterAddressZNode) == true) ||
  8. (node.equals(zkw.clusterIdZNode) == true) ||
  9. (node.equals(zkw.rsZNode) == true) ||
  10. (node.equals(zkw.backupMasterAddressesZNode) == true) ||
  11. (node.startsWith(zkw.masterTableZNode) == true) ||
  12. (node.startsWith(zkw.masterTableZNode92) == true)) {
  13. return ZooKeeperWatcher.CREATOR_ALL_AND_WORLD_READABLE;
  14. }
  15. return Ids.CREATOR_ALL_ACL;
  16. } else {
  17. return Ids.OPEN_ACL_UNSAFE;
  18. }
  19. }

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

  1. private static ArrayList<ACL> createACL(ZKWatcher zkw, String node) {
  2. return createACL(zkw, node, isSecureZooKeeper(zkw.getConfiguration()));
  3. }

代码示例来源:origin: harbby/presto-connectors

  1. private static ArrayList<ACL> createACL(ZooKeeperWatcher zkw, String node) {
  2. return createACL(zkw, node, isSecureZooKeeper(zkw.getConfiguration()));
  3. }

代码示例来源:origin: co.cask.hbase/hbase

  1. String loginContextProperty, String loginContextName)
  2. throws IOException {
  3. if (!isSecureZooKeeper(conf))
  4. return;

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

  1. String loginContextProperty, String loginContextName)
  2. throws IOException {
  3. if (!isSecureZooKeeper(conf)) {
  4. return;

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

  1. /**
  2. * On master start, we check the znode ACLs under the root directory and set the ACLs properly
  3. * if needed. If the cluster goes from an unsecure setup to a secure setup, this step is needed
  4. * so that the existing znodes created with open permissions are now changed with restrictive
  5. * perms.
  6. */
  7. public void checkAndSetZNodeAcls() {
  8. if (!ZKUtil.isSecureZooKeeper(getConfiguration())) {
  9. LOG.info("not a secure deployment, proceeding");
  10. return;
  11. }
  12. // Check the base znodes permission first. Only do the recursion if base znode's perms are not
  13. // correct.
  14. try {
  15. List<ACL> actualAcls = recoverableZooKeeper.getAcl(znodePaths.baseZNode, new Stat());
  16. if (!isBaseZnodeAclSetup(actualAcls)) {
  17. LOG.info("setting znode ACLs");
  18. setZnodeAclsRecursive(znodePaths.baseZNode);
  19. }
  20. } catch(KeeperException.NoNodeException nne) {
  21. return;
  22. } catch(InterruptedException ie) {
  23. interruptedExceptionNoThrow(ie, false);
  24. } catch (IOException|KeeperException e) {
  25. LOG.warn("Received exception while checking and setting zookeeper ACLs", e);
  26. }
  27. }

代码示例来源:origin: harbby/presto-connectors

  1. String loginContextProperty, String loginContextName)
  2. throws IOException {
  3. if (!isSecureZooKeeper(conf))
  4. return;

代码示例来源:origin: org.apache.hbase/hbase-server

  1. /**
  2. * Check if ZooKeeper JaasConfiguration is valid.
  3. */
  4. @Test
  5. public void testIsZooKeeperSecure() throws Exception {
  6. boolean testJaasConfig =
  7. ZKUtil.isSecureZooKeeper(new Configuration(TEST_UTIL.getConfiguration()));
  8. assertEquals(testJaasConfig, secureZKAvailable);
  9. // Define Jaas configuration without ZooKeeper Jaas config
  10. File saslConfFile = File.createTempFile("tmp", "fakeJaas.conf");
  11. FileWriter fwriter = new FileWriter(saslConfFile);
  12. fwriter.write("");
  13. fwriter.close();
  14. System.setProperty("java.security.auth.login.config",
  15. saslConfFile.getAbsolutePath());
  16. testJaasConfig = ZKUtil.isSecureZooKeeper(new Configuration(TEST_UTIL.getConfiguration()));
  17. assertFalse(testJaasConfig);
  18. saslConfFile.delete();
  19. }

代码示例来源:origin: org.apache.hbase/hbase-server

  1. /**
  2. * Check if Programmatic way of setting zookeeper security settings is valid.
  3. */
  4. @Test
  5. public void testIsZooKeeperSecureWithProgrammaticConfig() throws Exception {
  6. javax.security.auth.login.Configuration.setConfiguration(new DummySecurityConfiguration());
  7. Configuration config = new Configuration(HBaseConfiguration.create());
  8. boolean testJaasConfig = ZKUtil.isSecureZooKeeper(config);
  9. assertFalse(testJaasConfig);
  10. // Now set authentication scheme to Kerberos still it should return false
  11. // because no configuration set
  12. config.set("hbase.security.authentication", "kerberos");
  13. testJaasConfig = ZKUtil.isSecureZooKeeper(config);
  14. assertFalse(testJaasConfig);
  15. // Now set programmatic options related to security
  16. config.set(HConstants.ZK_CLIENT_KEYTAB_FILE, "/dummy/file");
  17. config.set(HConstants.ZK_CLIENT_KERBEROS_PRINCIPAL, "dummy");
  18. config.set(HConstants.ZK_SERVER_KEYTAB_FILE, "/dummy/file");
  19. config.set(HConstants.ZK_SERVER_KERBEROS_PRINCIPAL, "dummy");
  20. testJaasConfig = ZKUtil.isSecureZooKeeper(config);
  21. assertTrue(testJaasConfig);
  22. }

代码示例来源:origin: harbby/presto-connectors

  1. /**
  2. * On master start, we check the znode ACLs under the root directory and set the ACLs properly
  3. * if needed. If the cluster goes from an unsecure setup to a secure setup, this step is needed
  4. * so that the existing znodes created with open permissions are now changed with restrictive
  5. * perms.
  6. */
  7. public void checkAndSetZNodeAcls() {
  8. if (!ZKUtil.isSecureZooKeeper(getConfiguration())) {
  9. LOG.info("not a secure deployment, proceeding");
  10. return;
  11. }
  12. // Check the base znodes permission first. Only do the recursion if base znode's perms are not
  13. // correct.
  14. try {
  15. List<ACL> actualAcls = recoverableZooKeeper.getAcl(baseZNode, new Stat());
  16. if (!isBaseZnodeAclSetup(actualAcls)) {
  17. LOG.info("setting znode ACLs");
  18. setZnodeAclsRecursive(baseZNode);
  19. }
  20. } catch(KeeperException.NoNodeException nne) {
  21. return;
  22. } catch(InterruptedException ie) {
  23. interruptedException(ie);
  24. } catch (IOException|KeeperException e) {
  25. LOG.warn("Received exception while checking and setting zookeeper ACLs", e);
  26. }
  27. }

相关文章