mirror of https://github.com/apache/activemq.git
Merge pull request #602 from ikucuze/master
AMQ-8116 ActiveMQWildcardPermission buggy
This commit is contained in:
commit
33635f516f
|
@ -59,18 +59,25 @@ public class ActiveMQWildcardPermission extends WildcardPermission {
|
||||||
} else {
|
} else {
|
||||||
Set<String> thisPart = getParts().get(i);
|
Set<String> thisPart = getParts().get(i);
|
||||||
|
|
||||||
for (String token : thisPart) {
|
// all tokens from otherPart must pass at least one token from thisPart
|
||||||
if (token.equals(WILDCARD_TOKEN)) {
|
for (String otherToken : otherPart) {
|
||||||
continue;
|
if (!caseSensitive) {
|
||||||
|
otherToken = otherToken.toLowerCase();
|
||||||
}
|
}
|
||||||
for (String otherToken : otherPart) {
|
boolean otherIsMatched = false;
|
||||||
if (!caseSensitive) {
|
for (String token : thisPart) {
|
||||||
otherToken = otherToken.toLowerCase();
|
if (token.equals(WILDCARD_TOKEN)) {
|
||||||
|
otherIsMatched = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!matches(token, otherToken)) {
|
if (matches(token, otherToken)) {
|
||||||
return false;
|
otherIsMatched = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!otherIsMatched) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,10 @@ public class ActiveMQWildcardPermissionTest {
|
||||||
assertNoMatch("*:ActiveMQ*", "topic:TEST:*");
|
assertNoMatch("*:ActiveMQ*", "topic:TEST:*");
|
||||||
assertMatch("topic:ActiveMQ.Advisory*", "topic:ActiveMQ.Advisory.Connection:create");
|
assertMatch("topic:ActiveMQ.Advisory*", "topic:ActiveMQ.Advisory.Connection:create");
|
||||||
assertMatch("foo?ar", "foobar");
|
assertMatch("foo?ar", "foobar");
|
||||||
|
|
||||||
|
assertMatch("queue:*:read,write", "queue:testqueue:read");
|
||||||
|
assertMatch("queue:*:read,write", "queue:test*:read,write");
|
||||||
|
assertNoMatch("queue:*:read,write", "queue:*:read,write,delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void assertMatch(String pattern, String value) {
|
protected static void assertMatch(String pattern, String value) {
|
||||||
|
|
Loading…
Reference in New Issue