org.apache.hadoop.crypto.key.kms.server.MiniKMS Java Examples

The following examples show how to use org.apache.hadoop.crypto.key.kms.server.MiniKMS. 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: TestEncryptionZonesWithKMS.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
  File kmsDir = new File("target/test-classes/" +
      UUID.randomUUID().toString());
  Assert.assertTrue(kmsDir.mkdirs());
  MiniKMS.Builder miniKMSBuilder = new MiniKMS.Builder();
  miniKMS = miniKMSBuilder.setKmsConfDir(kmsDir).build();
  miniKMS.start();
  super.setup();
}
 
Example #2
Source File: TestEncryptionZonesWithKMS.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
  File kmsDir = new File("target/test-classes/" +
      UUID.randomUUID().toString());
  Assert.assertTrue(kmsDir.mkdirs());
  MiniKMS.Builder miniKMSBuilder = new MiniKMS.Builder();
  miniKMS = miniKMSBuilder.setKmsConfDir(kmsDir).build();
  miniKMS.start();
  super.setup();
}
 
Example #3
Source File: TestOzoneAtRestEncryption.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
/**
   * Create a MiniOzoneCluster for testing.
   * <p>
   * Ozone is made active by setting OZONE_ENABLED = true
   *
   * @throws IOException
   */
@BeforeClass
public static void init() throws Exception {
  testDir = GenericTestUtils.getTestDir(
      TestSecureOzoneRpcClient.class.getSimpleName());

  File kmsDir = new File(testDir, UUID.randomUUID().toString());
  Assert.assertTrue(kmsDir.mkdirs());
  MiniKMS.Builder miniKMSBuilder = new MiniKMS.Builder();
  miniKMS = miniKMSBuilder.setKmsConfDir(kmsDir).build();
  miniKMS.start();

  OzoneManager.setTestSecureOmFlag(true);
  conf = new OzoneConfiguration();
  conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH,
      getKeyProviderURI(miniKMS));
  conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir.getAbsolutePath());
  conf.setBoolean(HddsConfigKeys.HDDS_BLOCK_TOKEN_ENABLED, true);
  conf.set(OZONE_METADATA_DIRS, testDir.getAbsolutePath());
  CertificateClientTestImpl certificateClientTest =
      new CertificateClientTestImpl(conf);
  cluster = MiniOzoneCluster.newBuilder(conf)
      .setNumDatanodes(10)
      .setScmId(SCM_ID)
      .setCertificateClient(certificateClientTest)
      .build();
  cluster.getOzoneManager().startSecretManager();
  cluster.waitForClusterToBeReady();
  ozClient = OzoneClientFactory.getRpcClient(conf);
  store = ozClient.getObjectStore();
  storageContainerLocationClient =
      cluster.getStorageContainerLocationClient();
  ozoneManager = cluster.getOzoneManager();
  TestOzoneRpcClient.setCluster(cluster);
  TestOzoneRpcClient.setOzClient(ozClient);
  TestOzoneRpcClient.setOzoneManager(ozoneManager);
  TestOzoneRpcClient.setStorageContainerLocationClient(
      storageContainerLocationClient);
  TestOzoneRpcClient.setStore(store);
  TestOzoneRpcClient.setScmId(SCM_ID);

  // create test key
  createKey(TEST_KEY, cluster.getOzoneManager().getKmsProvider(), conf);
}
 
Example #4
Source File: TestOzoneAtRestEncryption.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
private static String getKeyProviderURI(MiniKMS kms) {
  return KMSClientProvider.SCHEME_NAME + "://" +
      kms.getKMSUrl().toExternalForm().replace("://", "@");
}