5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-17 01:11:07 +08:00

SQOOP-2283: Support usage of --exec and --password-alias

(Abraham Elmahrek via Gwen Shapira)
This commit is contained in:
Gwen Shapira 2015-04-07 19:15:59 -07:00
parent 240ec13a0d
commit d32137f15c

View File

@ -33,6 +33,7 @@
import org.apache.sqoop.accumulo.AccumuloConstants; import org.apache.sqoop.accumulo.AccumuloConstants;
import org.apache.sqoop.util.CredentialsUtil; import org.apache.sqoop.util.CredentialsUtil;
import org.apache.sqoop.util.LoggingUtils; import org.apache.sqoop.util.LoggingUtils;
import org.apache.sqoop.util.password.CredentialProviderHelper;
import org.apache.sqoop.validation.AbortOnFailureHandler; import org.apache.sqoop.validation.AbortOnFailureHandler;
import org.apache.sqoop.validation.AbsoluteValidationThreshold; import org.apache.sqoop.validation.AbsoluteValidationThreshold;
import org.apache.sqoop.validation.RowCountValidator; import org.apache.sqoop.validation.RowCountValidator;
@ -677,6 +678,16 @@ private void loadPasswordProperty(Properties props) {
} }
} }
passwordAlias = props.getProperty("db.password.alias");
if (passwordAlias != null) {
try {
setPassword(CredentialProviderHelper.resolveAlias(getConf(), passwordAlias));
return; // short-circuit
} catch (IOException e) {
throw new RuntimeException("Unable to resolve credentials.", e);
}
}
if (getBooleanProperty(props, "db.require.password", false)) { if (getBooleanProperty(props, "db.require.password", false)) {
// The user's password was stripped out from the metastore. // The user's password was stripped out from the metastore.
// Require that the user enter it now. // Require that the user enter it now.
@ -753,6 +764,11 @@ private void writePasswordProperty(Properties props) {
return; return;
} }
if (getPasswordAlias() != null) { // short-circuit
putProperty(props, "db.password.alias", getPasswordAlias());
return;
}
if (this.getConf().getBoolean( if (this.getConf().getBoolean(
METASTORE_PASSWORD_KEY, METASTORE_PASSWORD_DEFAULT)) { METASTORE_PASSWORD_KEY, METASTORE_PASSWORD_DEFAULT)) {
// If the user specifies, we may store the password in the metastore. // If the user specifies, we may store the password in the metastore.