public static String getPasswordFromProperties(Properties properties, Function<String, String> keyTransform)
      throws HiveException, IOException {
    String passwd = properties.getProperty(keyTransform.apply(CONFIG_PWD));
    String keystore = properties.getProperty(keyTransform.apply(CONFIG_PWD_KEYSTORE));
    String uri = properties.getProperty(keyTransform.apply(CONFIG_PWD_URI));
    if (countNonNull(passwd, keystore, uri) > 1) {
      // In tez, when the job conf is copied there is a code path in HiveInputFormat where all the table properties
      // are copied and the password is copied from the job credentials, so its possible to have 2 of them set.
      // For now ignore this and print a warning message, we should fix so that the above code is used instead.
      LOGGER.warn("Only one of " + CONFIG_PWD + ", " + CONFIG_PWD_KEYSTORE + ", " + CONFIG_PWD_URI + " can be set");
      // throw new HiveException(
      //    "Only one of " + CONFIG_PWD + ", " + CONFIG_PWD_KEYSTORE + ", " + CONFIG_PWD_URI + " can be set");
    }
    if (passwd == null && keystore != null) {
      String key = properties.getProperty(keyTransform.apply(CONFIG_PWD_KEY));
      passwd = Utilities.getPasswdFromKeystore(keystore, key);
    }
    if (passwd == null && uri != null) {
      try {
        passwd = Utilities.getPasswdFromUri(uri);
      } catch (URISyntaxException e) {
        // Should I include the uri in the exception? Suppressing for now, since it may have sensitive info.
        throw new HiveException("Invalid password uri specified", e);
      }
    }
    return passwd;
  }
@Test
  public void testExtractPassword() throws Exception {
    String prefix = "test.";
    String password = "my-super-secret";
    Properties props = new Properties();
    props.put(prefix + JdbcStorageConfigManager.CONFIG_PWD, password);
    props.put(prefix + JdbcStorageConfigManager.CONFIG_PWD_URI, "test:///random-stuff");

    String passwd = JdbcStorageConfigManager.getPasswordFromProperties(props, s -> prefix + s);
    assertThat(passwd, is(equalTo(password)));
  }