@Test
public void testJksProviderPasswordViaConfig() throws Exception {

  Configuration conf = new Configuration();
  final String ourUrl =
      JavaKeyStoreProvider.SCHEME_NAME + "://file" + tmpDir + "/test.jks";
  File file = new File(tmpDir, "test.jks");
  file.delete();
  try {
    conf.set(KeyProviderFactory.KEY_PROVIDER_PATH, ourUrl);
    conf.set(JavaKeyStoreProvider.KEYSTORE_PASSWORD_FILE_KEY,
        "javakeystoreprovider.password");
    KeyProvider provider = KeyProviderFactory.getProviders(conf).get(0);
    provider.createKey("key3", new byte[32], KeyProvider.options(conf));
    provider.flush();
  } catch (Exception ex) {
    Assert.fail("could not create keystore with password file");
  }
  KeyProvider provider = KeyProviderFactory.getProviders(conf).get(0);
  Assert.assertNotNull(provider.getCurrentKey("key3"));
  try {
    conf.set(JavaKeyStoreProvider.KEYSTORE_PASSWORD_FILE_KEY, "bar");
    KeyProviderFactory.getProviders(conf).get(0);
    Assert.fail("using non existing password file, it should fail");
  } catch (IOException ex) {
    //NOP
  }
  try {
    conf.set(JavaKeyStoreProvider.KEYSTORE_PASSWORD_FILE_KEY, "core-site.xml");
    KeyProviderFactory.getProviders(conf).get(0);
    Assert.fail("using different password file, it should fail");
  } catch (IOException ex) {
    //NOP
  }
  try {
    conf.unset(JavaKeyStoreProvider.KEYSTORE_PASSWORD_FILE_KEY);
    KeyProviderFactory.getProviders(conf).get(0);
    Assert.fail("No password file property, env not set, it should fail");
  } catch (IOException ex) {
    //NOP
  }
}