You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2016/03/07 21:29:38 UTC

[3/7] storm git commit: Addressing review comments

Addressing review comments


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

Branch: refs/heads/master
Commit: 4e04ce8dcdc33d488a3d15f7a47ab8af15136db4
Parents: cccb976
Author: Kishor Patil <kp...@yahoo-inc.com>
Authored: Wed Mar 2 10:27:56 2016 -0600
Committer: Kishor Patil <kp...@yahoo-inc.com>
Committed: Wed Mar 2 10:27:56 2016 -0600

----------------------------------------------------------------------
 conf/defaults.yaml                              |  2 +-
 .../auth/AbstractSaslServerCallbackHandler.java | 21 ++++++++++++++++++--
 .../auth/plain/PlainSaslTransportPlugin.java    | 14 +++++++------
 .../security/auth/plain/SaslPlainServer.java    |  5 ++++-
 4 files changed, 32 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/4e04ce8d/conf/defaults.yaml
----------------------------------------------------------------------
diff --git a/conf/defaults.yaml b/conf/defaults.yaml
index b32c2ff..9817161 100644
--- a/conf/defaults.yaml
+++ b/conf/defaults.yaml
@@ -39,7 +39,7 @@ storm.exhibitor.port: 8080
 storm.exhibitor.poll.uripath: "/exhibitor/v1/cluster/list"
 storm.cluster.mode: "distributed" # can be distributed or local
 storm.local.mode.zmq: false
-storm.thrift.transport: "org.apache.storm.security.auth.plain.PlainSaslTransportPlugin"
+storm.thrift.transport: "org.apache.storm.security.auth.SimpleTransportPlugin"
 storm.principal.tolocal: "org.apache.storm.security.auth.DefaultPrincipalToLocal"
 storm.group.mapping.service: "org.apache.storm.security.auth.ShellBasedGroupsMapping"
 storm.group.mapping.service.params: null

http://git-wip-us.apache.org/repos/asf/storm/blob/4e04ce8d/storm-core/src/jvm/org/apache/storm/security/auth/AbstractSaslServerCallbackHandler.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/security/auth/AbstractSaslServerCallbackHandler.java b/storm-core/src/jvm/org/apache/storm/security/auth/AbstractSaslServerCallbackHandler.java
index 0a57f93..ebbe2ea 100644
--- a/storm-core/src/jvm/org/apache/storm/security/auth/AbstractSaslServerCallbackHandler.java
+++ b/storm-core/src/jvm/org/apache/storm/security/auth/AbstractSaslServerCallbackHandler.java
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.storm.security.auth;
 
 import org.slf4j.Logger;
@@ -43,12 +60,12 @@ public abstract class AbstractSaslServerCallbackHandler implements CallbackHandl
         if (credentials.containsKey(userName) ) {
             pc.setPassword(credentials.get(userName).toCharArray());
         } else {
-            LOG.warn("No password found for user: " + userName);
+            LOG.warn("No password found for user: {}", userName);
         }
     }
 
     private void handleRealmCallback(RealmCallback rc) {
-        LOG.debug("handleRealmCallback: "+ rc.getDefaultText());
+        LOG.debug("handleRealmCallback: {}", rc.getDefaultText());
         rc.setText(rc.getDefaultText());
     }
 

http://git-wip-us.apache.org/repos/asf/storm/blob/4e04ce8d/storm-core/src/jvm/org/apache/storm/security/auth/plain/PlainSaslTransportPlugin.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/security/auth/plain/PlainSaslTransportPlugin.java b/storm-core/src/jvm/org/apache/storm/security/auth/plain/PlainSaslTransportPlugin.java
index 211a4b7..6247fe6 100644
--- a/storm-core/src/jvm/org/apache/storm/security/auth/plain/PlainSaslTransportPlugin.java
+++ b/storm-core/src/jvm/org/apache/storm/security/auth/plain/PlainSaslTransportPlugin.java
@@ -39,7 +39,9 @@ public class PlainSaslTransportPlugin extends SaslTransportPlugin {
     protected TTransportFactory getServerTransportFactory() throws IOException {
         //create an authentication callback handler
         CallbackHandler server_callback_handler = new PlainServerCallbackHandler();
-        Security.addProvider(new SaslPlainServer.SecurityProvider());
+        if (Security.getProvider(SaslPlainServer.SecurityProvider.SASL_PLAIN_SERVER) == null) {
+            Security.addProvider(new SaslPlainServer.SecurityProvider());
+        }
         //create a transport factory that will invoke our auth callback for digest
         TSaslServerTransport.Factory factory = new TSaslServerTransport.Factory();
         factory.addServerDefinition(PLAIN, AuthUtils.SERVICE, "localhost", null, server_callback_handler);
@@ -50,19 +52,19 @@ public class PlainSaslTransportPlugin extends SaslTransportPlugin {
 
     @Override
     public TTransport connect(TTransport transport, String serverHost, String asUser) throws IOException, TTransportException {
-        PlainClientCallbackHandler client_callback_handler = new PlainClientCallbackHandler();
-        TSaslClientTransport wrapper_transport = new TSaslClientTransport(PLAIN,
+        PlainClientCallbackHandler clientCallbackHandler = new PlainClientCallbackHandler();
+        TSaslClientTransport wrapperTransport = new TSaslClientTransport(PLAIN,
             null,
             AuthUtils.SERVICE,
             serverHost,
             null,
-            client_callback_handler,
+            clientCallbackHandler,
             transport);
 
-        wrapper_transport.open();
+        wrapperTransport.open();
         LOG.debug("SASL PLAIN client transport has been established");
 
-        return wrapper_transport;
+        return wrapperTransport;
 
     }
 

http://git-wip-us.apache.org/repos/asf/storm/blob/4e04ce8d/storm-core/src/jvm/org/apache/storm/security/auth/plain/SaslPlainServer.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/security/auth/plain/SaslPlainServer.java b/storm-core/src/jvm/org/apache/storm/security/auth/plain/SaslPlainServer.java
index dd2582c..c84ce77 100644
--- a/storm-core/src/jvm/org/apache/storm/security/auth/plain/SaslPlainServer.java
+++ b/storm-core/src/jvm/org/apache/storm/security/auth/plain/SaslPlainServer.java
@@ -32,8 +32,11 @@ import java.util.Map;
 public class SaslPlainServer implements SaslServer {
   @SuppressWarnings("serial")
   public static class SecurityProvider extends Provider {
+
+    public static final String SASL_PLAIN_SERVER = "SaslPlainServer";
+
     public SecurityProvider() {
-      super("SaslPlainServer", 1.0, "SASL PLAIN Authentication Server");
+      super(SASL_PLAIN_SERVER, 1.0, "SASL PLAIN Authentication Server");
       put("SaslServerFactory.PLAIN",
           SaslPlainServerFactory.class.getName());
     }