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

项目:ditb    文件: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());
  conf.setInt("hfile.format.version", 3);
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS, SimpleScanLabelGenerator.class,
      ScanLabelGenerator.class);
  util.setJobWithoutMRCluster();
  util.startMiniCluster();
  // Wait for the labels table to become available
  util.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME.getName(), 50000);
  createLabels();
}
项目:ditb    文件:IntegrationTestWithCellVisibilityLoadAndVerify.java   
@Override
public void setUpCluster() throws Exception {
  util = getTestingUtil(null);
  Configuration conf = util.getConfiguration();
  conf.setInt(HFile.FORMAT_VERSION_KEY, 3);
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  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();
}
项目:pbase    文件: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());
  conf.setInt("hfile.format.version", 3);
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  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();
  Admin admin = new HBaseAdmin(util.getConfiguration());
  util.startMiniMapReduceCluster();
}
项目:HIndex    文件: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());
  conf.set("hbase.coprocessor.master.classes",
      VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes",
      VisibilityController.class.getName());
  conf.setInt("hfile.format.version", 3);
  UTIL.startMiniCluster(1);
  // Wait for the labels table to become available
  UTIL.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME.getName(), 50000);
  createLabels();
  HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
  HTableDescriptor tableDescriptor = new HTableDescriptor(
      TableName.valueOf(tableAname));
  for (HColumnDescriptor family : families) {
    tableDescriptor.addFamily(family);
  }
  admin.createTable(tableDescriptor);
  setAuths();
}
项目:HIndex    文件: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());
  conf.setInt("hfile.format.version", 3);
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  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();
  HBaseAdmin admin = new HBaseAdmin(util.getConfiguration());
  util.startMiniMapReduceCluster();
}
项目:hbase    文件:TestMasterCoprocessorServices.java   
@Test
public void testVisibilityLabelServices() {
  MasterCoprocessor defaultImpl = new VisibilityController();
  MasterCoprocessor customImpl = new MockVisibilityController();
  MasterCoprocessor unrelatedImpl = new JMXListener();
  assertTrue(masterServices.checkCoprocessorWithService(
      Collections.singletonList(defaultImpl), VisibilityLabelsService.Interface.class));
  assertTrue(masterServices.checkCoprocessorWithService(
      Collections.singletonList(customImpl), VisibilityLabelsService.Interface.class));
  assertFalse(masterServices.checkCoprocessorWithService(
      Collections.emptyList(), VisibilityLabelsService.Interface.class));
  assertFalse(masterServices.checkCoprocessorWithService(
      null, VisibilityLabelsService.Interface.class));
  assertFalse(masterServices.checkCoprocessorWithService(
      Collections.singletonList(unrelatedImpl), VisibilityLabelsService.Interface.class));
  assertTrue(masterServices.checkCoprocessorWithService(
      Arrays.asList(unrelatedImpl, customImpl), VisibilityLabelsService.Interface.class));
  assertTrue(masterServices.checkCoprocessorWithService(
      Arrays.asList(unrelatedImpl, defaultImpl), VisibilityLabelsService.Interface.class));
}
项目:PyroDB    文件: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());
  conf.set("hbase.coprocessor.master.classes",
      VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes",
      VisibilityController.class.getName());
  conf.setInt("hfile.format.version", 3);
  UTIL.startMiniCluster(1);
  // Wait for the labels table to become available
  UTIL.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME.getName(), 50000);
  createLabels();
  HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
  HTableDescriptor tableDescriptor = new HTableDescriptor(
      TableName.valueOf(tableAname));
  for (HColumnDescriptor family : families) {
    tableDescriptor.addFamily(family);
  }
  admin.createTable(tableDescriptor);
  setAuths();
}
项目:PyroDB    文件: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());
  conf.setInt("hfile.format.version", 3);
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  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();
  HBaseAdmin admin = new HBaseAdmin(util.getConfiguration());
  util.startMiniMapReduceCluster();
}
项目:ditb    文件: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());
  conf.set("hbase.coprocessor.master.classes",
      VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes",
      VisibilityController.class.getName());
  conf.setInt("hfile.format.version", 3);
  UTIL.startMiniCluster(1);
  // Wait for the labels table to become available
  UTIL.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME.getName(), 50000);
  createLabels();
  Admin admin = new HBaseAdmin(UTIL.getConfiguration());
  HTableDescriptor tableDescriptor = new HTableDescriptor(
      TableName.valueOf(tableAname));
  for (HColumnDescriptor family : families) {
    tableDescriptor.addFamily(family);
  }
  admin.createTable(tableDescriptor);
  admin.close();
  setAuths();
}
项目:ditb    文件:MasterRpcServices.java   
/** 
 * Returns the security capabilities in effect on the cluster
 */
@Override
public SecurityCapabilitiesResponse getSecurityCapabilities(RpcController controller,
    SecurityCapabilitiesRequest request) throws ServiceException {
  SecurityCapabilitiesResponse.Builder response = SecurityCapabilitiesResponse.newBuilder();
  try {
    master.checkInitialized();
    Set<Capability> capabilities = new HashSet<>();
    // Authentication
    if (User.isHBaseSecurityEnabled(master.getConfiguration())) {
      capabilities.add(Capability.SECURE_AUTHENTICATION);
    } else {
      capabilities.add(Capability.SIMPLE_AUTHENTICATION);
    }
    // The AccessController can provide AUTHORIZATION and CELL_AUTHORIZATION
    if (master.cpHost != null &&
          master.cpHost.findCoprocessor(AccessController.class.getName()) != null) {
      if (AccessController.isAuthorizationSupported(master.getConfiguration())) {
        capabilities.add(Capability.AUTHORIZATION);
      }
      if (AccessController.isCellAuthorizationSupported(master.getConfiguration())) {
        capabilities.add(Capability.CELL_AUTHORIZATION);
      }
    }
    // The VisibilityController can provide CELL_VISIBILITY
    if (master.cpHost != null &&
          master.cpHost.findCoprocessor(VisibilityController.class.getName()) != null) {
      if (VisibilityController.isCellAuthorizationSupported(master.getConfiguration())) {
        capabilities.add(Capability.CELL_VISIBILITY);
      }
    }
    response.addAllCapabilities(capabilities);
  } catch (IOException e) {
    throw new ServiceException(e);
  }
  return response.build();
}
项目:ditb    文件:IntegrationTestIngestWithVisibilityLabels.java   
@Override
public void setUpCluster() throws Exception {
  util = getTestingUtil(null);
  Configuration conf = util.getConfiguration();
  conf.setInt(HFile.FORMAT_VERSION_KEY, 3);
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  conf.set("hbase.superuser", "admin," + User.getCurrent().getName());
  super.setUpCluster();
  addLabels();
}
项目:ditb    文件:IntegrationTestBigLinkedListWithVisibility.java   
@Override
public void setUpCluster() throws Exception {
  util = getTestingUtil(null);
  Configuration conf = util.getConfiguration();
  conf.setInt(HFile.FORMAT_VERSION_KEY, 3);
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  conf.set("hbase.superuser", User.getCurrent().getName());
  conf.setBoolean("dfs.permissions", false);
  USER = User.createUserForTesting(conf, userName, new String[] {});
  super.setUpCluster();
  addLabels();
}
项目:ditb    文件: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.setInt("hfile.format.version", 3);
  conf.set("hbase.superuser", SUPERUSER.getShortName());
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  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.getHBaseAdmin();
  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);
}
项目:HIndex    文件: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.setInt("hfile.format.version", 3);
  conf.set("hbase.superuser", SUPERUSER.getShortName());
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  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();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(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);
}
项目:HIndex    文件:IntegrationTestIngestWithVisibilityLabels.java   
@Override
public void setUpCluster() throws Exception {
  util = getTestingUtil(null);
  Configuration conf = util.getConfiguration();
  conf.setInt(HFile.FORMAT_VERSION_KEY, 3);
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  conf.set("hbase.superuser", "admin," + User.getCurrent().getName());
  super.setUpCluster();
  addLabels();
}
项目:HIndex    文件:IntegrationTestWithCellVisibilityLoadAndVerify.java   
@Override
public void setUpCluster() throws Exception {
  util = getTestingUtil(null);
  Configuration conf = util.getConfiguration();
  conf.setInt(HFile.FORMAT_VERSION_KEY, 3);
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  conf.set("hbase.superuser", User.getCurrent().getName());
  super.setUpCluster();
  USER1 = User.createUserForTesting(conf, "user1", new String[] {});
  USER2 = User.createUserForTesting(conf, "user2", new String[] {});
  addLabelsAndAuths();
}
项目:hbase    文件:MasterRpcServices.java   
/**
 * Returns the security capabilities in effect on the cluster
 */
@Override
public SecurityCapabilitiesResponse getSecurityCapabilities(RpcController controller,
    SecurityCapabilitiesRequest request) throws ServiceException {
  SecurityCapabilitiesResponse.Builder response = SecurityCapabilitiesResponse.newBuilder();
  try {
    master.checkInitialized();
    Set<SecurityCapabilitiesResponse.Capability> capabilities = new HashSet<>();
    // Authentication
    if (User.isHBaseSecurityEnabled(master.getConfiguration())) {
      capabilities.add(SecurityCapabilitiesResponse.Capability.SECURE_AUTHENTICATION);
    } else {
      capabilities.add(SecurityCapabilitiesResponse.Capability.SIMPLE_AUTHENTICATION);
    }
    // A coprocessor that implements AccessControlService can provide AUTHORIZATION and
    // CELL_AUTHORIZATION
    if (master.cpHost != null && hasAccessControlServiceCoprocessor(master.cpHost)) {
      if (AccessChecker.isAuthorizationSupported(master.getConfiguration())) {
        capabilities.add(SecurityCapabilitiesResponse.Capability.AUTHORIZATION);
      }
      if (AccessController.isCellAuthorizationSupported(master.getConfiguration())) {
        capabilities.add(SecurityCapabilitiesResponse.Capability.CELL_AUTHORIZATION);
      }
    }
    // A coprocessor that implements VisibilityLabelsService can provide CELL_VISIBILITY.
    if (master.cpHost != null && hasVisibilityLabelsServiceCoprocessor(master.cpHost)) {
      if (VisibilityController.isCellAuthorizationSupported(master.getConfiguration())) {
        capabilities.add(SecurityCapabilitiesResponse.Capability.CELL_VISIBILITY);
      }
    }
    response.addAllCapabilities(capabilities);
  } catch (IOException e) {
    throw new ServiceException(e);
  }
  return response.build();
}
项目:PyroDB    文件: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.setInt("hfile.format.version", 3);
  conf.set("hbase.superuser", SUPERUSER.getShortName());
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  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();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(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);
}
项目:PyroDB    文件:IntegrationTestIngestWithVisibilityLabels.java   
@Override
public void setUpCluster() throws Exception {
  util = getTestingUtil(null);
  Configuration conf = util.getConfiguration();
  conf.setInt(HFile.FORMAT_VERSION_KEY, 3);
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  conf.set("hbase.superuser", "admin," + User.getCurrent().getName());
  super.setUpCluster();
  addLabels();
}
项目:PyroDB    文件:IntegrationTestWithCellVisibilityLoadAndVerify.java   
@Override
public void setUpCluster() throws Exception {
  util = getTestingUtil(null);
  Configuration conf = util.getConfiguration();
  conf.setInt(HFile.FORMAT_VERSION_KEY, 3);
  conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
  conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
  String adminName = User.getCurrent().getName();
  conf.set("hbase.superuser", adminName);
  super.setUpCluster();
  ADMIN = User.createUserForTesting(conf, adminName, new String[] { "supergroup" });
  NORMAL_USER = User.createUserForTesting(conf, "user1", new String[] {});
  addLabelsAndAuths();
}