Java 类org.apache.hadoop.hbase.security.visibility.VisibilityTestUtil 实例源码

项目:pbase    文件:TestShell.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Start mini cluster
  TEST_UTIL.getConfiguration().setBoolean("hbase.online.schema.update.enable", true);
  TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
  TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
  TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
  TEST_UTIL.getConfiguration().setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false);
  TEST_UTIL.getConfiguration().setInt("hfile.format.version", 3);
  // Security setup configuration
  SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration());
  VisibilityTestUtil.enableVisiblityLabels(TEST_UTIL.getConfiguration());

  TEST_UTIL.startMiniCluster();

  // Configure jruby runtime
  List<String> loadPaths = new ArrayList();
  loadPaths.add("src/main/ruby");
  loadPaths.add("src/test/ruby");
  jruby.getProvider().setLoadPaths(loadPaths);
  jruby.put("$TEST_CLUSTER", TEST_UTIL);
  System.setProperty("jruby.jit.logging.verbose", "true");
  System.setProperty("jruby.jit.logging", "true");
  System.setProperty("jruby.native.verbose", "true");
}
项目:hbase    文件:TestThriftHBaseServiceHandlerWithLabels.java   
@BeforeClass
public static void beforeClass() throws Exception {
  SUPERUSER = User.createUserForTesting(conf, "admin",
      new String[] { "supergroup" });
  conf = UTIL.getConfiguration();
  conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS,
      SimpleScanLabelGenerator.class, ScanLabelGenerator.class);
  conf.set("hbase.superuser", SUPERUSER.getShortName());
  VisibilityTestUtil.enableVisiblityLabels(conf);
  UTIL.startMiniCluster(1);
  // Wait for the labels table to become available
  UTIL.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME.getName(), 50000);
  createLabels();
  Admin admin = UTIL.getAdmin();
  HTableDescriptor tableDescriptor = new HTableDescriptor(
      TableName.valueOf(tableAname));
  for (HColumnDescriptor family : families) {
    tableDescriptor.addFamily(family);
  }
  admin.createTable(tableDescriptor);
  admin.close();
  setAuths();
}
项目:hbase    文件:TestSecureExport.java   
/**
 * Sets the security firstly for getting the correct default realm.
 * @throws Exception
 */
@BeforeClass
public static void beforeClass() throws Exception {
  UserProvider.setUserProviderForTesting(UTIL.getConfiguration(), HadoopSecurityEnabledUserProviderForTesting.class);
  setUpKdcServer();
  SecureTestUtil.enableSecurity(UTIL.getConfiguration());
  UTIL.getConfiguration().setBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY, true);
  VisibilityTestUtil.enableVisiblityLabels(UTIL.getConfiguration());
  SecureTestUtil.verifyConfiguration(UTIL.getConfiguration());
  setUpClusterKdc();
  UTIL.startMiniCluster();
  UTIL.waitUntilAllRegionsAssigned(AccessControlLists.ACL_TABLE_NAME);
  UTIL.waitUntilAllRegionsAssigned(VisibilityConstants.LABELS_TABLE_NAME);
  UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME, 50000);
  UTIL.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME, 50000);
  SecureTestUtil.grantGlobal(UTIL, USER_ADMIN,
          Permission.Action.ADMIN,
          Permission.Action.CREATE,
          Permission.Action.EXEC,
          Permission.Action.READ,
          Permission.Action.WRITE);
  addLabels(UTIL.getConfiguration(), Arrays.asList(USER_OWNER),
          Arrays.asList(PRIVATE, CONFIDENTIAL, SECRET, TOPSECRET));
}
项目:hbase    文件:IntegrationTestWithCellVisibilityLoadAndVerify.java   
@Override
public void setUpCluster() throws Exception {
  util = getTestingUtil(null);
  Configuration conf = util.getConfiguration();
  VisibilityTestUtil.enableVisiblityLabels(conf);
  conf.set("hbase.superuser", User.getCurrent().getName());
  conf.setBoolean("dfs.permissions", false);
  super.setUpCluster();
  String[] users = userNames.split(",");
  if (users.length != 2) {
    System.err.println(ERROR_STR);
    throw new IOException(ERROR_STR);
  }
  System.out.println(userNames + " "+users[0]+ " "+users[1]);
  USER1 = User.createUserForTesting(conf, users[0], new String[] {});
  USER2 = User.createUserForTesting(conf, users[1], new String[] {});
  addLabelsAndAuths();
}
项目:ditb    文件:AbstractTestShell.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Start mini cluster
  TEST_UTIL.getConfiguration().setBoolean("hbase.online.schema.update.enable", true);
  TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
  TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
  TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
  TEST_UTIL.getConfiguration().setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false);
  TEST_UTIL.getConfiguration().setInt("hfile.format.version", 3);
  TEST_UTIL.getConfiguration().setInt(HConstants.MASTER_INFO_PORT, -1);
  TEST_UTIL.getConfiguration().setInt(HConstants.REGIONSERVER_INFO_PORT, -1);
  // Security setup configuration
  SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration());
  VisibilityTestUtil.enableVisiblityLabels(TEST_UTIL.getConfiguration());

  TEST_UTIL.startMiniCluster();

  // Configure jruby runtime
  List<String> loadPaths = new ArrayList();
  loadPaths.add("src/main/ruby");
  loadPaths.add("src/test/ruby");
  jruby.getProvider().setLoadPaths(loadPaths);
  jruby.put("$TEST_CLUSTER", TEST_UTIL);
  System.setProperty("jruby.jit.logging.verbose", "true");
  System.setProperty("jruby.jit.logging", "true");
  System.setProperty("jruby.native.verbose", "true");
}
项目:Gaffer    文件:MiniHBaseStore.java   
private Configuration setupConf() throws IOException {
    final Configuration conf = HBaseConfiguration.create();
    VisibilityTestUtil.enableVisiblityLabels(conf);
    conf.set(Superusers.SUPERUSER_CONF_KEY, ADMIN_USERNAME);
    conf.setInt(HFile.FORMAT_VERSION_KEY, HFile.MIN_FORMAT_VERSION_WITH_TAGS);
    conf.set(JTConfig.JT_IPC_ADDRESS, JTConfig.LOCAL_FRAMEWORK_NAME);
    conf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, CommonConfigurationKeysPublic.FS_DEFAULT_NAME_DEFAULT);
    conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS, SimpleScanLabelGenerator.class,
            ScanLabelGenerator.class);
    conf.set(HConstants.REPLICATION_CODEC_CONF_KEY, KeyValueCodecWithTags.class.getName());
    return conf;
}
项目:hbase    文件:TestImportTSVWithVisibilityLabels.java   
@BeforeClass
public static void provisionCluster() throws Exception {
  conf = util.getConfiguration();
  SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
  conf.set("hbase.superuser", "admin,"+User.getCurrent().getName());
  VisibilityTestUtil.enableVisiblityLabels(conf);
  conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS, SimpleScanLabelGenerator.class,
      ScanLabelGenerator.class);
  util.startMiniCluster();
  // Wait for the labels table to become available
  util.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME.getName(), 50000);
  createLabels();
}
项目:hbase    文件:IntegrationTestIngestWithVisibilityLabels.java   
@Override
public void setUpCluster() throws Exception {
  util = getTestingUtil(null);
  Configuration conf = util.getConfiguration();
  VisibilityTestUtil.enableVisiblityLabels(conf);
  conf.set("hbase.superuser", "admin," + User.getCurrent().getName());
  super.setUpCluster();
  addLabels();
}
项目:hbase    文件:IntegrationTestBigLinkedListWithVisibility.java   
@Override
public void setUpCluster() throws Exception {
  util = getTestingUtil(null);
  Configuration conf = util.getConfiguration();
  VisibilityTestUtil.enableVisiblityLabels(conf);
  conf.set("hbase.superuser", User.getCurrent().getName());
  conf.setBoolean("dfs.permissions", false);
  USER = User.createUserForTesting(conf, userName, new String[] {});
  super.setUpCluster();
  addLabels();
}
项目:hbase    文件:TestScannersWithLabels.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  SUPERUSER = User.createUserForTesting(conf, "admin",
      new String[] { "supergroup" });
  conf = TEST_UTIL.getConfiguration();
  conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS,
      SimpleScanLabelGenerator.class, ScanLabelGenerator.class);
  conf.set("hbase.superuser", SUPERUSER.getShortName());
  VisibilityTestUtil.enableVisiblityLabels(conf);
  TEST_UTIL.startMiniCluster(1);
  // Wait for the labels table to become available
  TEST_UTIL.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME.getName(), 50000);
  createLabels();
  setAuths();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(CellModel.class, CellSetModel.class, RowModel.class,
      ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  Admin admin = TEST_UTIL.getAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  insertData(TABLE, COLUMN_1, 1.0);
  insertData(TABLE, COLUMN_2, 0.5);
}
项目:hbase    文件:AbstractTestShell.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Start mini cluster
  TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
  TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
  TEST_UTIL.getConfiguration().setBoolean("hbase.quota.enabled", true);
  TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
  TEST_UTIL.getConfiguration().setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false);
  TEST_UTIL.getConfiguration().setInt("hfile.format.version", 3);

  // Below settings are necessary for task monitor test.
  TEST_UTIL.getConfiguration().setInt(HConstants.MASTER_INFO_PORT, 0);
  TEST_UTIL.getConfiguration().setInt(HConstants.REGIONSERVER_INFO_PORT, 0);
  TEST_UTIL.getConfiguration().setBoolean(HConstants.REGIONSERVER_INFO_PORT_AUTO, true);
  // Security setup configuration
  SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration());
  VisibilityTestUtil.enableVisiblityLabels(TEST_UTIL.getConfiguration());

  TEST_UTIL.startMiniCluster();

  // Configure jruby runtime
  List<String> loadPaths = new ArrayList<>(2);
  loadPaths.add("src/main/ruby");
  loadPaths.add("src/test/ruby");
  jruby.setLoadPaths(loadPaths);
  jruby.put("$TEST_CLUSTER", TEST_UTIL);
  System.setProperty("jruby.jit.logging.verbose", "true");
  System.setProperty("jruby.jit.logging", "true");
  System.setProperty("jruby.native.verbose", "true");
}
项目:hbase    文件:TestShellRSGroups.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  basePath = System.getProperty("basedir");

  // Start mini cluster
  TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
  TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
  TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
  TEST_UTIL.getConfiguration().setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false);
  TEST_UTIL.getConfiguration().setInt("hfile.format.version", 3);
  // Security setup configuration
  SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration());
  VisibilityTestUtil.enableVisiblityLabels(TEST_UTIL.getConfiguration());

  //Setup RegionServer Groups
  TEST_UTIL.getConfiguration().set(
      HConstants.HBASE_MASTER_LOADBALANCER_CLASS,
      RSGroupBasedLoadBalancer.class.getName());
  TEST_UTIL.getConfiguration().set(
      CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY,
      RSGroupAdminEndpoint.class.getName());

  TEST_UTIL.startMiniCluster(1,4);

  // Configure jruby runtime
  List<String> loadPaths = new ArrayList<>(2);
  loadPaths.add(basePath+"/src/main/ruby");
  loadPaths.add(basePath+"/src/test/ruby");
  jruby.setLoadPaths(loadPaths);
  jruby.put("$TEST_CLUSTER", TEST_UTIL);
  System.setProperty("jruby.jit.logging.verbose", "true");
  System.setProperty("jruby.jit.logging", "true");
  System.setProperty("jruby.native.verbose", "true");
}