Skip to content

Commit e612481

Browse files
authored
Revert "Optimize SecurityContext#isInOneOf (#1874)" (#1875)
This reverts commit b404e1e. This change needs more work because DefaultAuthorizationMap requires equals() to be used the way it handles a wildcard Principal. This needs to be fixed before the change can be made
1 parent b404e1e commit e612481

2 files changed

Lines changed: 8 additions & 103 deletions

File tree

activemq-broker/src/main/java/org/apache/activemq/security/SecurityContext.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ public SecurityContext(String userName) {
5454
}
5555

5656
public boolean isInOneOf(Set<?> allowedPrincipals) {
57-
for (Object allowedPrincipal : allowedPrincipals) {
58-
if (contains(allowedPrincipal)) {
59-
return true;
57+
Iterator<?> allowedIter = allowedPrincipals.iterator();
58+
HashSet<?> userPrincipals = new HashSet<Object>(getPrincipals());
59+
while (allowedIter.hasNext()) {
60+
Iterator<?> userIter = userPrincipals.iterator();
61+
Object allowedPrincipal = allowedIter.next();
62+
while (userIter.hasNext()) {
63+
if (allowedPrincipal.equals(userIter.next()))
64+
return true;
6065
}
6166
}
6267
return false;
6368
}
6469

6570
public abstract Set<Principal> getPrincipals();
6671

67-
public boolean contains(Object principal) {
68-
Set<Principal> principals = getPrincipals();
69-
return principals != null && principals.contains(principal);
70-
}
71-
7272
public String getUserName() {
7373
return userName;
7474
}

activemq-broker/src/test/java/org/apache/activemq/security/SecurityContextTest.java

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)