git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@892220 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2009-12-18 11:12:32 +00:00
parent 08d89ff881
commit c6de4d7e56
1 changed files with 12 additions and 3 deletions

View File

@ -18,6 +18,7 @@ package org.apache.activemq.security;
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 abstract class SecurityContext {
}
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();