class AWSCredentialUtils {

  static String getKey(Configuration conf, String keyType) {
    checkNotNull(conf, "conf cannot be null");
    checkNotNull(keyType, "KeyType cannot be null");

    try {
      char[] key = conf.getPassword(keyType);
      if (key == null) {
        throw new IllegalStateException(format("Unable to get value of '%s'", keyType));
      }
      return new String(key);
    } catch (IOException e) {
      throw new RuntimeException(format("Error getting key for '%s' from credential provider", keyType), e);
    }
  }

  private  AWSCredentialUtils();

}