Java Code Examples for org.apache.hadoop.hbase.security.UserProvider#setUserProviderForTesting()

The following examples show how to use org.apache.hadoop.hbase.security.UserProvider#setUserProviderForTesting() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSecureExport.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the security firstly for getting the correct default realm.
 */
@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(PermissionStorage.ACL_TABLE_NAME);
  UTIL.waitUntilAllRegionsAssigned(VisibilityConstants.LABELS_TABLE_NAME);
  UTIL.waitTableEnabled(PermissionStorage.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));
}
 
Example 2
Source File: TestSecureBulkLoadHFiles.java    From hbase with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // set the always on security provider
  UserProvider.setUserProviderForTesting(util.getConfiguration(),
    HadoopSecurityEnabledUserProviderForTesting.class);
  // setup configuration
  SecureTestUtil.enableSecurity(util.getConfiguration());
  util.getConfiguration().setInt(BulkLoadHFiles.MAX_FILES_PER_REGION_PER_FAMILY,
    MAX_FILES_PER_REGION_PER_FAMILY);
  // change default behavior so that tag values are returned with normal rpcs
  util.getConfiguration().set(HConstants.RPC_CODEC_CONF_KEY,
    KeyValueCodecWithTags.class.getCanonicalName());

  util.startMiniCluster();

  // Wait for the ACL table to become available
  util.waitTableEnabled(PermissionStorage.ACL_TABLE_NAME);

  setupNamespace();
}
 
Example 3
Source File: TestMobSecureExportSnapshot.java    From hbase with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  setUpBaseConf(TEST_UTIL.getConfiguration());
  // Setup separate test-data directory for MR cluster and set corresponding configurations.
  // Otherwise, different test classes running MR cluster can step on each other.
  TEST_UTIL.getDataTestDir();

  // set the always on security provider
  UserProvider.setUserProviderForTesting(TEST_UTIL.getConfiguration(),
    HadoopSecurityEnabledUserProviderForTesting.class);

  // setup configuration
  SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration());

  TEST_UTIL.startMiniCluster(3);
  TEST_UTIL.startMiniMapReduceCluster();

  // Wait for the ACL table to become available
  TEST_UTIL.waitTableEnabled(PermissionStorage.ACL_TABLE_NAME);
}
 
Example 4
Source File: TestSecureExportSnapshot.java    From hbase with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  setUpBaseConf(TEST_UTIL.getConfiguration());
  // Setup separate test-data directory for MR cluster and set corresponding configurations.
  // Otherwise, different test classes running MR cluster can step on each other.
  TEST_UTIL.getDataTestDir();

  // set the always on security provider
  UserProvider.setUserProviderForTesting(TEST_UTIL.getConfiguration(),
    HadoopSecurityEnabledUserProviderForTesting.class);

  // setup configuration
  SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration());

  TEST_UTIL.startMiniCluster(3);
  TEST_UTIL.startMiniMapReduceCluster();

  // Wait for the ACL table to become available
  TEST_UTIL.waitTableEnabled(PermissionStorage.ACL_TABLE_NAME);
}
 
Example 5
Source File: TestSecureBulkLoadHFilesSplitRecovery.java    From hbase with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setupCluster() throws Exception {
  util = new HBaseTestingUtility();
  // set the always on security provider
  UserProvider.setUserProviderForTesting(util.getConfiguration(),
    HadoopSecurityEnabledUserProviderForTesting.class);
  // setup configuration
  SecureTestUtil.enableSecurity(util.getConfiguration());

  util.startMiniCluster();

  // Wait for the ACL table to become available
  util.waitTableEnabled(PermissionStorage.ACL_TABLE_NAME);
}
 
Example 6
Source File: TestBackupBase.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * @throws Exception if starting the mini cluster or setting up the tables fails
 */
@Before
public void setUp() throws Exception {
  if (setupIsDone) {
    return;
  }
  if (secure) {
    // set the always on security provider
    UserProvider.setUserProviderForTesting(TEST_UTIL.getConfiguration(),
        HadoopSecurityEnabledUserProviderForTesting.class);
    // setup configuration
    SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration());
  }
  conf1.setBoolean(BackupRestoreConstants.BACKUP_ENABLE_KEY, true);
  BackupManager.decorateMasterConfiguration(conf1);
  BackupManager.decorateRegionServerConfiguration(conf1);
  conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
  // Set TTL for old WALs to 1 sec to enforce fast cleaning of an archived
  // WAL files
  conf1.setLong(TimeToLiveLogCleaner.TTL_CONF_KEY, 1000);
  conf1.setLong(LogCleaner.OLD_WALS_CLEANER_THREAD_TIMEOUT_MSEC, 1000);

  // Set MultiWAL (with 2 default WAL files per RS)
  conf1.set(WALFactory.WAL_PROVIDER, provider);
  TEST_UTIL.startMiniCluster();

  if (useSecondCluster) {
    conf2 = HBaseConfiguration.create(conf1);
    conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
    TEST_UTIL2 = new HBaseTestingUtility(conf2);
    TEST_UTIL2.setZkCluster(TEST_UTIL.getZkCluster());
    TEST_UTIL2.startMiniDFSCluster(3);
    String root2 = TEST_UTIL2.getConfiguration().get("fs.defaultFS");
    Path p = new Path(new Path(root2), "/tmp/wal");
    CommonFSUtils.setWALRootDir(TEST_UTIL2.getConfiguration(), p);
    TEST_UTIL2.startMiniCluster();
  }
  conf1 = TEST_UTIL.getConfiguration();

  TEST_UTIL.startMiniMapReduceCluster();
  BACKUP_ROOT_DIR =
      new Path(new Path(TEST_UTIL.getConfiguration().get("fs.defaultFS")),
        BACKUP_ROOT_DIR).toString();
  LOG.info("ROOTDIR " + BACKUP_ROOT_DIR);
  if (useSecondCluster) {
    BACKUP_REMOTE_ROOT_DIR =
        new Path(new Path(TEST_UTIL2.getConfiguration().get("fs.defaultFS"))
        + BACKUP_REMOTE_ROOT_DIR).toString();
    LOG.info("REMOTE ROOTDIR " + BACKUP_REMOTE_ROOT_DIR);
  }
  createTables();
  populateFromMasterConfig(TEST_UTIL.getHBaseCluster().getMaster().getConfiguration(), conf1);
  setupIsDone = true;
}