Java 类org.apache.hadoop.security.TestUserGroupInformation 实例源码

项目:hadoop    文件:TestSaslRPC.java   
static void testKerberosRpc(String principal, String keytab) throws Exception {
  final Configuration newConf = new Configuration(conf);
  newConf.set(SERVER_PRINCIPAL_KEY, principal);
  newConf.set(SERVER_KEYTAB_KEY, keytab);
  SecurityUtil.login(newConf, SERVER_KEYTAB_KEY, SERVER_PRINCIPAL_KEY);
  TestUserGroupInformation.verifyLoginMetrics(1, 0);
  UserGroupInformation current = UserGroupInformation.getCurrentUser();
  System.out.println("UGI: " + current);

  Server server = new RPC.Builder(newConf)
      .setProtocol(TestSaslProtocol.class).setInstance(new TestSaslImpl())
      .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
      .build();
  TestSaslProtocol proxy = null;

  server.start();

  InetSocketAddress addr = NetUtils.getConnectAddress(server);
  try {
    proxy = RPC.getProxy(TestSaslProtocol.class,
        TestSaslProtocol.versionID, addr, newConf);
    proxy.ping();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
  System.out.println("Test is successful.");
}
项目:aliyun-oss-hadoop-fs    文件:TestSaslRPC.java   
static void testKerberosRpc(String principal, String keytab) throws Exception {
  final Configuration newConf = new Configuration(conf);
  newConf.set(SERVER_PRINCIPAL_KEY, principal);
  newConf.set(SERVER_KEYTAB_KEY, keytab);
  SecurityUtil.login(newConf, SERVER_KEYTAB_KEY, SERVER_PRINCIPAL_KEY);
  TestUserGroupInformation.verifyLoginMetrics(1, 0);
  UserGroupInformation current = UserGroupInformation.getCurrentUser();
  System.out.println("UGI: " + current);

  Server server = new RPC.Builder(newConf)
      .setProtocol(TestSaslProtocol.class).setInstance(new TestSaslImpl())
      .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
      .build();
  TestSaslProtocol proxy = null;

  server.start();

  InetSocketAddress addr = NetUtils.getConnectAddress(server);
  try {
    proxy = RPC.getProxy(TestSaslProtocol.class,
        TestSaslProtocol.versionID, addr, newConf);
    proxy.ping();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
  System.out.println("Test is successful.");
}
项目:big-c    文件:TestSaslRPC.java   
static void testKerberosRpc(String principal, String keytab) throws Exception {
  final Configuration newConf = new Configuration(conf);
  newConf.set(SERVER_PRINCIPAL_KEY, principal);
  newConf.set(SERVER_KEYTAB_KEY, keytab);
  SecurityUtil.login(newConf, SERVER_KEYTAB_KEY, SERVER_PRINCIPAL_KEY);
  TestUserGroupInformation.verifyLoginMetrics(1, 0);
  UserGroupInformation current = UserGroupInformation.getCurrentUser();
  System.out.println("UGI: " + current);

  Server server = new RPC.Builder(newConf)
      .setProtocol(TestSaslProtocol.class).setInstance(new TestSaslImpl())
      .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
      .build();
  TestSaslProtocol proxy = null;

  server.start();

  InetSocketAddress addr = NetUtils.getConnectAddress(server);
  try {
    proxy = RPC.getProxy(TestSaslProtocol.class,
        TestSaslProtocol.versionID, addr, newConf);
    proxy.ping();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
  System.out.println("Test is successful.");
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestSaslRPC.java   
static void testKerberosRpc(String principal, String keytab) throws Exception {
  final Configuration newConf = new Configuration(conf);
  newConf.set(SERVER_PRINCIPAL_KEY, principal);
  newConf.set(SERVER_KEYTAB_KEY, keytab);
  SecurityUtil.login(newConf, SERVER_KEYTAB_KEY, SERVER_PRINCIPAL_KEY);
  TestUserGroupInformation.verifyLoginMetrics(1, 0);
  UserGroupInformation current = UserGroupInformation.getCurrentUser();
  System.out.println("UGI: " + current);

  Server server = new RPC.Builder(newConf)
      .setProtocol(TestSaslProtocol.class).setInstance(new TestSaslImpl())
      .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
      .build();
  TestSaslProtocol proxy = null;

  server.start();

  InetSocketAddress addr = NetUtils.getConnectAddress(server);
  try {
    proxy = RPC.getProxy(TestSaslProtocol.class,
        TestSaslProtocol.versionID, addr, newConf);
    proxy.ping();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
  System.out.println("Test is successful.");
}
项目:hadoop-plus    文件:TestSaslRPC.java   
static void testKerberosRpc(String principal, String keytab) throws Exception {
  final Configuration newConf = new Configuration(conf);
  newConf.set(SERVER_PRINCIPAL_KEY, principal);
  newConf.set(SERVER_KEYTAB_KEY, keytab);
  SecurityUtil.login(newConf, SERVER_KEYTAB_KEY, SERVER_PRINCIPAL_KEY);
  TestUserGroupInformation.verifyLoginMetrics(1, 0);
  UserGroupInformation current = UserGroupInformation.getCurrentUser();
  System.out.println("UGI: " + current);

  Server server = new RPC.Builder(newConf)
      .setProtocol(TestSaslProtocol.class).setInstance(new TestSaslImpl())
      .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
      .build();
  TestSaslProtocol proxy = null;

  server.start();

  InetSocketAddress addr = NetUtils.getConnectAddress(server);
  try {
    proxy = RPC.getProxy(TestSaslProtocol.class,
        TestSaslProtocol.versionID, addr, newConf);
    proxy.ping();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
  System.out.println("Test is successful.");
}
项目:hadoop-TCP    文件:TestSaslRPC.java   
static void testKerberosRpc(String principal, String keytab) throws Exception {
  final Configuration newConf = new Configuration(conf);
  newConf.set(SERVER_PRINCIPAL_KEY, principal);
  newConf.set(SERVER_KEYTAB_KEY, keytab);
  SecurityUtil.login(newConf, SERVER_KEYTAB_KEY, SERVER_PRINCIPAL_KEY);
  TestUserGroupInformation.verifyLoginMetrics(1, 0);
  UserGroupInformation current = UserGroupInformation.getCurrentUser();
  System.out.println("UGI: " + current);

  Server server = new RPC.Builder(newConf)
      .setProtocol(TestSaslProtocol.class).setInstance(new TestSaslImpl())
      .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
      .build();
  TestSaslProtocol proxy = null;

  server.start();

  InetSocketAddress addr = NetUtils.getConnectAddress(server);
  try {
    proxy = RPC.getProxy(TestSaslProtocol.class,
        TestSaslProtocol.versionID, addr, newConf);
    proxy.ping();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
  System.out.println("Test is successful.");
}
项目:hadoop-on-lustre    文件:TestSaslRPC.java   
static void testKerberosRpc(String principal, String keytab) throws Exception {
  final Configuration newConf = new Configuration(conf);
  newConf.set(SERVER_PRINCIPAL_KEY, principal);
  newConf.set(SERVER_KEYTAB_KEY, keytab);
  SecurityUtil.login(newConf, SERVER_KEYTAB_KEY, SERVER_PRINCIPAL_KEY);
  TestUserGroupInformation.verifyLoginMetrics(1, 0);
  UserGroupInformation current = UserGroupInformation.getCurrentUser();
  System.out.println("UGI: " + current);

  Server server = RPC.getServer(new TestSaslImpl(),
      ADDRESS, 0, 5, true, newConf, null);
  TestSaslProtocol proxy = null;

  server.start();

  InetSocketAddress addr = NetUtils.getConnectAddress(server);
  try {
    proxy = (TestSaslProtocol) RPC.getProxy(TestSaslProtocol.class,
        TestSaslProtocol.versionID, addr, newConf);
    proxy.ping();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
  System.out.println("Test is successful.");
}
项目:hardfs    文件:TestSaslRPC.java   
static void testKerberosRpc(String principal, String keytab) throws Exception {
  final Configuration newConf = new Configuration(conf);
  newConf.set(SERVER_PRINCIPAL_KEY, principal);
  newConf.set(SERVER_KEYTAB_KEY, keytab);
  SecurityUtil.login(newConf, SERVER_KEYTAB_KEY, SERVER_PRINCIPAL_KEY);
  TestUserGroupInformation.verifyLoginMetrics(1, 0);
  UserGroupInformation current = UserGroupInformation.getCurrentUser();
  System.out.println("UGI: " + current);

  Server server = new RPC.Builder(newConf)
      .setProtocol(TestSaslProtocol.class).setInstance(new TestSaslImpl())
      .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
      .build();
  TestSaslProtocol proxy = null;

  server.start();

  InetSocketAddress addr = NetUtils.getConnectAddress(server);
  try {
    proxy = RPC.getProxy(TestSaslProtocol.class,
        TestSaslProtocol.versionID, addr, newConf);
    proxy.ping();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
  System.out.println("Test is successful.");
}
项目:hadoop-on-lustre2    文件:TestSaslRPC.java   
static void testKerberosRpc(String principal, String keytab) throws Exception {
  final Configuration newConf = new Configuration(conf);
  newConf.set(SERVER_PRINCIPAL_KEY, principal);
  newConf.set(SERVER_KEYTAB_KEY, keytab);
  SecurityUtil.login(newConf, SERVER_KEYTAB_KEY, SERVER_PRINCIPAL_KEY);
  TestUserGroupInformation.verifyLoginMetrics(1, 0);
  UserGroupInformation current = UserGroupInformation.getCurrentUser();
  System.out.println("UGI: " + current);

  Server server = new RPC.Builder(newConf)
      .setProtocol(TestSaslProtocol.class).setInstance(new TestSaslImpl())
      .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
      .build();
  TestSaslProtocol proxy = null;

  server.start();

  InetSocketAddress addr = NetUtils.getConnectAddress(server);
  try {
    proxy = RPC.getProxy(TestSaslProtocol.class,
        TestSaslProtocol.versionID, addr, newConf);
    proxy.ping();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
  System.out.println("Test is successful.");
}
项目:hortonworks-extension    文件:TestSaslRPC.java   
static void testKerberosRpc(String principal, String keytab) throws Exception {
  final Configuration newConf = new Configuration(conf);
  newConf.set(SERVER_PRINCIPAL_KEY, principal);
  newConf.set(SERVER_KEYTAB_KEY, keytab);
  SecurityUtil.login(newConf, SERVER_KEYTAB_KEY, SERVER_PRINCIPAL_KEY);
  TestUserGroupInformation.verifyLoginMetrics(1, 0);
  UserGroupInformation current = UserGroupInformation.getCurrentUser();
  System.out.println("UGI: " + current);

  Server server = RPC.getServer(new TestSaslImpl(),
      ADDRESS, 0, 5, true, newConf, null);
  TestSaslProtocol proxy = null;

  server.start();

  InetSocketAddress addr = NetUtils.getConnectAddress(server);
  try {
    proxy = (TestSaslProtocol) RPC.getProxy(TestSaslProtocol.class,
        TestSaslProtocol.versionID, addr, newConf);
    proxy.ping();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
  System.out.println("Test is successful.");
}
项目:hortonworks-extension    文件:TestSaslRPC.java   
static void testKerberosRpc(String principal, String keytab) throws Exception {
  final Configuration newConf = new Configuration(conf);
  newConf.set(SERVER_PRINCIPAL_KEY, principal);
  newConf.set(SERVER_KEYTAB_KEY, keytab);
  SecurityUtil.login(newConf, SERVER_KEYTAB_KEY, SERVER_PRINCIPAL_KEY);
  TestUserGroupInformation.verifyLoginMetrics(1, 0);
  UserGroupInformation current = UserGroupInformation.getCurrentUser();
  System.out.println("UGI: " + current);

  Server server = RPC.getServer(new TestSaslImpl(),
      ADDRESS, 0, 5, true, newConf, null);
  TestSaslProtocol proxy = null;

  server.start();

  InetSocketAddress addr = NetUtils.getConnectAddress(server);
  try {
    proxy = (TestSaslProtocol) RPC.getProxy(TestSaslProtocol.class,
        TestSaslProtocol.versionID, addr, newConf);
    proxy.ping();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
  System.out.println("Test is successful.");
}