STORM-741: Allow users to pass a config value to perform impersonation.

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

Branch: refs/heads/nimbus-ha-branch
Commit: bb968c8304e72d90d3d3d11c9fad66122f94dca7
Parents: 36e99fa
Author: Parth Brahmbhatt <[email protected]>
Authored: Tue Mar 31 14:24:30 2015 -0700
Committer: Parth Brahmbhatt <[email protected]>
Committed: Tue Mar 31 17:26:31 2015 -0700

----------------------------------------------------------------------
 storm-core/src/jvm/backtype/storm/Config.java             | 6 ++++++
 storm-core/src/jvm/backtype/storm/utils/NimbusClient.java | 7 +++++++
 2 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/bb968c83/storm-core/src/jvm/backtype/storm/Config.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/Config.java 
b/storm-core/src/jvm/backtype/storm/Config.java
index 9cddb2e..e6032f1 100644
--- a/storm-core/src/jvm/backtype/storm/Config.java
+++ b/storm-core/src/jvm/backtype/storm/Config.java
@@ -1228,6 +1228,12 @@ public class Config extends HashMap<String, Object> {
     public static final Object TRANSACTIONAL_ZOOKEEPER_PORT_SCHEMA = 
ConfigValidation.IntegerValidator;
 
     /**
+     * The user as which the nimbus client should be acquired to perform the 
operation.
+     */
+    public static final String STORM_DO_AS_USER="storm.doAsUser";
+    public static final Object STORM_DO_AS_USER_SCHEMA = String.class;
+
+    /**
      * The number of threads that should be used by the zeromq context in each 
worker process.
      */
     public static final String ZMQ_THREADS = "zmq.threads";

http://git-wip-us.apache.org/repos/asf/storm/blob/bb968c83/storm-core/src/jvm/backtype/storm/utils/NimbusClient.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/utils/NimbusClient.java 
b/storm-core/src/jvm/backtype/storm/utils/NimbusClient.java
index b171353..6314deb 100644
--- a/storm-core/src/jvm/backtype/storm/utils/NimbusClient.java
+++ b/storm-core/src/jvm/backtype/storm/utils/NimbusClient.java
@@ -42,6 +42,13 @@ public class NimbusClient extends ThriftClient {
 
     public static NimbusClient getConfiguredClientAs(Map conf, String asUser) {
         try {
+            if(conf.containsKey(Config.STORM_DO_AS_USER)) {
+                if(asUser != null && !asUser.isEmpty()) {
+                    LOG.warn("You have specified a doAsUser as param {} and a 
doAsParam as config, config will take precedence."
+                            , asUser, conf.get(Config.STORM_DO_AS_USER));
+                }
+                asUser = (String) conf.get(Config.STORM_DO_AS_USER);
+            }
             String nimbusHost = (String) conf.get(Config.NIMBUS_HOST);
             return new NimbusClient(conf, nimbusHost, null, null, asUser);
         } catch (TTransportException ex) {

Reply via email to