java类org.apache.zookeeper.Environment的实例源码

RegistrySecurity.java 文件源码 项目:hadoop 阅读 38 收藏 0 点赞 0 评论 0
/**
 * Resolve the context of an entry. This is an effective test of
 * JAAS setup, because it will relay detected problems up
 * @param context context name
 * @return the entry
 * @throws RuntimeException if there is no context entry found
 */
public static AppConfigurationEntry[] validateContext(String context)  {
  if (context == null) {
    throw new RuntimeException("Null context argument");
  }
  if (context.isEmpty()) {
    throw new RuntimeException("Empty context argument");
  }
  javax.security.auth.login.Configuration configuration =
      javax.security.auth.login.Configuration.getConfiguration();
  AppConfigurationEntry[] entries =
      configuration.getAppConfigurationEntry(context);
  if (entries == null) {
    throw new RuntimeException(
        String.format("Entry \"%s\" not found; " +
                      "JAAS config = %s",
            context,
            describeProperty(Environment.JAAS_CONF_KEY) ));
  }
  return entries;
}
TestSecureLogins.java 文件源码 项目:hadoop 阅读 39 收藏 0 点赞 0 评论 0
@Test
public void testClientLogin() throws Throwable {
  LoginContext client = login(ALICE_LOCALHOST,
                              ALICE_CLIENT_CONTEXT,
                              keytab_alice);

  try {
    logLoginDetails(ALICE_LOCALHOST, client);
    String confFilename = System.getProperty(Environment.JAAS_CONF_KEY);
    assertNotNull("Unset: "+ Environment.JAAS_CONF_KEY, confFilename);
    String config = FileUtils.readFileToString(new File(confFilename));
    LOG.info("{}=\n{}", confFilename, config);
    RegistrySecurity.setZKSaslClientProperties(ALICE, ALICE_CLIENT_CONTEXT);
  } finally {
    client.logout();
  }
}
RegistrySecurity.java 文件源码 项目:aliyun-oss-hadoop-fs 阅读 42 收藏 0 点赞 0 评论 0
/**
 * Resolve the context of an entry. This is an effective test of
 * JAAS setup, because it will relay detected problems up
 * @param context context name
 * @return the entry
 * @throws RuntimeException if there is no context entry found
 */
public static AppConfigurationEntry[] validateContext(String context)  {
  if (context == null) {
    throw new RuntimeException("Null context argument");
  }
  if (context.isEmpty()) {
    throw new RuntimeException("Empty context argument");
  }
  javax.security.auth.login.Configuration configuration =
      javax.security.auth.login.Configuration.getConfiguration();
  AppConfigurationEntry[] entries =
      configuration.getAppConfigurationEntry(context);
  if (entries == null) {
    throw new RuntimeException(
        String.format("Entry \"%s\" not found; " +
                      "JAAS config = %s",
            context,
            describeProperty(Environment.JAAS_CONF_KEY) ));
  }
  return entries;
}
TestSecureLogins.java 文件源码 项目:aliyun-oss-hadoop-fs 阅读 47 收藏 0 点赞 0 评论 0
@Test
public void testClientLogin() throws Throwable {
  LoginContext client = login(ALICE_LOCALHOST,
                              ALICE_CLIENT_CONTEXT,
                              keytab_alice);

  try {
    logLoginDetails(ALICE_LOCALHOST, client);
    String confFilename = System.getProperty(Environment.JAAS_CONF_KEY);
    assertNotNull("Unset: "+ Environment.JAAS_CONF_KEY, confFilename);
    String config = FileUtils.readFileToString(new File(confFilename));
    LOG.info("{}=\n{}", confFilename, config);
    RegistrySecurity.setZKSaslClientProperties(ALICE, ALICE_CLIENT_CONTEXT);
  } finally {
    client.logout();
  }
}
RegistrySecurity.java 文件源码 项目:big-c 阅读 44 收藏 0 点赞 0 评论 0
/**
 * Resolve the context of an entry. This is an effective test of
 * JAAS setup, because it will relay detected problems up
 * @param context context name
 * @return the entry
 * @throws RuntimeException if there is no context entry found
 */
public static AppConfigurationEntry[] validateContext(String context)  {
  if (context == null) {
    throw new RuntimeException("Null context argument");
  }
  if (context.isEmpty()) {
    throw new RuntimeException("Empty context argument");
  }
  javax.security.auth.login.Configuration configuration =
      javax.security.auth.login.Configuration.getConfiguration();
  AppConfigurationEntry[] entries =
      configuration.getAppConfigurationEntry(context);
  if (entries == null) {
    throw new RuntimeException(
        String.format("Entry \"%s\" not found; " +
                      "JAAS config = %s",
            context,
            describeProperty(Environment.JAAS_CONF_KEY) ));
  }
  return entries;
}
TestSecureLogins.java 文件源码 项目:big-c 阅读 34 收藏 0 点赞 0 评论 0
@Test
public void testClientLogin() throws Throwable {
  LoginContext client = login(ALICE_LOCALHOST,
                              ALICE_CLIENT_CONTEXT,
                              keytab_alice);

  try {
    logLoginDetails(ALICE_LOCALHOST, client);
    String confFilename = System.getProperty(Environment.JAAS_CONF_KEY);
    assertNotNull("Unset: "+ Environment.JAAS_CONF_KEY, confFilename);
    String config = FileUtils.readFileToString(new File(confFilename));
    LOG.info("{}=\n{}", confFilename, config);
    RegistrySecurity.setZKSaslClientProperties(ALICE, ALICE_CLIENT_CONTEXT);
  } finally {
    client.logout();
  }
}
RegistrySecurity.java 文件源码 项目:hadoop-2.6.0-cdh5.4.3 阅读 41 收藏 0 点赞 0 评论 0
/**
 * Resolve the context of an entry. This is an effective test of
 * JAAS setup, because it will relay detected problems up
 * @param context context name
 * @return the entry
 * @throws RuntimeException if there is no context entry found
 */
public static AppConfigurationEntry[] validateContext(String context)  {
  if (context == null) {
    throw new RuntimeException("Null context argument");
  }
  if (context.isEmpty()) {
    throw new RuntimeException("Empty context argument");
  }
  javax.security.auth.login.Configuration configuration =
      javax.security.auth.login.Configuration.getConfiguration();
  AppConfigurationEntry[] entries =
      configuration.getAppConfigurationEntry(context);
  if (entries == null) {
    throw new RuntimeException(
        String.format("Entry \"%s\" not found; " +
                      "JAAS config = %s",
            context,
            describeProperty(Environment.JAAS_CONF_KEY) ));
  }
  return entries;
}
TestSecureLogins.java 文件源码 项目:hadoop-2.6.0-cdh5.4.3 阅读 38 收藏 0 点赞 0 评论 0
@Test
public void testClientLogin() throws Throwable {
  LoginContext client = login(ALICE_LOCALHOST,
                              ALICE_CLIENT_CONTEXT,
                              keytab_alice);

  try {
    logLoginDetails(ALICE_LOCALHOST, client);
    String confFilename = System.getProperty(Environment.JAAS_CONF_KEY);
    assertNotNull("Unset: "+ Environment.JAAS_CONF_KEY, confFilename);
    String config = FileUtils.readFileToString(new File(confFilename));
    LOG.info("{}=\n{}", confFilename, config);
    RegistrySecurity.setZKSaslClientProperties(ALICE, ALICE_CLIENT_CONTEXT);
  } finally {
    client.logout();
  }
}
RegistrySecurity.java 文件源码 项目:hops 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Resolve the context of an entry. This is an effective test of
 * JAAS setup, because it will relay detected problems up
 * @param context context name
 * @return the entry
 * @throws RuntimeException if there is no context entry found
 */
public static AppConfigurationEntry[] validateContext(String context)  {
  if (context == null) {
    throw new RuntimeException("Null context argument");
  }
  if (context.isEmpty()) {
    throw new RuntimeException("Empty context argument");
  }
  javax.security.auth.login.Configuration configuration =
      javax.security.auth.login.Configuration.getConfiguration();
  AppConfigurationEntry[] entries =
      configuration.getAppConfigurationEntry(context);
  if (entries == null) {
    throw new RuntimeException(
        String.format("Entry \"%s\" not found; " +
                      "JAAS config = %s",
            context,
            describeProperty(Environment.JAAS_CONF_KEY) ));
  }
  return entries;
}
TestSecureLogins.java 文件源码 项目:hops 阅读 32 收藏 0 点赞 0 评论 0
@Test
public void testClientLogin() throws Throwable {
  LoginContext client = login(ALICE_LOCALHOST,
                              ALICE_CLIENT_CONTEXT,
                              keytab_alice);

  try {
    logLoginDetails(ALICE_LOCALHOST, client);
    String confFilename = System.getProperty(Environment.JAAS_CONF_KEY);
    assertNotNull("Unset: "+ Environment.JAAS_CONF_KEY, confFilename);
    String config = FileUtils.readFileToString(new File(confFilename));
    LOG.info("{}=\n{}", confFilename, config);
    RegistrySecurity.setZKSaslClientProperties(ALICE, ALICE_CLIENT_CONTEXT);
  } finally {
    client.logout();
  }
}
NettyServerCnxn.java 文件源码 项目:fuck_zookeeper 阅读 30 收藏 0 点赞 0 评论 0
@Override
public void commandRun() {
    List<Environment.Entry> env = Environment.list();

    pw.println("Environment:");
    for(Environment.Entry e : env) {
        pw.print(e.getKey());
        pw.print("=");
        pw.println(e.getValue());
    }

}
NIOServerCnxn.java 文件源码 项目:fuck_zookeeper 阅读 39 收藏 0 点赞 0 评论 0
@Override
public void commandRun() {
    List<Environment.Entry> env = Environment.list();

    pw.println("Environment:");
    for(Environment.Entry e : env) {
        pw.print(e.getKey());
        pw.print("=");
        pw.println(e.getValue());
    }

}
Commands.java 文件源码 项目:https-github.com-apache-zookeeper 阅读 40 收藏 0 点赞 0 评论 0
@Override
public CommandResponse run(ZooKeeperServer zkServer, Map<String, String> kwargs) {
    CommandResponse response = initializeResponse();
    for (Entry e : Environment.list()) {
        response.put(e.getKey(), e.getValue());
    }
    return response;
}
EnvCommand.java 文件源码 项目:https-github.com-apache-zookeeper 阅读 36 收藏 0 点赞 0 评论 0
@Override
public void commandRun() {
    List<Environment.Entry> env = Environment.list();

    pw.println("Environment:");
    for (Environment.Entry e : env) {
        pw.print(e.getKey());
        pw.print("=");
        pw.println(e.getValue());
    }
}
RegistrySecurity.java 文件源码 项目:hadoop 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Bind the JVM JAS setting to the specified JAAS file.
 *
 * <b>Important:</b> once a file has been loaded the JVM doesn't pick up
 * changes
 * @param jaasFile the JAAS file
 */
public static void bindJVMtoJAASFile(File jaasFile) {
  String path = jaasFile.getAbsolutePath();
  if (LOG.isDebugEnabled()) {
    LOG.debug("Binding {} to {}", Environment.JAAS_CONF_KEY, path);
  }
  System.setProperty(Environment.JAAS_CONF_KEY, path);
}
RegistrySecurity.java 文件源码 项目:hadoop 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Build up low-level security diagnostics to aid debugging
 * @return a string to use in diagnostics
 */
public String buildSecurityDiagnostics() {
  StringBuilder builder = new StringBuilder();
  builder.append(secureRegistry ? "secure registry; "
                        : "insecure registry; ");
  builder.append("Curator service access policy: ").append(access);

  builder.append("; System ACLs: ").append(aclsToString(systemACLs));
  builder.append("User: ").append(UgiInfo.fromCurrentUser());
  builder.append("; Kerberos Realm: ").append(kerberosRealm);
  builder.append(describeProperty(Environment.JAAS_CONF_KEY));
  String sasl =
      System.getProperty(PROP_ZK_ENABLE_SASL_CLIENT,
          DEFAULT_ZK_ENABLE_SASL_CLIENT);
  boolean saslEnabled = Boolean.valueOf(sasl);
  builder.append(describeProperty(PROP_ZK_ENABLE_SASL_CLIENT,
      DEFAULT_ZK_ENABLE_SASL_CLIENT));
  if (saslEnabled) {
    builder.append("; JAAS Client Identity")
           .append("=")
           .append(jaasClientIdentity)
           .append("; ");
    builder.append(KEY_REGISTRY_CLIENT_JAAS_CONTEXT)
           .append("=")
           .append(jaasClientContext)
           .append("; ");
    builder.append(describeProperty(PROP_ZK_SASL_CLIENT_USERNAME));
    builder.append(describeProperty(PROP_ZK_SASL_CLIENT_CONTEXT));
  }
  builder.append(describeProperty(PROP_ZK_ALLOW_FAILED_SASL_CLIENTS,
      "(undefined but defaults to true)"));
  builder.append(describeProperty(
      PROP_ZK_SERVER_MAINTAIN_CONNECTION_DESPITE_SASL_FAILURE));
  return builder.toString();
}
TestSecureLogins.java 文件源码 项目:hadoop 阅读 42 收藏 0 点赞 0 评论 0
@Test
public void testJaasFileSetup() throws Throwable {
  // the JVM has seemed inconsistent on setting up here
  assertNotNull("jaasFile", jaasFile);
  String confFilename = System.getProperty(Environment.JAAS_CONF_KEY);
  assertEquals(jaasFile.getAbsolutePath(), confFilename);
}
TestSecureLogins.java 文件源码 项目:hadoop 阅读 34 收藏 0 点赞 0 评论 0
@Test
public void testJaasFileBinding() throws Throwable {
  // the JVM has seemed inconsistent on setting up here
  assertNotNull("jaasFile", jaasFile);
  RegistrySecurity.bindJVMtoJAASFile(jaasFile);
  String confFilename = System.getProperty(Environment.JAAS_CONF_KEY);
  assertEquals(jaasFile.getAbsolutePath(), confFilename);
}
NettyServerCnxn.java 文件源码 项目:ZooKeeper 阅读 34 收藏 0 点赞 0 评论 0
@Override
public void commandRun() {
    List<Environment.Entry> env = Environment.list();

    pw.println("Environment:");
    for(Environment.Entry e : env) {
        pw.print(e.getKey());
        pw.print("=");
        pw.println(e.getValue());
    }

}
NIOServerCnxn.java 文件源码 项目:ZooKeeper 阅读 41 收藏 0 点赞 0 评论 0
@Override
public void commandRun() {
    List<Environment.Entry> env = Environment.list();

    pw.println("Environment:");
    for(Environment.Entry e : env) {
        pw.print(e.getKey());
        pw.print("=");
        pw.println(e.getValue());
    }

}
RegistrySecurity.java 文件源码 项目:aliyun-oss-hadoop-fs 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Bind the JVM JAS setting to the specified JAAS file.
 *
 * <b>Important:</b> once a file has been loaded the JVM doesn't pick up
 * changes
 * @param jaasFile the JAAS file
 */
public static void bindJVMtoJAASFile(File jaasFile) {
  String path = jaasFile.getAbsolutePath();
  if (LOG.isDebugEnabled()) {
    LOG.debug("Binding {} to {}", Environment.JAAS_CONF_KEY, path);
  }
  System.setProperty(Environment.JAAS_CONF_KEY, path);
}
RegistrySecurity.java 文件源码 项目:aliyun-oss-hadoop-fs 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Build up low-level security diagnostics to aid debugging
 * @return a string to use in diagnostics
 */
public String buildSecurityDiagnostics() {
  StringBuilder builder = new StringBuilder();
  builder.append(secureRegistry ? "secure registry; "
                        : "insecure registry; ");
  builder.append("Curator service access policy: ").append(access);

  builder.append("; System ACLs: ").append(aclsToString(systemACLs));
  builder.append("User: ").append(UgiInfo.fromCurrentUser());
  builder.append("; Kerberos Realm: ").append(kerberosRealm);
  builder.append(describeProperty(Environment.JAAS_CONF_KEY));
  String sasl =
      System.getProperty(PROP_ZK_ENABLE_SASL_CLIENT,
          DEFAULT_ZK_ENABLE_SASL_CLIENT);
  boolean saslEnabled = Boolean.valueOf(sasl);
  builder.append(describeProperty(PROP_ZK_ENABLE_SASL_CLIENT,
      DEFAULT_ZK_ENABLE_SASL_CLIENT));
  if (saslEnabled) {
    builder.append("; JAAS Client Identity")
           .append("=")
           .append(jaasClientIdentity)
           .append("; ");
    builder.append(KEY_REGISTRY_CLIENT_JAAS_CONTEXT)
           .append("=")
           .append(jaasClientContext)
           .append("; ");
    builder.append(describeProperty(PROP_ZK_SASL_CLIENT_USERNAME));
    builder.append(describeProperty(PROP_ZK_SASL_CLIENT_CONTEXT));
  }
  builder.append(describeProperty(PROP_ZK_ALLOW_FAILED_SASL_CLIENTS,
      "(undefined but defaults to true)"));
  builder.append(describeProperty(
      PROP_ZK_SERVER_MAINTAIN_CONNECTION_DESPITE_SASL_FAILURE));
  return builder.toString();
}
TestSecureLogins.java 文件源码 项目:aliyun-oss-hadoop-fs 阅读 32 收藏 0 点赞 0 评论 0
@Test
public void testJaasFileSetup() throws Throwable {
  // the JVM has seemed inconsistent on setting up here
  assertNotNull("jaasFile", jaasFile);
  String confFilename = System.getProperty(Environment.JAAS_CONF_KEY);
  assertEquals(jaasFile.getAbsolutePath(), confFilename);
}
TestSecureLogins.java 文件源码 项目:aliyun-oss-hadoop-fs 阅读 31 收藏 0 点赞 0 评论 0
@Test
public void testJaasFileBinding() throws Throwable {
  // the JVM has seemed inconsistent on setting up here
  assertNotNull("jaasFile", jaasFile);
  RegistrySecurity.bindJVMtoJAASFile(jaasFile);
  String confFilename = System.getProperty(Environment.JAAS_CONF_KEY);
  assertEquals(jaasFile.getAbsolutePath(), confFilename);
}
NettyServerCnxn.java 文件源码 项目:StreamProcessingInfrastructure 阅读 34 收藏 0 点赞 0 评论 0
@Override
public void commandRun() {
    List<Environment.Entry> env = Environment.list();

    pw.println("Environment:");
    for(Environment.Entry e : env) {
        pw.print(e.getKey());
        pw.print("=");
        pw.println(e.getValue());
    }

}
NIOServerCnxn.java 文件源码 项目:StreamProcessingInfrastructure 阅读 34 收藏 0 点赞 0 评论 0
@Override
public void commandRun() {
    List<Environment.Entry> env = Environment.list();

    pw.println("Environment:");
    for(Environment.Entry e : env) {
        pw.print(e.getKey());
        pw.print("=");
        pw.println(e.getValue());
    }

}
NettyServerCnxn.java 文件源码 项目:bigstreams 阅读 42 收藏 0 点赞 0 评论 0
@Override
public void commandRun() {
    List<Environment.Entry> env = Environment.list();

    pw.println("Environment:");
    for(Environment.Entry e : env) {
        pw.print(e.getKey());
        pw.print("=");
        pw.println(e.getValue());
    }

}
NIOServerCnxn.java 文件源码 项目:bigstreams 阅读 43 收藏 0 点赞 0 评论 0
@Override
public void commandRun() {
    List<Environment.Entry> env = Environment.list();

    pw.println("Environment:");
    for(Environment.Entry e : env) {
        pw.print(e.getKey());
        pw.print("=");
        pw.println(e.getValue());
    }

}
NettyServerCnxn.java 文件源码 项目:bigstreams 阅读 42 收藏 0 点赞 0 评论 0
@Override
public void commandRun() {
    List<Environment.Entry> env = Environment.list();

    pw.println("Environment:");
    for(Environment.Entry e : env) {
        pw.print(e.getKey());
        pw.print("=");
        pw.println(e.getValue());
    }

}
NIOServerCnxn.java 文件源码 项目:bigstreams 阅读 44 收藏 0 点赞 0 评论 0
@Override
public void commandRun() {
    List<Environment.Entry> env = Environment.list();

    pw.println("Environment:");
    for(Environment.Entry e : env) {
        pw.print(e.getKey());
        pw.print("=");
        pw.println(e.getValue());
    }

}


问题


面经


文章

微信
公众号

扫码关注公众号