activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r892221 - /activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/security/SecurityContext.java
Date Fri, 18 Dec 2009 11:15:33 GMT
Author: dejanb
Date: Fri Dec 18 11:15:33 2009
New Revision: 892221

URL: http://svn.apache.org/viewvc?rev=892221&view=rev
Log:
merging 892220 - https://issues.apache.org/activemq/browse/AMQ-2508 - SecurityContext.isInOneOf()

Modified:
    activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/security/SecurityContext.java

Modified: activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/security/SecurityContext.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/security/SecurityContext.java?rev=892221&r1=892220&r2=892221&view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/security/SecurityContext.java
(original)
+++ activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/security/SecurityContext.java
Fri Dec 18 11:15:33 2009
@@ -18,6 +18,7 @@
 
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -52,9 +53,17 @@
     }
 
     public boolean isInOneOf(Set<?> allowedPrincipals) {
-        HashSet<?> set = new HashSet<Object>(getPrincipals());
-        set.retainAll(allowedPrincipals);
-        return set.size() > 0;
+    	Iterator allowedIter = allowedPrincipals.iterator();
+    	HashSet<?> userPrincipals = new HashSet<Object>(getPrincipals());
+    	while (allowedIter.hasNext()) {
+    		Iterator userIter = userPrincipals.iterator();
+    		Object allowedPrincipal = allowedIter.next(); 
+    		while (userIter.hasNext()) {
+    			if (allowedPrincipal.equals(userIter.next()))
+    				return true;
+    		}
+    	}
+    	return false;
     }
 
     public abstract Set<?> getPrincipals();



Mime
View raw message