storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject [27/50] storm git commit: Changed plugin to clear out old credentials.
Date Thu, 13 Nov 2014 19:37:22 GMT
Changed plugin to clear out old credentials.


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

Branch: refs/heads/master
Commit: b07eff3fd86eed1fd67c1159e03d52e583b655e8
Parents: b19fdbb
Author: Robert (Bobby) Evans <evans@yahoo-inc.com>
Authored: Fri Aug 29 19:19:47 2014 +0000
Committer: Robert (Bobby) Evans <evans@yahoo-inc.com>
Committed: Fri Aug 29 19:46:54 2014 +0000

----------------------------------------------------------------------
 .../security/auth/DefaultHttpCredentialsPlugin.java     | 12 ++++++++----
 .../security/auth/DefaultHttpCredentialsPlugin_test.clj | 10 +++++-----
 2 files changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/b07eff3f/storm-core/src/jvm/backtype/storm/security/auth/DefaultHttpCredentialsPlugin.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/security/auth/DefaultHttpCredentialsPlugin.java
b/storm-core/src/jvm/backtype/storm/security/auth/DefaultHttpCredentialsPlugin.java
index 7d8e0fb..8645558 100644
--- a/storm-core/src/jvm/backtype/storm/security/auth/DefaultHttpCredentialsPlugin.java
+++ b/storm-core/src/jvm/backtype/storm/security/auth/DefaultHttpCredentialsPlugin.java
@@ -72,12 +72,16 @@ public class DefaultHttpCredentialsPlugin implements IHttpCredentialsPlugin
{
     public ReqContext populateContext(ReqContext context,
             HttpServletRequest req) {
         String userName = getUserName(req);
+        Principal p = null;
         if (userName != null) {
-            Set<SingleUserPrincipal> principals = new HashSet<SingleUserPrincipal>(1);
-            principals.add(new SingleUserPrincipal(userName));
-            Subject s = new Subject(true, principals, new HashSet(), new HashSet());
-            context.setSubject(s);
+            p = new SingleUserPrincipal(userName);
         }
+        Set<Principal> principals = new HashSet<Principal>(1);
+        if (p != null) {
+            principals.add(p);
+        }
+        Subject s = new Subject(true, principals, new HashSet(), new HashSet());
+        context.setSubject(s);
         return context;
     }
 }

http://git-wip-us.apache.org/repos/asf/storm/blob/b07eff3f/storm-core/test/clj/backtype/storm/security/auth/DefaultHttpCredentialsPlugin_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/backtype/storm/security/auth/DefaultHttpCredentialsPlugin_test.clj
b/storm-core/test/clj/backtype/storm/security/auth/DefaultHttpCredentialsPlugin_test.clj
index ab54d82..bf62a6b 100644
--- a/storm-core/test/clj/backtype/storm/security/auth/DefaultHttpCredentialsPlugin_test.clj
+++ b/storm-core/test/clj/backtype/storm/security/auth/DefaultHttpCredentialsPlugin_test.clj
@@ -2,6 +2,7 @@
   (:use [clojure test])
   (:import [javax.security.auth Subject])
   (:import [javax.servlet.http HttpServletRequest])
+  (:import [backtype.storm.security.auth SingleUserPrincipal])
   (:import [org.mockito Mockito])
   (:import [backtype.storm.security.auth DefaultHttpCredentialsPlugin
             ReqContext SingleUserPrincipal])
@@ -31,10 +32,9 @@
            thenReturn princ)
         (is (.equals exp-name (.getUserName handler req)))))))
 
-(deftest test-populate-req-context-noop-on-null-user
+(deftest test-populate-req-context-on-null-user
   (let [req (Mockito/mock HttpServletRequest)
         handler (doto (DefaultHttpCredentialsPlugin.) (.prepare {}))
-        expected-subj (Subject.)
-        context (ReqContext. expected-subj)]
-    (is (.equals expected-subj
-                 (-> handler (.populateContext context req) (.subject))))))
+        subj (Subject. false (set [(SingleUserPrincipal. "test")]) (set []) (set []))
+        context (ReqContext. subj)]
+    (is (= 0 (-> handler (.populateContext context req) (.subject) (.getPrincipals) (.size))))))


Mime
View raw message