Author: timfox
Date: 2010-09-21 05:22:42 -0400 (Tue, 21 Sep 2010)
New Revision: 9704
Modified:
trunk/src/main/org/hornetq/core/deployers/impl/FileConfigurationParser.java
trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/SecurityDeployerTest.java
Log:
https://jira.jboss.org/browse/HORNETQ-501
Modified: trunk/src/main/org/hornetq/core/deployers/impl/FileConfigurationParser.java
===================================================================
--- trunk/src/main/org/hornetq/core/deployers/impl/FileConfigurationParser.java 2010-09-21
09:09:50 UTC (rev 9703)
+++ trunk/src/main/org/hornetq/core/deployers/impl/FileConfigurationParser.java 2010-09-21
09:22:42 UTC (rev 9704)
@@ -686,31 +686,31 @@
}
else if (FileConfigurationParser.CREATEDURABLEQUEUE_NAME.equals(type))
{
- createDurableQueue.add(role);
+ createDurableQueue.add(role.trim());
}
else if (FileConfigurationParser.DELETEDURABLEQUEUE_NAME.equals(type))
{
- deleteDurableQueue.add(role);
+ deleteDurableQueue.add(role.trim());
}
else if
(FileConfigurationParser.CREATE_NON_DURABLE_QUEUE_NAME.equals(type))
{
- createNonDurableQueue.add(role);
+ createNonDurableQueue.add(role.trim());
}
else if
(FileConfigurationParser.DELETE_NON_DURABLE_QUEUE_NAME.equals(type))
{
- deleteNonDurableQueue.add(role);
+ deleteNonDurableQueue.add(role.trim());
}
else if (FileConfigurationParser.CREATETEMPQUEUE_NAME.equals(type))
{
- createNonDurableQueue.add(role);
+ createNonDurableQueue.add(role.trim());
}
else if (FileConfigurationParser.DELETETEMPQUEUE_NAME.equals(type))
{
- deleteNonDurableQueue.add(role);
+ deleteNonDurableQueue.add(role.trim());
}
else if (FileConfigurationParser.MANAGE_NAME.equals(type))
{
- manageRoles.add(role);
+ manageRoles.add(role.trim());
}
if (!allRoles.contains(role.trim()))
{
Modified:
trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/SecurityDeployerTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/SecurityDeployerTest.java 2010-09-21
09:09:50 UTC (rev 9703)
+++
trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/SecurityDeployerTest.java 2010-09-21
09:22:42 UTC (rev 9704)
@@ -41,7 +41,31 @@
+ " <permission type=\"manage\"
roles=\"guest,publisher,durpublisher\"/>\n"
+ " </security-setting>";
- private final String conf2 = "<security-setting
match=\"jms.topic.testQueue\">\n" + " <permission
type=\"createNonDurableQueue\" roles=\"durpublisher\"/>\n"
+ private final String confWithWhiteSpace1 = "<security-setting
match=\"jms.topic.testTopic\">\n" +
+ " <permission type=\"createDurableQueue\" roles=\"guest,
publisher, durpublisher\"/>\n" +
+ "<permission type=\"createNonDurableQueue\" roles=\"guest,
publisher, durpublisher\"/>\n"
+ + " <permission type=\"deleteNonDurableQueue\"
roles=\"guest, publisher, durpublisher\"/>\n"
+ + " <permission
type=\"deleteDurableQueue\" roles=\"guest, publisher,
durpublisher\"/>\n"
+
+ + " <permission
type=\"consume\" roles=\"guest, publisher,
durpublisher\"/>\n"
+ + " <permission
type=\"send\" roles=\"guest, publisher, durpublisher\"/>\n"
+ + " <permission
type=\"manage\" roles=\"guest, publisher, durpublisher\"/>\n"
+ + " <permission
type=\"manage\" roles=\"guest, publisher, durpublisher\"/>\n"
+ + "
</security-setting>";
+
+ private final String confWithWhiteSpace2 = "<security-setting
match=\"jms.topic.testTopic\">\n" +
+ " <permission type=\"createDurableQueue\" roles=\"guest ,
publisher , durpublisher\"/>\n" +
+ "<permission type=\"createNonDurableQueue\" roles=\"guest ,
publisher , durpublisher\"/>\n"
+ + " <permission type=\"deleteNonDurableQueue\"
roles=\"guest , publisher , durpublisher\"/>\n"
+ + " <permission
type=\"deleteDurableQueue\" roles=\"guest , publisher ,
durpublisher\"/>\n"
+
+ + " <permission
type=\"consume\" roles=\"guest , publisher ,
durpublisher\"/>\n"
+ + " <permission
type=\"send\" roles=\"guest , publisher , durpublisher\"/>\n"
+ + " <permission
type=\"manage\" roles=\"guest , publisher ,
durpublisher\"/>\n"
+ + "
</security-setting>";
+
+ private final String conf2 = "<security-setting
match=\"jms.topic.testQueue\">\n" +
+ " <permission type=\"createNonDurableQueue\"
roles=\"durpublisher\"/>\n"
+ " <permission
type=\"deleteNonDurableQueue\" roles=\"durpublisher\"/>\n"
+ " <permission type=\"consume\"
roles=\"guest,publisher,durpublisher\"/>\n"
+ " <permission type=\"send\"
roles=\"guest,publisher,durpublisher\"/>\n"
@@ -106,7 +130,63 @@
}
}
}
+
+ public void testWithWhiteSpace1() throws Exception
+ {
+ testWithWhiteSpace(confWithWhiteSpace1);
+ }
+
+ public void testWithWhiteSpace2() throws Exception
+ {
+ testWithWhiteSpace(confWithWhiteSpace2);
+ }
+ private void testWithWhiteSpace(String conf) throws Exception
+ {
+ Element e = org.hornetq.utils.XMLUtil.stringToElement(confWithWhiteSpace1);
+ deployer.deploy(e);
+ HashSet<Role> roles =
(HashSet<Role>)repository.getMatch("jms.topic.testTopic");
+ Assert.assertNotNull(roles);
+ Assert.assertEquals(3, roles.size());
+ for (Role role : roles)
+ {
+ if (role.getName().equals("guest"))
+ {
+ Assert.assertTrue(role.isConsume());
+ Assert.assertTrue(role.isCreateDurableQueue());
+ Assert.assertTrue(role.isCreateNonDurableQueue());
+ Assert.assertTrue(role.isDeleteDurableQueue());
+ Assert.assertTrue(role.isDeleteNonDurableQueue());
+ Assert.assertTrue(role.isManage());
+ Assert.assertTrue(role.isSend());
+ }
+ else if (role.getName().equals("publisher"))
+ {
+ Assert.assertTrue(role.isConsume());
+ Assert.assertTrue(role.isCreateDurableQueue());
+ Assert.assertTrue(role.isCreateNonDurableQueue());
+ Assert.assertTrue(role.isDeleteDurableQueue());
+ Assert.assertTrue(role.isDeleteNonDurableQueue());
+ Assert.assertTrue(role.isManage());
+ Assert.assertTrue(role.isSend());
+ }
+ else if (role.getName().equals("durpublisher"))
+ {
+ Assert.assertTrue(role.isConsume());
+ Assert.assertTrue(role.isCreateDurableQueue());
+ Assert.assertTrue(role.isCreateNonDurableQueue());
+ Assert.assertTrue(role.isDeleteDurableQueue());
+ Assert.assertTrue(role.isDeleteNonDurableQueue());
+ Assert.assertTrue(role.isManage());
+ Assert.assertTrue(role.isSend());
+ }
+ else
+ {
+ Assert.fail("unexpected role");
+ }
+ }
+ }
+
public void testMultiple() throws Exception
{
deployer.deploy(org.hornetq.utils.XMLUtil.stringToElement(conf));