Java Code Examples for org.apache.hadoop.conf.Configuration.getPassword()

The following are Jave code examples for showing how to use getPassword() of the org.apache.hadoop.conf.Configuration class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: hadoop-oss   File: LdapGroupsMapping.java   View Source Code Vote up 6 votes
String getPassword(Configuration conf, String alias, String defaultPass) {
  String password = null;
  try {
    char[] passchars = conf.getPassword(alias);
    if (passchars != null) {
      password = new String(passchars);
    }
    else {
      password = defaultPass;
    }
  }
  catch (IOException ioe) {
    LOG.warn("Exception while trying to password for alias " + alias + ": "
        + ioe.getMessage());
  }
  return password;
}
 
Example 2
Project: hadoop   File: FileBasedKeyStoresFactory.java   View Source Code Vote up 6 votes
String getPassword(Configuration conf, String alias, String defaultPass) {
  String password = defaultPass;
  try {
    char[] passchars = conf.getPassword(alias);
    if (passchars != null) {
      password = new String(passchars);
    }
  }
  catch (IOException ioe) {
    LOG.warn("Exception while trying to get password for alias " + alias +
        ": " + ioe.getMessage());
  }
  return password;
}
 
Example 3
Project: hadoop   File: LdapGroupsMapping.java   View Source Code Vote up 6 votes
String getPassword(Configuration conf, String alias, String defaultPass) {
  String password = null;
  try {
    char[] passchars = conf.getPassword(alias);
    if (passchars != null) {
      password = new String(passchars);
    }
    else {
      password = defaultPass;
    }
  }
  catch (IOException ioe) {
    LOG.warn("Exception while trying to password for alias " + alias + ": "
        + ioe.getMessage());
  }
  return password;
}
 
Example 4
Project: hadoop-oss   File: FileBasedKeyStoresFactory.java   View Source Code Vote up 5 votes
String getPassword(Configuration conf, String alias, String defaultPass) {
  String password = defaultPass;
  try {
    char[] passchars = conf.getPassword(alias);
    if (passchars != null) {
      password = new String(passchars);
    }
  }
  catch (IOException ioe) {
    LOG.warn("Exception while trying to get password for alias " + alias +
        ": " + ioe.getMessage());
  }
  return password;
}
 
Example 5
Project: circus-train   File: AWSCredentialUtils.java   View Source Code Vote up 5 votes
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);
  }
}
 
Example 6
Project: hadoop   File: WebAppUtils.java   View Source Code Vote up 5 votes
/**
 * Leverages the Configuration.getPassword method to attempt to get
 * passwords from the CredentialProvider API before falling back to
 * clear text in config - if falling back is allowed.
 * @param conf Configuration instance
 * @param alias name of the credential to retreive
 * @return String credential value or null
 */
static String getPassword(Configuration conf, String alias) {
  String password = null;
  try {
    char[] passchars = conf.getPassword(alias);
    if (passchars != null) {
      password = new String(passchars);
    }
  }
  catch (IOException ioe) {
    password = null;
  }
  return password;
}
 
Example 7
Project: hadoop   File: DFSUtil.java   View Source Code Vote up 5 votes
/**
 * Leverages the Configuration.getPassword method to attempt to get
 * passwords from the CredentialProvider API before falling back to
 * clear text in config - if falling back is allowed.
 * @param conf Configuration instance
 * @param alias name of the credential to retreive
 * @return String credential value or null
 */
static String getPassword(Configuration conf, String alias) {
  String password = null;
  try {
    char[] passchars = conf.getPassword(alias);
    if (passchars != null) {
      password = new String(passchars);
    }
  }
  catch (IOException ioe) {
    password = null;
  }
  return password;
}