}
if (in.hasOption(PASSWORD_PATH_ARG)) {
if (in.hasOption(PASSWORD_ARG) || in.hasOption(PASSWORD_PROMPT_ARG)
|| in.hasOption(PASSWORD_ALIAS_ARG)) {
throw new InvalidOptionsException("Only one of password, password "
+ "alias or path to a password file must be specified.");
}
try {
out.setPasswordFilePath(in.getOptionValue(PASSWORD_PATH_ARG));
// apply password from file into password in options
out.setPassword(CredentialsUtil.fetchPassword(out));
// And allow the PasswordLoader to clean up any sensitive properties
CredentialsUtil.cleanUpSensitiveProperties(out.getConf());
} catch (IOException ex) {
LOG.warn("Failed to load password file", ex);
throw (InvalidOptionsException)
new InvalidOptionsException("Error while loading password file: "
+ ex.getMessage()).initCause(ex);
}
}
if (in.hasOption(PASSWORD_ALIAS_ARG)) {
if (in.hasOption(PASSWORD_ARG) || in.hasOption(PASSWORD_PROMPT_ARG)
|| in.hasOption(PASSWORD_PATH_ARG)) {
throw new InvalidOptionsException("Only one of password, password "
+ "alias or path to a password file must be specified.");
}
out.setPasswordAlias(in.getOptionValue(PASSWORD_ALIAS_ARG));
if (!CredentialProviderHelper.isProviderAvailable()) {
throw new InvalidOptionsException(
"CredentialProvider facility not available in the hadoop "
+ " environment used");
}
try {
out.setPassword(CredentialProviderHelper
.resolveAlias(out.getConf(), in.getOptionValue(PASSWORD_ALIAS_ARG)));
} catch (IOException ioe) {
throw (InvalidOptionsException)
new InvalidOptionsException("Unable to process alias")
.initCause(ioe);
}
}
}