Repository: sqoop
Updated Branches:
  refs/heads/trunk 240ec13a0 -> d32137f15


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

(Abraham Elmahrek via Gwen Shapira)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/d32137f1
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/d32137f1
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/d32137f1

Branch: refs/heads/trunk
Commit: d32137f15c06827dea50b293f4d422481cb374cd
Parents: 240ec13
Author: Gwen Shapira <csh...@gmail.com>
Authored: Tue Apr 7 19:15:59 2015 -0700
Committer: Gwen Shapira <csh...@gmail.com>
Committed: Tue Apr 7 19:15:59 2015 -0700

----------------------------------------------------------------------
 src/java/org/apache/sqoop/SqoopOptions.java | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/d32137f1/src/java/org/apache/sqoop/SqoopOptions.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/SqoopOptions.java 
b/src/java/org/apache/sqoop/SqoopOptions.java
index fc3d847..e4eb2f2 100644
--- a/src/java/org/apache/sqoop/SqoopOptions.java
+++ b/src/java/org/apache/sqoop/SqoopOptions.java
@@ -33,6 +33,7 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.sqoop.accumulo.AccumuloConstants;
 import org.apache.sqoop.util.CredentialsUtil;
 import org.apache.sqoop.util.LoggingUtils;
+import org.apache.sqoop.util.password.CredentialProviderHelper;
 import org.apache.sqoop.validation.AbortOnFailureHandler;
 import org.apache.sqoop.validation.AbsoluteValidationThreshold;
 import org.apache.sqoop.validation.RowCountValidator;
@@ -677,6 +678,16 @@ public class SqoopOptions implements Cloneable {
       }
     }
 
+    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)) {
       // The user's password was stripped out from the metastore.
       // Require that the user enter it now.
@@ -753,6 +764,11 @@ public class SqoopOptions implements Cloneable {
       return;
     }
 
+    if (getPasswordAlias() != null) { // short-circuit
+      putProperty(props, "db.password.alias", getPasswordAlias());
+      return;
+    }
+
     if (this.getConf().getBoolean(
       METASTORE_PASSWORD_KEY, METASTORE_PASSWORD_DEFAULT)) {
       // If the user specifies, we may store the password in the metastore.

Reply via email to