From c2f9da7dc06892f89b5b6fd7f1725c609a5e759a Mon Sep 17 00:00:00 2001 From: Marnie McCormack Date: Fri, 10 Apr 2009 15:14:29 +0000 Subject: QPID-1801 Added method to show failure to PrincipalPermissionsTest.java and then adjusted the ternary operator in PrincipalPermissions.java to ensure we don't pass a null into the map (see JIRA descriptions). git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@763959 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/server/security/access/PrincipalPermissions.java | 2 +- .../qpid/server/security/access/PrincipalPermissionsTest.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'qpid/java') diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/PrincipalPermissions.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/PrincipalPermissions.java index 35b76bcf32..f852514444 100755 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/PrincipalPermissions.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/PrincipalPermissions.java @@ -157,7 +157,7 @@ public class PrincipalPermissions AMQShortString queueName = parameters.length > 1 ? (AMQShortString) parameters[1] : null; AMQShortString exchangeName = parameters.length > 2 ? (AMQShortString) parameters[2] : null; //Set the routingkey to the specified value or the queueName if present - AMQShortString routingKey = parameters.length > 3 ? (AMQShortString) parameters[3] : queueName; + AMQShortString routingKey = (parameters.length > 3 && null != parameters[3]) ? (AMQShortString) parameters[3] : queueName; // Get the queues map Map create_queues = (Map) createRights.get(CREATE_QUEUES_KEY); diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java index 56a3783126..1ff3e5a880 100644 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java +++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java @@ -107,7 +107,16 @@ public class PrincipalPermissionsTest extends TestCase _perms.grant(Permission.CREATEQUEUE, grantArgs); assertEquals(AuthzResult.ALLOWED, _perms.authorise(Permission.CREATEQUEUE, authArgs)); } - + + public void testQueueCreateWithNullRoutingKey() + { + Object[] grantArgs = new Object[]{_temporary , _queueName, _exchangeName, null}; + Object[] authArgs = new Object[]{_autoDelete, _queueName}; + + assertEquals(AuthzResult.DENIED, _perms.authorise(Permission.CREATEQUEUE, authArgs)); + _perms.grant(Permission.CREATEQUEUE, grantArgs); + assertEquals(AuthzResult.ALLOWED, _perms.authorise(Permission.CREATEQUEUE, authArgs)); + } // FIXME disabled, this fails due to grant putting the grant into the wrong map QPID-1598 public void disableTestExchangeCreate() -- cgit v1.2.1