Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use LOG in ThriftServer, removed unwanted LOG from NimbusClient

  • Loading branch information...
commit 8e6934783970fb74f01e1d6909b8bdce9c9b6ec2 1 parent 2a78dc0
afeng authored
View
4 src/jvm/backtype/storm/security/auth/ThriftServer.java
@@ -13,7 +13,7 @@
private Map _storm_conf; //storm configuration
private TProcessor _processor = null;
private int _port = 0;
- private TServer _server;
+ private TServer _server = null;
private Configuration _login_conf;
public ThriftServer(Map storm_conf, TProcessor processor, int port) {
@@ -25,7 +25,7 @@ public ThriftServer(Map storm_conf, TProcessor processor, int port) {
//retrieve authentication configuration
_login_conf = AuthUtils.GetConfiguration(_storm_conf);
} catch (Exception x) {
- x.printStackTrace();
+ LOG.error(x.getMessage(), x);
}
}
View
5 src/jvm/backtype/storm/utils/NimbusClient.java
@@ -8,7 +8,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NimbusClient extends ThriftClient {
+public class NimbusClient extends ThriftClient {
private Nimbus.Client _client;
private static final Logger LOG = LoggerFactory.getLogger(NimbusClient.class);
@@ -16,10 +16,9 @@ public static NimbusClient getConfiguredClient(Map conf) {
try {
String nimbusHost = (String) conf.get(Config.NIMBUS_HOST);
int nimbusPort = Utils.getInt(conf.get(Config.NIMBUS_THRIFT_PORT));
- Integer timeout = new Integer(Utils.getInt(conf.get(Config.NIMBUS_TASK_TIMEOUT_SECS)));
+ Integer timeout = Utils.getInt(conf.get(Config.NIMBUS_TASK_TIMEOUT_SECS));
return new NimbusClient(conf, nimbusHost, nimbusPort, timeout);
} catch (TTransportException ex) {
- LOG.info(ex.getMessage(), ex);
throw new RuntimeException(ex);
}
}
View
24 test/clj/backtype/storm/security/auth/auth_test.clj
@@ -4,8 +4,10 @@
(:import [org.apache.thrift7 TException])
(:import [org.apache.thrift7.transport TTransportException])
(:import [java.nio ByteBuffer])
+ (:import [backtype.storm Config])
(:import [backtype.storm.utils NimbusClient])
- (:import [backtype.storm.security.auth ThriftServer ThriftClient ReqContext ReqContext$OperationType])
+ (:import [backtype.storm.security.auth AuthUtils ThriftServer ThriftClient
+ ReqContext ReqContext$OperationType])
(:use [backtype.storm bootstrap util])
(:use [backtype.storm.daemon common])
(:use [backtype.storm bootstrap testing])
@@ -152,15 +154,18 @@
nimbus_client (.getClient client)]
(log-message "(Positive authorization) Authorization plugin should accept client request")
(.activate nimbus_client "security_auth_test_topology")
- (.close client)))
+ (.close (.transport client))))
(deftest deny-authorization-test
(launch-server-w-wait 6629 1000 nil
"backtype.storm.security.auth.authorizer.DenyAuthorizer"
"backtype.storm.security.auth.SimpleTransportPlugin")
(let [storm-conf (merge (read-storm-config)
- {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"})
- client (NimbusClient. storm-conf "localhost" 6629 nimbus-timeout)
+ {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"
+ Config/NIMBUS_HOST "localhost"
+ Config/NIMBUS_THRIFT_PORT 6629
+ Config/NIMBUS_TASK_TIMEOUT_SECS nimbus-timeout})
+ client (NimbusClient/getConfiguredClient storm-conf)
nimbus_client (.getClient client)]
(log-message "(Negative authorization) Authorization plugin should reject client request")
(is (thrown? TTransportException
@@ -208,3 +213,14 @@
nil
(catch TTransportException ex (.getMessage ex)))))))
+ (log-message "(Negative authentication) IOException")
+ (let [storm-conf (merge (read-storm-config)
+ {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
+ "java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest_missing_client.conf"})]
+ (is (thrown? RuntimeException
+ (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout))))
+
+(deftest test-GetTransportPlugin-throws-RuntimeException
+ (let [conf (merge (read-storm-config)
+ {Config/STORM_THRIFT_TRANSPORT_PLUGIN "null.invalid"})]
+ (is (thrown? RuntimeException (AuthUtils/GetTransportPlugin conf nil)))))
View
5 test/clj/backtype/storm/security/auth/jaas_digest_missing_client.conf
@@ -0,0 +1,5 @@
+StormServer {
+ org.apache.zookeeper.server.auth.DigestLoginModule required
+ user_super="adminsecret"
+ user_bob="bobsecret";
+};
Please sign in to comment.
Something went wrong with that request. Please try again.