当前位置: 首页>>代码示例>>Java>>正文


Java DefaultImpersonationProvider类代码示例

本文整理汇总了Java中org.apache.hadoop.security.authorize.DefaultImpersonationProvider的典型用法代码示例。如果您正苦于以下问题:Java DefaultImpersonationProvider类的具体用法?Java DefaultImpersonationProvider怎么用?Java DefaultImpersonationProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DefaultImpersonationProvider类属于org.apache.hadoop.security.authorize包,在下文中一共展示了DefaultImpersonationProvider类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureSuperUserIPAddresses

import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; //导入依赖的package包/类
private void configureSuperUserIPAddresses(Configuration conf,
    String superUserShortName) throws IOException {
  ArrayList<String> ipList = new ArrayList<String>();
  Enumeration<NetworkInterface> netInterfaceList = NetworkInterface
      .getNetworkInterfaces();
  while (netInterfaceList.hasMoreElements()) {
    NetworkInterface inf = netInterfaceList.nextElement();
    Enumeration<InetAddress> addrList = inf.getInetAddresses();
    while (addrList.hasMoreElements()) {
      InetAddress addr = addrList.nextElement();
      ipList.add(addr.getHostAddress());
    }
  }
  StringBuilder builder = new StringBuilder();
  for (String ip : ipList) {
    builder.append(ip);
    builder.append(',');
  }
  builder.append("127.0.1.1,");
  builder.append(InetAddress.getLocalHost().getCanonicalHostName());
  LOG.info("Local Ip addresses: "+builder.toString());
  conf.setStrings(DefaultImpersonationProvider.getTestProvider().
          getProxySuperuserIpConfKey(superUserShortName),
      builder.toString());
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:26,代码来源:TestDoAsEffectiveUser.java

示例2: configureSuperUserIPAddresses

import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; //导入依赖的package包/类
private void configureSuperUserIPAddresses(Configuration conf,
    String superUserShortName) throws IOException {
  ArrayList<String> ipList = new ArrayList<String>();
  Enumeration<NetworkInterface> netInterfaceList = NetworkInterface
      .getNetworkInterfaces();
  while (netInterfaceList.hasMoreElements()) {
    NetworkInterface inf = netInterfaceList.nextElement();
    Enumeration<InetAddress> addrList = inf.getInetAddresses();
    while (addrList.hasMoreElements()) {
      InetAddress addr = addrList.nextElement();
      ipList.add(addr.getHostAddress());
    }
  }
  StringBuilder builder = new StringBuilder();
  for (String ip : ipList) {
    builder.append(ip);
    builder.append(',');
  }
  builder.append("127.0.1.1,");
  builder.append(InetAddress.getLocalHost().getCanonicalHostName());
  conf.setStrings(DefaultImpersonationProvider.getTestProvider().
          getProxySuperuserIpConfKey(superUserShortName), builder.toString());
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:24,代码来源:MiniRPCBenchmark.java

示例3: setup

import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception {

  String currentUser = System.getProperty("user.name");
  config.set(DefaultImpersonationProvider.getTestProvider()
      .getProxySuperuserGroupConfKey(currentUser), "*");
  config.set(DefaultImpersonationProvider.getTestProvider()
      .getProxySuperuserIpConfKey(currentUser), "*");
  ProxyUsers.refreshSuperUserGroupsConfiguration(config);
  cluster = new MiniDFSCluster.Builder(config).numDataNodes(1).build();
  cluster.waitActive();
  hdfs = cluster.getFileSystem();
  nn = cluster.getNameNode();

  // Use ephemeral port in case tests are running in parallel
  config.setInt("nfs3.mountd.port", 0);
  config.setInt("nfs3.server.port", 0);

  securityHandler = Mockito.mock(SecurityHandler.class);
  Mockito.when(securityHandler.getUser()).thenReturn(
      System.getProperty("user.name"));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestClientAccessPrivilege.java

示例4: configureSuperUserIPAddresses

import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; //导入依赖的package包/类
private static void configureSuperUserIPAddresses(Configuration conf,
    String superUserShortName) throws IOException {
  ArrayList<String> ipList = new ArrayList<String>();
  Enumeration<NetworkInterface> netInterfaceList = NetworkInterface
      .getNetworkInterfaces();
  while (netInterfaceList.hasMoreElements()) {
    NetworkInterface inf = netInterfaceList.nextElement();
    Enumeration<InetAddress> addrList = inf.getInetAddresses();
    while (addrList.hasMoreElements()) {
      InetAddress addr = addrList.nextElement();
      ipList.add(addr.getHostAddress());
    }
  }
  StringBuilder builder = new StringBuilder();
  for (String ip : ipList) {
    builder.append(ip);
    builder.append(',');
  }
  builder.append("127.0.1.1,");
  builder.append(InetAddress.getLocalHost().getCanonicalHostName());
  LOG.info("Local Ip addresses: " + builder.toString());
  conf.setStrings(DefaultImpersonationProvider.getTestProvider().
          getProxySuperuserIpConfKey(superUserShortName),
      builder.toString());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestDelegationTokenForProxyUser.java

示例5: setUp

import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  config = new HdfsConfiguration();
  config.setBoolean(DFSConfigKeys.DFS_WEBHDFS_ENABLED_KEY, true);
  config.setLong(
      DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_KEY, 10000);
  config.setLong(
      DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_KEY, 5000);
  config.setStrings(DefaultImpersonationProvider.getTestProvider().
          getProxySuperuserGroupConfKey(REAL_USER),
      "group1");
  config.setBoolean(
      DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_KEY, true);
  configureSuperUserIPAddresses(config, REAL_USER);
  FileSystem.setDefaultUri(config, "hdfs://localhost:" + "0");
  cluster = new MiniDFSCluster.Builder(config).build();
  cluster.waitActive();
  ProxyUsers.refreshSuperUserGroupsConfiguration(config);
  ugi = UserGroupInformation.createRemoteUser(REAL_USER);
  proxyUgi = UserGroupInformation.createProxyUserForTesting(PROXY_USER, ugi,
      GROUP_NAMES);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestDelegationTokenForProxyUser.java

示例6: setUp

import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  config = new HdfsConfiguration();
  config.setLong(
      DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_KEY, 10000);
  config.setLong(
      DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_KEY, 5000);
  config.setStrings(DefaultImpersonationProvider.getTestProvider().
          getProxySuperuserGroupConfKey(REAL_USER),
      "group1");
  config.setBoolean(
      DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_KEY, true);
  configureSuperUserIPAddresses(config, REAL_USER);
  FileSystem.setDefaultUri(config, "hdfs://localhost:" + "0");
  cluster = new MiniDFSCluster.Builder(config).build();
  cluster.waitActive();
  ProxyUsers.refreshSuperUserGroupsConfiguration(config);
  ugi = UserGroupInformation.createRemoteUser(REAL_USER);
  proxyUgi = UserGroupInformation.createProxyUserForTesting(PROXY_USER, ugi,
      GROUP_NAMES);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:22,代码来源:TestDelegationTokenForProxyUser.java

示例7: setup

import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception {
  String currentUser = System.getProperty("user.name");
  config.set(DefaultImpersonationProvider.getTestProvider().getProxySuperuserGroupConfKey(currentUser), "*");
  config.set(DefaultImpersonationProvider.getTestProvider().getProxySuperuserIpConfKey(currentUser), "*");
  ProxyUsers.refreshSuperUserGroupsConfiguration(config);
  cluster = new MiniDFSCluster.Builder(config).numDataNodes(1).build();
  cluster.waitActive();
  hdfs = cluster.getFileSystem();
  nn = cluster.getNameNode();

  // Use emphral port in case tests are running in parallel
  config.setInt("nfs3.mountd.port", 0);
  config.setInt("nfs3.server.port", 0);
  
  // Start nfs
  Nfs3 nfs3 = new Nfs3(config);
  nfs3.startServiceInternal(false);

  nfsd = (RpcProgramNfs3) nfs3.getRpcProgram();

  securityHandler = Mockito.mock(SecurityHandler.class);
  Mockito.when(securityHandler.getUser())
      .thenReturn(System.getProperty("user.name"));
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:26,代码来源:TestReaddir.java

示例8: configureSuperUserIPAddresses

import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; //导入依赖的package包/类
private void configureSuperUserIPAddresses(Configuration conf,
    String superUserShortName) throws IOException {
  ArrayList<String> ipList = new ArrayList<>();
  Enumeration<NetworkInterface> netInterfaceList =
      NetworkInterface.getNetworkInterfaces();
  while (netInterfaceList.hasMoreElements()) {
    NetworkInterface inf = netInterfaceList.nextElement();
    Enumeration<InetAddress> addrList = inf.getInetAddresses();
    while (addrList.hasMoreElements()) {
      InetAddress addr = addrList.nextElement();
      ipList.add(addr.getHostAddress());
    }
  }
  StringBuilder builder = new StringBuilder();
  for (String ip : ipList) {
    builder.append(ip);
    builder.append(',');
  }
  builder.append("127.0.1.1,");
  builder.append(InetAddress.getLocalHost().getCanonicalHostName());
  LOG.info("Local Ip addresses: " + builder.toString());
  conf.setStrings(DefaultImpersonationProvider.getTestProvider().getProxySuperuserIpConfKey(superUserShortName),
      builder.toString());
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:25,代码来源:TestDelegationTokenForProxyUser.java

示例9: setUp

import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  config = new HdfsConfiguration();
  config.setBoolean(DFSConfigKeys.DFS_WEBHDFS_ENABLED_KEY, true);
  config.setLong(DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_KEY,
      10000);
  config
      .setLong(DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_KEY,
          5000);
  config.setStrings(DefaultImpersonationProvider.getTestProvider().
            getProxySuperuserGroupConfKey(REAL_USER),
      "group1");
  config
      .setBoolean(DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_KEY,
          true);
  configureSuperUserIPAddresses(config, REAL_USER);
  FileSystem.setDefaultUri(config, "hdfs://localhost:" + "0");
  cluster = new MiniDFSCluster.Builder(config).build();
  cluster.waitActive();
  ProxyUsers.refreshSuperUserGroupsConfiguration(config);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:22,代码来源:TestDelegationTokenForProxyUser.java

示例10: testRealUserSetup

import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; //导入依赖的package包/类
@Test(timeout=4000)
public void testRealUserSetup() throws IOException {
  final Configuration conf = new Configuration();
  conf.setStrings(DefaultImpersonationProvider.getTestProvider().
      getProxySuperuserGroupConfKey(REAL_USER_SHORT_NAME), "group1");
  configureSuperUserIPAddresses(conf, REAL_USER_SHORT_NAME);
  Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
      .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
      .setNumHandlers(5).setVerbose(true).build();

  refreshConf(conf);
  try {
    server.start();

    UserGroupInformation realUserUgi = UserGroupInformation
        .createRemoteUser(REAL_USER_NAME);
    checkRemoteUgi(server, realUserUgi, conf);
    
    UserGroupInformation proxyUserUgi = UserGroupInformation.createProxyUserForTesting(
        PROXY_USER_NAME, realUserUgi, GROUP_NAMES);
    checkRemoteUgi(server, proxyUserUgi, conf);
  } catch (Exception e) {
    e.printStackTrace();
    Assert.fail();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:32,代码来源:TestDoAsEffectiveUser.java

示例11: testRealUserAuthorizationSuccess

import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; //导入依赖的package包/类
@Test(timeout=4000)
public void testRealUserAuthorizationSuccess() throws IOException {
  final Configuration conf = new Configuration();
  configureSuperUserIPAddresses(conf, REAL_USER_SHORT_NAME);
  conf.setStrings(DefaultImpersonationProvider.getTestProvider().
          getProxySuperuserGroupConfKey(REAL_USER_SHORT_NAME),
      "group1");
  Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
      .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
      .setNumHandlers(2).setVerbose(false).build();

  refreshConf(conf);
  try {
    server.start();

    UserGroupInformation realUserUgi = UserGroupInformation
        .createRemoteUser(REAL_USER_NAME);
    checkRemoteUgi(server, realUserUgi, conf);

    UserGroupInformation proxyUserUgi = UserGroupInformation
        .createProxyUserForTesting(PROXY_USER_NAME, realUserUgi, GROUP_NAMES);
    checkRemoteUgi(server, proxyUserUgi, conf);
  } catch (Exception e) {
    e.printStackTrace();
    Assert.fail();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:33,代码来源:TestDoAsEffectiveUser.java

示例12: runMiniBenchmarkWithDelegationToken

import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; //导入依赖的package包/类
/**
 * Run MiniBenchmark using delegation token authentication.
 * 
 * @param conf - configuration
 * @param count - connect this many times
 * @param keytabKey - key for keytab file in the configuration
 * @param userNameKey - key for user name in the configuration
 * @return average time to connect
 * @throws IOException
 */
long runMiniBenchmarkWithDelegationToken(Configuration conf,
                                         int count,
                                         String keytabKey,
                                         String userNameKey)
throws IOException {
  // get login information
  String user = System.getProperty("user.name");
  if(userNameKey != null)
    user = conf.get(userNameKey, user);
  String keytabFile = null;
  if(keytabKey != null)
    keytabFile = conf.get(keytabKey, keytabFile);
  MiniServer miniServer = null;
  UserGroupInformation.setConfiguration(conf);
  String shortUserName =
    UserGroupInformation.createRemoteUser(user).getShortUserName();
  try {
    conf.setStrings(DefaultImpersonationProvider.getTestProvider().
            getProxySuperuserGroupConfKey(shortUserName), GROUP_NAME_1);
    configureSuperUserIPAddresses(conf, shortUserName);
    // start the server
    miniServer = new MiniServer(conf, user, keytabFile);
    InetSocketAddress addr = miniServer.getAddress();

    connectToServerAndGetDelegationToken(conf, addr);
    // connect to the server count times
    setLoggingLevel(logLevel);
    long elapsed = 0L;
    for(int idx = 0; idx < count; idx ++) {
      elapsed += connectToServerUsingDelegationToken(conf, addr);
    }
    return elapsed;
  } finally {
    if(miniServer != null) miniServer.stop();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:47,代码来源:MiniRPCBenchmark.java

示例13: setup

import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception {
  String currentUser = System.getProperty("user.name");
  config.set(
          DefaultImpersonationProvider.getTestProvider().
              getProxySuperuserGroupConfKey(currentUser), "*");
  config.set(
          DefaultImpersonationProvider.getTestProvider().
              getProxySuperuserIpConfKey(currentUser), "*");
  ProxyUsers.refreshSuperUserGroupsConfiguration(config);
  cluster = new MiniDFSCluster.Builder(config).numDataNodes(1).build();
  cluster.waitActive();
  hdfs = cluster.getFileSystem();
  nn = cluster.getNameNode();

  // Use emphral port in case tests are running in parallel
  config.setInt("nfs3.mountd.port", 0);
  config.setInt("nfs3.server.port", 0);
  
  // Start nfs
  Nfs3 nfs3 = new Nfs3(config);
  nfs3.startServiceInternal(false);

  nfsd = (RpcProgramNfs3) nfs3.getRpcProgram();

  securityHandler = Mockito.mock(SecurityHandler.class);
  Mockito.when(securityHandler.getUser()).thenReturn(
      System.getProperty("user.name"));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:TestReaddir.java


注:本文中的org.apache.hadoop.security.authorize.DefaultImpersonationProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。