activemq-commits mailing list archives

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

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

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

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/security/SecurityContext.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/security/SecurityContext.java?rev=892220&r1=892219&r2=892220&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/security/SecurityContext.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/security/SecurityContext.java
Fri Dec 18 11:12:32 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