org.apache.zookeeper.server.auth.DigestAuthenticationProvider.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(177)

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

DigestAuthenticationProvider.<init>介绍

暂无

代码示例

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

public static void initialize() {
  synchronized (ProviderRegistry.class) {
    if (initialized)
      return;
    IPAuthenticationProvider ipp = new IPAuthenticationProvider();
    DigestAuthenticationProvider digp = new DigestAuthenticationProvider();
    authenticationProviders.put(ipp.getScheme(), ipp);
    authenticationProviders.put(digp.getScheme(), digp);
    Enumeration<Object> en = System.getProperties().keys();
    while (en.hasMoreElements()) {
      String k = (String) en.nextElement();
      if (k.startsWith("zookeeper.authProvider.")) {
        String className = System.getProperty(k);
        try {
          Class<?> c = ZooKeeperServer.class.getClassLoader()
              .loadClass(className);
          AuthenticationProvider ap = (AuthenticationProvider) c.getDeclaredConstructor()
              .newInstance();
          authenticationProviders.put(ap.getScheme(), ap);
        } catch (Exception e) {
          LOG.warn("Problems loading " + className,e);
        }
      }
    }
    initialized = true;
  }
}

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

public static void initialize() {
  synchronized (ProviderRegistry.class) {
    if (initialized)
      return;
    IPAuthenticationProvider ipp = new IPAuthenticationProvider();
    DigestAuthenticationProvider digp = new DigestAuthenticationProvider();
    authenticationProviders.put(ipp.getScheme(), ipp);
    authenticationProviders.put(digp.getScheme(), digp);
    Enumeration<Object> en = System.getProperties().keys();
    while (en.hasMoreElements()) {
      String k = (String) en.nextElement();
      if (k.startsWith("zookeeper.authProvider.")) {
        String className = System.getProperty(k);
        try {
          Class<?> c = ZooKeeperServer.class.getClassLoader()
              .loadClass(className);
          AuthenticationProvider ap = (AuthenticationProvider) c
              .getDeclaredConstructor().newInstance();
          authenticationProviders.put(ap.getScheme(), ap);
        } catch (Exception e) {
          LOG.warn("Problems loading " + className,e);
        }
      }
    }
    initialized = true;
  }
}

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

public static void initialize() {
  synchronized (ProviderRegistry.class) {
    if (initialized)
      return;
    IPAuthenticationProvider ipp = new IPAuthenticationProvider();
    DigestAuthenticationProvider digp = new DigestAuthenticationProvider();
    authenticationProviders.put(ipp.getScheme(), ipp);
    authenticationProviders.put(digp.getScheme(), digp);
    Enumeration<Object> en = System.getProperties().keys();
    while (en.hasMoreElements()) {
      String k = (String) en.nextElement();
      if (k.startsWith("zookeeper.authProvider.")) {
        String className = System.getProperty(k);
        try {
          Class<?> c = ZooKeeperServer.class.getClassLoader()
              .loadClass(className);
          AuthenticationProvider ap = (AuthenticationProvider) c
              .newInstance();
          authenticationProviders.put(ap.getScheme(), ap);
        } catch (Exception e) {
          LOG.warn("Problems loading " + className,e);
        }
      }
    }
    initialized = true;
  }
}

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

/**
 * Get ZooKeeper Curator manager, creating and starting if not exists.
 * @param config Configuration for the ZooKeeper curator.
 * @return ZooKeeper Curator manager.
 * @throws IOException If it cannot create the manager.
 */
public ZKCuratorManager createAndStartZKManager(Configuration
  config) throws IOException {
 ZKCuratorManager manager = new ZKCuratorManager(config);
 // Get authentication
 List<AuthInfo> authInfos = new ArrayList<>();
 if (HAUtil.isHAEnabled(config) && HAUtil.getConfValueForRMInstance(
   YarnConfiguration.ZK_RM_STATE_STORE_ROOT_NODE_ACL, config) == null) {
  String zkRootNodeUsername = HAUtil.getConfValueForRMInstance(
    YarnConfiguration.RM_ADDRESS,
    YarnConfiguration.DEFAULT_RM_ADDRESS, config);
  String defaultFencingAuth =
    zkRootNodeUsername + ":" + zkRootNodePassword;
  byte[] defaultFencingAuthData =
    defaultFencingAuth.getBytes(Charset.forName("UTF-8"));
  String scheme = new DigestAuthenticationProvider().getScheme();
  AuthInfo authInfo = new AuthInfo(scheme, defaultFencingAuthData);
  authInfos.add(authInfo);
 }
 manager.start(authInfos);
 return manager;
}

相关文章