This closes #3360
This commit is contained in:
commit
ce7215c9b8
|
@ -541,8 +541,17 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
||||||
try {
|
try {
|
||||||
securityCheck(address, unPrefixedQueueName, browseOnly ? CheckType.BROWSE : CheckType.CONSUME, this);
|
securityCheck(address, unPrefixedQueueName, browseOnly ? CheckType.BROWSE : CheckType.CONSUME, this);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// this is here for backwards compatibility with the pre-FQQN syntax from ARTEMIS-592
|
/*
|
||||||
securityCheck(address.concat(".").concat(unPrefixedQueueName), queueName, browseOnly ? CheckType.BROWSE : CheckType.CONSUME, this);
|
* This is here for backwards compatibility with the pre-FQQN syntax from ARTEMIS-592.
|
||||||
|
* We only want to do this check if an exact match exists in the security-settings.
|
||||||
|
* This code is deprecated and should be removed at the release of the next major version.
|
||||||
|
*/
|
||||||
|
SimpleString exactMatch = address.concat(".").concat(unPrefixedQueueName);
|
||||||
|
if (server.getSecurityRepository().containsExactMatch(exactMatch.toString())) {
|
||||||
|
securityCheck(exactMatch, unPrefixedQueueName, browseOnly ? CheckType.BROWSE : CheckType.CONSUME, this);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Filter filter = FilterImpl.createFilter(filterString);
|
Filter filter = FilterImpl.createFilter(filterString);
|
||||||
|
|
|
@ -595,6 +595,37 @@ public class SecurityTest extends ActiveMQTestBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFallbackConsumerAuthorization() throws Exception {
|
||||||
|
final SimpleString ADDRESS = new SimpleString("a.c.b");
|
||||||
|
final SimpleString QUEUE = new SimpleString("a.c.b");
|
||||||
|
|
||||||
|
ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager("PropertiesLogin");
|
||||||
|
ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(createDefaultInVMConfig().setSecurityEnabled(true), ManagementFactory.getPlatformMBeanServer(), securityManager, false));
|
||||||
|
|
||||||
|
Set<Role> aRoles = new HashSet<>();
|
||||||
|
aRoles.add(new Role("xyz", true, true, true, true, true, true, true, true, true, true));
|
||||||
|
server.getConfiguration().putSecurityRoles("a.*.b", aRoles);
|
||||||
|
|
||||||
|
Set<Role> bRoles = new HashSet<>();
|
||||||
|
bRoles.add(new Role("amq", true, true, true, true, true, true, true, true, true, true));
|
||||||
|
server.getConfiguration().putSecurityRoles("#", bRoles);
|
||||||
|
|
||||||
|
server.start();
|
||||||
|
server.addAddressInfo(new AddressInfo(ADDRESS, RoutingType.ANYCAST));
|
||||||
|
server.createQueue(new QueueConfiguration(QUEUE).setAddress(ADDRESS).setRoutingType(RoutingType.ANYCAST));
|
||||||
|
|
||||||
|
ClientSessionFactory cf = createSessionFactory(locator);
|
||||||
|
ClientSession session = addClientSession(cf.createSession("x", "x", false, true, true, false, 0));
|
||||||
|
|
||||||
|
try {
|
||||||
|
session.createConsumer(QUEUE);
|
||||||
|
Assert.fail("should throw exception here");
|
||||||
|
} catch (ActiveMQException e) {
|
||||||
|
assertTrue(e instanceof ActiveMQSecurityException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testJAASSecurityManagerFQQNAuthorizationWithJMS() throws Exception {
|
public void testJAASSecurityManagerFQQNAuthorizationWithJMS() throws Exception {
|
||||||
final SimpleString ADDRESS = new SimpleString("address");
|
final SimpleString ADDRESS = new SimpleString("address");
|
||||||
|
|
|
@ -20,3 +20,4 @@ accounting=second
|
||||||
employees=first,second
|
employees=first,second
|
||||||
a=a
|
a=a
|
||||||
b=b
|
b=b
|
||||||
|
amq=x
|
||||||
|
|
|
@ -19,3 +19,4 @@ first=secret
|
||||||
second=password
|
second=password
|
||||||
a=a
|
a=a
|
||||||
b=b
|
b=b
|
||||||
|
x=x
|
||||||
|
|
Loading…
Reference in New Issue