Java 类org.apache.zookeeper.Environment 实例源码

项目:hadoop    文件:RegistrySecurity.java   
/**
 * 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;
}
项目:hadoop    文件:TestSecureLogins.java   
@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();
  }
}
项目:aliyun-oss-hadoop-fs    文件:RegistrySecurity.java   
/**
 * 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;
}
项目:aliyun-oss-hadoop-fs    文件:TestSecureLogins.java   
@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();
  }
}
项目:big-c    文件:RegistrySecurity.java   
/**
 * 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;
}
项目:big-c    文件:TestSecureLogins.java   
@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();
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:RegistrySecurity.java   
/**
 * 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;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestSecureLogins.java   
@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();
  }
}
项目:hops    文件:RegistrySecurity.java   
/**
 * 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;
}
项目:hops    文件:TestSecureLogins.java   
@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();
  }
}
项目:fuck_zookeeper    文件:NettyServerCnxn.java   
@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());
    }

}
项目:fuck_zookeeper    文件:NIOServerCnxn.java   
@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());
    }

}
项目:https-github.com-apache-zookeeper    文件:Commands.java   
@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;
}
项目:https-github.com-apache-zookeeper    文件:EnvCommand.java   
@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());
    }
}
项目:hadoop    文件:RegistrySecurity.java   
/**
 * 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);
}
项目:hadoop    文件:RegistrySecurity.java   
/**
 * 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();
}
项目:hadoop    文件:TestSecureLogins.java   
@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);
}
项目:hadoop    文件:TestSecureLogins.java   
@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);
}
项目:ZooKeeper    文件:NettyServerCnxn.java   
@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());
    }

}
项目:ZooKeeper    文件:NIOServerCnxn.java   
@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());
    }

}
项目:aliyun-oss-hadoop-fs    文件:RegistrySecurity.java   
/**
 * 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);
}
项目:aliyun-oss-hadoop-fs    文件:RegistrySecurity.java   
/**
 * 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();
}
项目:aliyun-oss-hadoop-fs    文件:TestSecureLogins.java   
@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);
}
项目:aliyun-oss-hadoop-fs    文件:TestSecureLogins.java   
@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);
}
项目:StreamProcessingInfrastructure    文件:NettyServerCnxn.java   
@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());
    }

}
项目:StreamProcessingInfrastructure    文件:NIOServerCnxn.java   
@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());
    }

}
项目:bigstreams    文件:NettyServerCnxn.java   
@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());
    }

}
项目:bigstreams    文件:NIOServerCnxn.java   
@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());
    }

}
项目:bigstreams    文件:NettyServerCnxn.java   
@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());
    }

}
项目:bigstreams    文件:NIOServerCnxn.java   
@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());
    }

}
项目:zookeeper-src-learning    文件:NettyServerCnxn.java   
@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());
    }

}
项目:zookeeper-src-learning    文件:NIOServerCnxn.java   
@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());
    }

}
项目:big-c    文件:RegistrySecurity.java   
/**
 * 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);
}
项目:big-c    文件:RegistrySecurity.java   
/**
 * 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();
}
项目:big-c    文件:TestSecureLogins.java   
@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);
}
项目:big-c    文件:TestSecureLogins.java   
@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);
}
项目:zookeeper    文件:NettyServerCnxn.java   
@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());
    }

}
项目:zookeeper    文件:NIOServerCnxn.java   
@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());
    }

}
项目:SecureKeeper    文件:Commands.java   
@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;
}
项目:SecureKeeper    文件:EnvCommand.java   
@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());
    }
}