[jboss-cvs] JBoss Messaging SVN: r6131 - in trunk: src/main/org/jboss/messaging/core/deployers/impl and 26 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 23 05:28:20 EDT 2009


Author: ataylor
Date: 2009-03-23 05:28:19 -0400 (Mon, 23 Mar 2009)
New Revision: 6131

Added:
   trunk/tests/src/org/jboss/messaging/tests/integration/security/SecurityTest.java
Removed:
   trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/
   trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/JBossASSecurityManagerTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/SecurityStoreImplTest.java
Modified:
   trunk/src/config/jbm-cluster-standalone-beans.xml
   trunk/src/config/jbm-queues.xml
   trunk/src/config/jbm-security.xml
   trunk/src/config/jbm-standalone-beans.xml
   trunk/src/main/org/jboss/messaging/core/deployers/impl/BasicSecurityDeployer.java
   trunk/src/main/org/jboss/messaging/core/deployers/impl/SecurityDeployer.java
   trunk/src/main/org/jboss/messaging/core/management/AddressControlMBean.java
   trunk/src/main/org/jboss/messaging/core/management/RoleInfo.java
   trunk/src/main/org/jboss/messaging/core/management/impl/AddressControl.java
   trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareAddressControlWrapper.java
   trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java
   trunk/src/main/org/jboss/messaging/core/security/CheckType.java
   trunk/src/main/org/jboss/messaging/core/security/JBMUpdateableSecurityManager.java
   trunk/src/main/org/jboss/messaging/core/security/Role.java
   trunk/src/main/org/jboss/messaging/core/security/impl/JBMSecurityManagerImpl.java
   trunk/src/main/org/jboss/messaging/core/security/impl/SecurityStoreImpl.java
   trunk/src/main/org/jboss/messaging/core/server/Messaging.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
   trunk/src/main/org/jboss/messaging/integration/security/JAASSecurityManager.java
   trunk/src/main/org/jboss/messaging/integration/security/JBossASSecurityManager.java
   trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
   trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
   trunk/src/schemas/jbm-security.xsd
   trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/SecurityTest.java
   trunk/tests/jms-tests/src/org/jboss/test/messaging/thirdparty/jbosssx/SecurityAssociationTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareAddressControlWrapperTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeReconnectionTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControl2Test.java
   trunk/tests/src/org/jboss/messaging/tests/integration/management/AddressControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/management/AddressControlUsingCoreTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/management/SecurityManagementWithConfiguredAdminUserTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/paging/PageCrashTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/SecurityDeployerTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/management/RoleInfoTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/security/RoleTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/JAASSecurityManagerTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/JBMSecurityManagerImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/settings/impl/RepositoryTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossTemporaryTopicTest.java
Log:
made security fine grained and other security issues. JBMESSAGING-1535

Modified: trunk/src/config/jbm-cluster-standalone-beans.xml
===================================================================
--- trunk/src/config/jbm-cluster-standalone-beans.xml	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/config/jbm-cluster-standalone-beans.xml	2009-03-23 09:28:19 UTC (rev 6131)
@@ -29,9 +29,6 @@
    <!--<bean name="JBMSecurityManager" class="org.jboss.messaging.core.security.impl.JBossASSecurityManager"/>-->
 
    <bean name="JBMSecurityManager" class="org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl">
-      <constructor>
-         <parameter>false</parameter>  
-      </constructor>
    </bean>
 
    <bean name="BasicSecurityDeployer" class="org.jboss.messaging.core.deployers.impl.BasicSecurityDeployer">

Modified: trunk/src/config/jbm-queues.xml
===================================================================
--- trunk/src/config/jbm-queues.xml	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/config/jbm-queues.xml	2009-03-23 09:28:19 UTC (rev 6131)
@@ -5,71 +5,78 @@
    <!--  manangement address -->
    <security match="jbm.admin.management">
       <!--  only the admin role can interact with the management address  -->
-      <permission type="read" roles="admin"/>
-      <permission type="write" roles="admin"/>
+      <permission type="consume" roles="admin"/>
+      <permission type="send" roles="admin"/>
    </security>
    
    <security match="topicjms.testTopic">
-      <permission type="create" roles="durpublisher"/>
-      <permission type="read" roles="guest,publisher,durpublisher"/>
-      <permission type="write" roles="guest,publisher,durpublisher"/>
+      <permission type="createDurableQueue" roles="durpublisher"/>
+      <permission type="deleteDurableQueue" roles="durpublisher"/>
+      <permission type="consume" roles="guest,publisher,durpublisher"/>
+      <permission type="send" roles="guest,publisher,durpublisher"/>
    </security>
 
    <security match="topicjms.securedTopic">
-      <permission type="write" roles="publisher"/>
-      <permission type="read" roles="publisher"/>
+      <permission type="send" roles="publisher"/>
+      <permission type="consume" roles="publisher"/>
    </security>
 
    <security match="topicjms.testDurableTopic">
-      <permission type="create" roles="durpublisher"/>
-      <permission type="read" roles="guest,publisher,durpublisher"/>
-      <permission type="write" roles="guest,publisher,durpublisher"/>
+      <permission type="createDurableQueue" roles="durpublisher"/>
+      <permission type="deleteDurableQueue" roles="durpublisher"/>
+      <permission type="consume" roles="guest,publisher,durpublisher"/>
+      <permission type="send" roles="guest,publisher,durpublisher"/>
    </security>
 
    <security match="queuejms.testQueue">
-      <permission type="read" roles="guest,publisher"/>
-      <permission type="write" roles="guest,publisher"/>
+      <permission type="consume" roles="guest,publisher"/>
+      <permission type="send" roles="guest,publisher"/>
    </security>
 
    <security match="queuejms.NoSuchQueue">
-      <permission type="read" roles="guest,publisher"/>
-      <permission type="write" roles="guest,publisher"/>
+      <permission type="consume" roles="guest,publisher"/>
+      <permission type="send" roles="guest,publisher"/>
    </security>
 
    <security match="topicjms.NoSuchTopic">
-      <permission type="read" roles="guest,publisher"/>
-      <permission type="write" roles="guest,publisher"/>
+      <permission type="consume" roles="guest,publisher"/>
+      <permission type="send" roles="guest,publisher"/>
    </security>
 
    <security match="queuetempjms.*">
-      <permission type="create" roles="guest,def"/>
-      <permission type="read" roles="guest,def"/>
-      <permission type="write" roles="guest,def"/>
+      <permission type="createTempQueue" roles="guest,def"/>
+      <permission type="deleteTempQueue" roles="guest,def"/>
+      <permission type="consume" roles="guest,def"/>
+      <permission type="send" roles="guest,def"/>
    </security>
 
    <security match="topictempjms.*">
-      <permission type="create" roles="guest,def"/>
-      <permission type="read" roles="guest,def"/>
-      <permission type="write" roles="guest,def"/>
+      <permission type="createTempQueue" roles="guest,def"/>
+      <permission type="deleteTempQueue" roles="guest,def"/>
+      <permission type="consume" roles="guest,def"/>
+      <permission type="send" roles="guest,def"/>
    </security>
 
    <!--this will catch any word i.e. queuejms.anything-->
    <!--<security match="queuejms.#">
-      <permission type="read" roles="guest,publisher"/>
-      <permission type="write" roles="guest,publisher"/>
+      <permission type="consume" roles="guest,publisher"/>
+      <permission type="send" roles="guest,publisher"/>
    </security>-->
 
    <!--this will catch any word i.e. queuejms.anything-->
    <!--<security match="topicjms.#">
-      <permission type="read" roles="guest,publisher"/>
-      <permission type="write" roles="guest,publisher"/>
+      <permission type="consume" roles="guest,publisher"/>
+      <permission type="send" roles="guest,publisher"/>
    </security>-->
 
    <!--default security to catch all-->
    <security match="#">
-      <permission type="create" roles="guest,def"/>
-      <permission type="read" roles="guest,def"/>
-      <permission type="write" roles="guest,def"/>
+      <permission type="createDurableQueue" roles="guest,def"/>
+      <permission type="deleteDurableQueue" roles="guest,def"/>
+      <permission type="createTempQueue" roles="guest,def"/>
+      <permission type="deleteTempQueue" roles="guest,def"/>
+      <permission type="consume" roles="guest,def"/>
+      <permission type="send" roles="guest,def"/>
    </security>
 
    <address-settings match="queuejms.QueueWithOwnDLQAndExpiryQueue">

Modified: trunk/src/config/jbm-security.xml
===================================================================
--- trunk/src/config/jbm-security.xml	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/config/jbm-security.xml	2009-03-23 09:28:19 UTC (rev 6131)
@@ -1,5 +1,10 @@
-<deployment xmlns="urn:jboss:messaging" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-security.xsd ">
-      <user name="guest" password="guest">
-         <role name="guest"/>
-      </user>
+<deployment xmlns="urn:jboss:messaging" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-security.xsd ">
+   <!-- the default user.  this is used where username is null-->
+   <defaultuser name="guest" password="guest">
+      <role name="guest"/>
+   </defaultuser>
+   <!--<user name="user" password="pass">
+      <role name="role"/>
+   </user>-->
 </deployment>
\ No newline at end of file

Modified: trunk/src/config/jbm-standalone-beans.xml
===================================================================
--- trunk/src/config/jbm-standalone-beans.xml	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/config/jbm-standalone-beans.xml	2009-03-23 09:28:19 UTC (rev 6131)
@@ -27,9 +27,6 @@
    <!--<bean name="JBMSecurityManager" class="org.jboss.messaging.core.security.impl.JBossASSecurityManager"/>-->
 
    <bean name="JBMSecurityManager" class="org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl">
-      <constructor>
-         <parameter>false</parameter>  
-      </constructor>
    </bean>
 
    <bean name="BasicSecurityDeployer" class="org.jboss.messaging.core.deployers.impl.BasicSecurityDeployer">

Modified: trunk/src/main/org/jboss/messaging/core/deployers/impl/BasicSecurityDeployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/deployers/impl/BasicSecurityDeployer.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/deployers/impl/BasicSecurityDeployer.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -38,6 +38,10 @@
    private static final String ROLES_NODE = "role";
    private static final String ROLE_ATTR_NAME = "name";
 
+   private static  final String DEFAULT_USER = "defaultuser";
+
+   private static  final String USER = "user";
+
    public BasicSecurityDeployer(final DeploymentManager deploymentManager)
    {
       super(deploymentManager);
@@ -45,7 +49,7 @@
 
    public String[] getElementTagName()
    {
-      return new String[]{"user"};
+      return new String[]{DEFAULT_USER, USER};
    }
 
    @Override
@@ -60,6 +64,11 @@
       String password = node.getAttributes().getNamedItem(PASSWORD_ATTRIBUTE).getNodeValue();
       //add the user
       jbmSecurityManager.addUser(username, password);
+      String nodeName = node.getNodeName();
+      if (DEFAULT_USER.equalsIgnoreCase(nodeName))
+      {
+         jbmSecurityManager.setDefaultUser(username);
+      }
       NodeList children = node.getChildNodes();
       for (int i = 0; i < children.getLength(); i++)
       {

Modified: trunk/src/main/org/jboss/messaging/core/deployers/impl/SecurityDeployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/deployers/impl/SecurityDeployer.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/deployers/impl/SecurityDeployer.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,10 +22,6 @@
 
 package org.jboss.messaging.core.deployers.impl;
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
-
 import org.jboss.messaging.core.deployers.DeploymentManager;
 import org.jboss.messaging.core.security.Role;
 import org.jboss.messaging.core.settings.HierarchicalRepository;
@@ -33,6 +29,10 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * Deploys the security settings into a security repository and adds them to the security store.
  *
@@ -48,9 +48,13 @@
    private static final String MATCH = "match";
    private static final String SECURITY_ELEMENT_NAME = "security";
 
-   public static final String WRITE_NAME = "write";
-   public static final String READ_NAME = "read";
-   public static final String CREATE_NAME = "create";
+   public static final String SEND_NAME = "send";
+   public static final String CONSUME_NAME = "consume";
+   public static final String CREATEDURABLEQUEUE_NAME = "createDurableQueue";
+   public static final String DELETEDURABLEQUEUE_NAME = "deleteDurableQueue";
+   public static final String CREATETEMPQUEUE_NAME = "createTempQueue";
+   public static final String DELETETEMPQUEUE_NAME = "deleteTempQueue";
+   public static final String MANAGE_NAME = "manage";
 
    /**
     * The repository to add to
@@ -98,9 +102,13 @@
    public void deploy(final Node node) throws Exception
    {
       HashSet<Role> securityRoles = new HashSet<Role>();
-      ArrayList<String> create = new ArrayList<String>();
-      ArrayList<String> write = new ArrayList<String>();
-      ArrayList<String> read = new ArrayList<String>();
+      ArrayList<String> send = new ArrayList<String>();
+      ArrayList<String> consume = new ArrayList<String>();
+      ArrayList<String> createDurableQueue = new ArrayList<String>();
+      ArrayList<String> deleteDurableQueue = new ArrayList<String>();
+      ArrayList<String> createTempQueue = new ArrayList<String>();
+      ArrayList<String> deleteTempQueue = new ArrayList<String>();
+      ArrayList<String> manageRoles = new ArrayList<String>();
       ArrayList<String> allRoles = new ArrayList<String>();
       String match = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
       NodeList children = node.getChildNodes();
@@ -115,18 +123,34 @@
             String[] roles = roleString.split(",");
             for (String role : roles)
             {
-               if (CREATE_NAME.equals(type))
+               if (SEND_NAME.equals(type))
                {
-                  create.add(role.trim());
+                  send.add(role.trim());
                }
-               else if (WRITE_NAME.equals(type))
+               else if (CONSUME_NAME.equals(type))
                {
-                  write.add(role.trim());
+                  consume.add(role.trim());
                }
-               else if (READ_NAME.equals(type))
+               else if (CREATEDURABLEQUEUE_NAME.equals(type))
                {
-                  read.add(role);
+                  createDurableQueue.add(role);
                }
+               else if (DELETEDURABLEQUEUE_NAME.equals(type))
+               {
+                  deleteDurableQueue.add(role);
+               }
+               else if (CREATETEMPQUEUE_NAME.equals(type))
+               {
+                  createTempQueue.add(role);
+               }
+               else if (DELETETEMPQUEUE_NAME.equals(type))
+               {
+                  deleteTempQueue.add(role);
+               }
+               else if (MANAGE_NAME.equals(type))
+               {
+                  manageRoles.add(role);
+               }
                if (!allRoles.contains(role.trim()))
                {
                   allRoles.add(role.trim());
@@ -137,7 +161,14 @@
       }
       for (String role : allRoles)
       {
-         securityRoles.add(new Role(role, read.contains(role), write.contains(role), create.contains(role)));
+         securityRoles.add(new Role(role,
+                                    send.contains(role),
+                                    consume.contains(role),
+                                    createDurableQueue.contains(role), 
+                                    deleteDurableQueue.contains(role),
+                                    createTempQueue.contains(role),
+                                    deleteTempQueue.contains(role),
+                                    manageRoles.contains(role)));
       }
       securityRepository.addMatch(match, securityRoles);
    }

Modified: trunk/src/main/org/jboss/messaging/core/management/AddressControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/AddressControlMBean.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/management/AddressControlMBean.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -45,9 +45,13 @@
    @Operation(desc = "Add a Role to this address")
    void addRole(
          @Parameter(name = "name", desc = "Name of the role to add") String name,
-         @Parameter(name = "create", desc = "Can the user create resource?") boolean create,
-         @Parameter(name = "read", desc = "Can the user read from this address?") boolean read,
-         @Parameter(name = "write", desc = "Can the user write from this address?") boolean write)
+         @Parameter(name = "send", desc = "Can the user send to an address?") boolean send,
+         @Parameter(name = "consume", desc = "Can the user consume from this address?") boolean consume,
+         @Parameter(name = "createDurableQueue", desc = "Can the user create a durable queue?") boolean createDurableQueue,
+         @Parameter(name = "deleteDurableQueue", desc = "Can the user delete a durable queue?") boolean deleteDurableQueue,
+         @Parameter(name = "createTempQueue", desc = "Can the user create a temp queue?") boolean createTempQueue,
+         @Parameter(name = "deleteTempQueue", desc = "Can the user delete a temp queue?") boolean deleteTempQueue,
+         @Parameter(name = "manage", desc = "Can the user send management messages?") boolean manage)
          throws Exception;
 
    @Operation(desc = "Remove a Role from this address")

Modified: trunk/src/main/org/jboss/messaging/core/management/RoleInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/RoleInfo.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/management/RoleInfo.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,21 +22,19 @@
 
 package org.jboss.messaging.core.management;
 
-import static javax.management.openmbean.SimpleType.BOOLEAN;
-import static javax.management.openmbean.SimpleType.STRING;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
 import javax.management.openmbean.CompositeData;
 import javax.management.openmbean.CompositeDataSupport;
 import javax.management.openmbean.CompositeType;
 import javax.management.openmbean.OpenDataException;
 import javax.management.openmbean.OpenType;
+import static javax.management.openmbean.SimpleType.BOOLEAN;
+import static javax.management.openmbean.SimpleType.STRING;
 import javax.management.openmbean.TabularData;
 import javax.management.openmbean.TabularDataSupport;
 import javax.management.openmbean.TabularType;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -52,13 +50,17 @@
    private static final String ROLE_TYPE_NAME = "RoleInfo";
    private static final String ROLE_TABULAR_TYPE_NAME = "RoleTabularInfo";
    private static final TabularType TABULAR_TYPE;
-   private static final String[] ITEM_NAMES = new String[] { "name", "create",
-         "read", "write" };
+   private static final String[] ITEM_NAMES = new String[] { "name", "send",
+         "consume", "createDurableQueue", "deleteDurableQueue", "createTempQueue", "deleteTempQueue", "manage" };
    private static final String[] ITEM_DESCRIPTIONS = new String[] {
-         "Name of the role", "Can the role create?", "Can the role read?",
-         "Can the role write?" };
+         "Name of the role", "Can the role send messages?", "Can the role consume messages?",
+         "Can the role create a durable queue (needed for durable subscribers)?",
+         "Can the role delete a durable queue (needed for durable subscribers)?",
+         "Can the role create a temp queue?",
+         "Can the role create a temp queue?",
+         "Can the user send management messages"};
    private static final OpenType[] ITEM_TYPES = new OpenType[] { STRING,
-         BOOLEAN, BOOLEAN, BOOLEAN };
+         BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN };
 
    static
    {
@@ -77,10 +79,22 @@
    // Attributes ----------------------------------------------------
 
    private final String name;
-   private final boolean create;
-   private final boolean read;
-   private final boolean write;
 
+   final private boolean send;
+
+   final private boolean consume;
+
+   final private boolean createDurableQueue;
+
+   final private boolean deleteDurableQueue;
+
+   final private boolean createTempQueue;
+
+   final private boolean deleteTempQueue;
+
+   final private boolean manage;
+
+
    // Static --------------------------------------------------------
 
    public static TabularData toTabularData(RoleInfo[] infos)
@@ -101,10 +115,14 @@
       {
          CompositeData compositeData = (CompositeData) object;
          String name = (String) compositeData.get("name");
-         boolean create = (Boolean) compositeData.get("create");
-         boolean read = (Boolean) compositeData.get("read");
-         boolean write = (Boolean) compositeData.get("write");
-         infos.add(new RoleInfo(name, create, read, write));
+         boolean send = (Boolean) compositeData.get("send");
+         boolean consume = (Boolean) compositeData.get("consume");
+         boolean createDurableQueue = (Boolean) compositeData.get("createDurableQueue");
+         boolean deleteDurableQueue = (Boolean) compositeData.get("deleteDurableQueue");
+         boolean createTempQueue = (Boolean) compositeData.get("createTempQueue");
+         boolean deleteTempQueue = (Boolean) compositeData.get("deleteTempQueue");
+         boolean manage = (Boolean) compositeData.get("manage");
+         infos.add(new RoleInfo(name, send, consume, createDurableQueue, deleteDurableQueue, createTempQueue, deleteTempQueue, manage));
       }
 
       return (RoleInfo[]) infos.toArray(new RoleInfo[infos.size()]);
@@ -112,12 +130,17 @@
    
    // Constructors --------------------------------------------------
 
-   public RoleInfo(String name, boolean create, boolean read, boolean write)
+
+   public RoleInfo(String name, boolean send, boolean consume, boolean createDurableQueue, boolean deleteDurableQueue, boolean createTempQueue, boolean deleteTempQueue, boolean manage)
    {
       this.name = name;
-      this.create = create;
-      this.read = read;
-      this.write = write;
+      this.send = send;
+      this.consume = consume;
+      this.createDurableQueue = createDurableQueue;
+      this.deleteDurableQueue = deleteDurableQueue;
+      this.createTempQueue = createTempQueue;
+      this.deleteTempQueue = deleteTempQueue;
+      this.manage = manage;
    }
 
    // Public --------------------------------------------------------
@@ -127,27 +150,47 @@
       return name;
    }
 
-   public boolean isCreate()
+   public boolean isSend()
    {
-      return create;
+      return send;
    }
 
-   public boolean isRead()
+   public boolean isConsume()
    {
-      return read;
+      return consume;
    }
 
-   public boolean isWrite()
+   public boolean isCreateDurableQueue()
    {
-      return write;
+      return createDurableQueue;
    }
 
+   public boolean isDeleteDurableQueue()
+   {
+      return deleteDurableQueue;
+   }
+
+   public boolean isCreateTempQueue()
+   {
+      return createTempQueue;
+   }
+
+   public boolean isDeleteTempQueue()
+   {
+      return deleteTempQueue;
+   }
+
+   public boolean isManage()
+   {
+      return manage;
+   }
+
    public CompositeData toCompositeData()
    {
       try
       {
          return new CompositeDataSupport(TYPE, ITEM_NAMES, new Object[] { name,
-               create, read, write });
+               send, consume, createDurableQueue, deleteDurableQueue, createTempQueue, deleteTempQueue, manage });
       } catch (OpenDataException e)
       {
          return null;
@@ -157,8 +200,14 @@
    @Override
    public String toString()
    {
-      return "RoleInfo[name=" + name + ", create=" + create + ", read=" + read
-            + ", write=" + write + "]";
+       return "RolInfoe {name=" + name + ";" +
+             "read=" + send + ";" +
+             "write=" + consume + ";" +
+             "createDurableQueue=" + createDurableQueue + "}" +
+            "deleteDurableQueue=" + deleteDurableQueue + "}" +
+            "createTempQueue=" + createTempQueue + "}" +
+            "deleteTempQueue=" + deleteTempQueue + "}" +
+            "manage=" + manage + "}";
    }
 
    // Package protected ---------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/management/impl/AddressControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/AddressControl.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/AddressControl.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,11 +22,6 @@
 
 package org.jboss.messaging.core.management.impl;
 
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.management.openmbean.TabularData;
-
 import org.jboss.messaging.core.management.AddressControlMBean;
 import org.jboss.messaging.core.management.RoleInfo;
 import org.jboss.messaging.core.postoffice.Binding;
@@ -37,6 +32,10 @@
 import org.jboss.messaging.core.settings.HierarchicalRepository;
 import org.jboss.messaging.utils.SimpleString;
 
+import javax.management.openmbean.TabularData;
+import java.util.Iterator;
+import java.util.Set;
+
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  * 
@@ -105,17 +104,28 @@
       for (Role role : roles)
       {
          roleInfos[i++] = new RoleInfo(role.getName(),
-                                       role.isCheckType(CheckType.CREATE),
-                                       role.isCheckType(CheckType.READ),
-                                       role.isCheckType(CheckType.WRITE));
+                                       CheckType.SEND.hasRole(role),
+                                       CheckType.CONSUME.hasRole(role),
+                                       CheckType.CREATE_DURABLE_QUEUE.hasRole(role),
+                                       CheckType.DELETE_DURABLE_QUEUE.hasRole(role),
+                                       CheckType.CREATE_TEMP_QUEUE.hasRole(role),
+                                       CheckType.DELETE_TEMP_QUEUE.hasRole(role),
+                                       CheckType.MANAGE.hasRole(role));
       }
       return RoleInfo.toTabularData(roleInfos);
    }
 
-   public synchronized void addRole(final String name, final boolean create, final boolean read, final boolean write) throws Exception
+   public synchronized void addRole(final String name,
+                                    final boolean send,
+                                    final boolean consume,
+                                    final boolean createDurableQueue,
+                                    final boolean deleteDurableQueue,
+                                    final boolean createTempQueue,
+                                    final boolean deleteTempQueue,
+                                    final boolean manage) throws Exception
    {
       Set<Role> roles = securityRepository.getMatch(address.toString());
-      Role newRole = new Role(name, read, write, create);
+      Role newRole = new Role(name, send, consume, createDurableQueue, deleteDurableQueue, createTempQueue, deleteTempQueue, manage);
       boolean added = roles.add(newRole);
       if (!added)
       {

Modified: trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareAddressControlWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareAddressControlWrapper.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareAddressControlWrapper.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,16 +22,15 @@
 
 package org.jboss.messaging.core.management.jmx.impl;
 
-import javax.management.MBeanInfo;
-import javax.management.ObjectName;
-import javax.management.openmbean.TabularData;
-
 import org.jboss.messaging.core.management.AddressControlMBean;
 import org.jboss.messaging.core.management.ReplicationOperationInvoker;
-import org.jboss.messaging.core.management.RoleInfo;
 import org.jboss.messaging.core.management.impl.AddressControl;
 import org.jboss.messaging.core.management.impl.MBeanInfoHelper;
 
+import javax.management.MBeanInfo;
+import javax.management.ObjectName;
+import javax.management.openmbean.TabularData;
+
 /**
  * A ReplicationAwareAddressControlWrapper
  *
@@ -82,9 +81,16 @@
       replicationAwareInvoke("removeRole", name);
    }
 
-   public void addRole(final String name, final boolean create, final boolean read, final boolean write) throws Exception
+   public void addRole(final String name,
+                                    final boolean send,
+                                    final boolean consume,
+                                    final boolean createDurableQueue,
+                                    final boolean deleteDurableQueue,
+                                    final boolean createTempQueue,
+                                    final boolean deleteTempQueue,
+                                    final boolean manage) throws Exception
    {
-      replicationAwareInvoke("addRole", name, create, read, write);
+      replicationAwareInvoke("addRole", name, send, consume, createDurableQueue, deleteDurableQueue, createTempQueue, deleteTempQueue, manage);
    }
 
    // StandardMBean overrides ---------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -12,16 +12,6 @@
 
 package org.jboss.messaging.core.remoting.server.impl;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ConcurrentHashMap;
-
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.config.TransportConfiguration;
 import org.jboss.messaging.core.exception.MessagingException;
@@ -44,6 +34,16 @@
 import org.jboss.messaging.core.server.MessagingServer;
 import org.jboss.messaging.core.server.impl.MessagingServerPacketHandler;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
+
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  * @author <a href="mailto:ataylor at redhat.com">Andy Taylor</a>
@@ -270,7 +270,6 @@
    public void connectionDestroyed(final Object connectionID)
    {
       RemotingConnection conn = connections.remove(connectionID);
-   
       if (conn != null)
       {
          conn.destroy();

Modified: trunk/src/main/org/jboss/messaging/core/security/CheckType.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/security/CheckType.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/security/CheckType.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -18,20 +18,28 @@
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
+ */
 
 package org.jboss.messaging.core.security;
 
 /**
- * 
  * @author Peter Antman
  * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * @author <a href="mailto:andy.taylor at jboss.org>Andy Taylor</a>
  * @version $Revision: 2925 $
- *
- * $Id: $
+ *          <p/>
+ *          $Id: $
  */
 public enum CheckType
-{	
-   READ, WRITE, CREATE;   
+{
+   SEND {public boolean hasRole(final Role role) { return role.isSend();}},
+   CONSUME {public boolean hasRole(final Role role) { return role.isConsume();}},
+   CREATE_DURABLE_QUEUE {public boolean hasRole(final Role role) { return role.isCreateDurableQueue();}},
+   DELETE_DURABLE_QUEUE {public boolean hasRole(final Role role) { return role.isDeleteDurableQueue();}},
+   CREATE_TEMP_QUEUE {public boolean hasRole(final Role role) { return role.isCreateTempQueue();}},
+   DELETE_TEMP_QUEUE {public boolean hasRole(final Role role) { return role.isDeleteTempQueue();}},
+   MANAGE {public boolean hasRole(final Role role) { return role.isManage();}};
+
+   public abstract boolean hasRole(final Role role);
 }

Modified: trunk/src/main/org/jboss/messaging/core/security/JBMUpdateableSecurityManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/security/JBMUpdateableSecurityManager.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/security/JBMUpdateableSecurityManager.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -55,4 +55,9 @@
     * @param role the role to remove
     */
    void removeRole(String user, String role);
+
+   /*
+   * set the default user for null users
+   */
+   void setDefaultUser(String username);
 }

Modified: trunk/src/main/org/jboss/messaging/core/security/Role.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/security/Role.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/security/Role.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -33,53 +33,134 @@
 {
    private static final long serialVersionUID = 3560097227776448872L;
 
-   private String name;
+   final private String name;
 
-   private boolean read = false;
+   final private boolean send;
 
-   private boolean write = false;
+   final private boolean consume;
 
-   private boolean create = false;
+   final private boolean createDurableQueue;
 
-   public Role(final String name)
-   {
-      this.name = name;
-   }
+   final private boolean deleteDurableQueue;
 
-   public Role(final String name, final boolean read, final boolean write, final boolean create)
+   final private boolean createTempQueue;
+
+   final private boolean deleteTempQueue;
+
+   final private boolean manage;
+
+   public Role(final String name,
+               final boolean send,
+               final boolean consume,
+               final boolean createDurableQueue,
+               final boolean deleteDurableQueue,
+               final boolean createTempQueue,
+               final boolean deleteTempQueue,
+               boolean manage)
    {
+      if(name == null)
+      {
+         throw new NullPointerException("name is null");
+      }
       this.name = name;
-      this.read = read;
-      this.write = write;
-      this.create = create;
+      this.send = send;
+      this.consume = consume;
+      this.createDurableQueue = createDurableQueue;
+      this.deleteDurableQueue = deleteDurableQueue;
+      this.createTempQueue = createTempQueue;
+      this.deleteTempQueue = deleteTempQueue;
+      this.manage = manage;
    }
 
+
    public String getName()
    {
       return name;
    }
 
-   public boolean isCheckType(final CheckType checkType)
+
+   public boolean isSend()
    {
-      return checkType.equals(CheckType.READ) ? read : checkType.equals(CheckType.WRITE) ? write : create;
+      return send;
    }
 
+   public boolean isConsume()
+   {
+      return consume;
+   }
+
+   public boolean isCreateDurableQueue()
+   {
+      return createDurableQueue;
+   }
+
+   public boolean isDeleteDurableQueue()
+   {
+      return deleteDurableQueue;
+   }
+
+   public boolean isCreateTempQueue()
+   {
+      return createTempQueue;
+   }
+
+   public boolean isDeleteTempQueue()
+   {
+      return deleteTempQueue;
+   }
+
    public String toString()
    {
-      return "Role {name=" + name + ";read=" + read + ";write=" + write + ";create=" + create + "}";
+      return "Role {name=" + name + ";" +
+             "read=" + send + ";" +
+             "write=" + consume + ";" +
+             "createDurableQueue=" + createDurableQueue + "}" +
+            "deleteDurableQueue=" + deleteDurableQueue + "}" +
+            "createTempQueue=" + createTempQueue + "}" +
+            "deleteTempQueue=" + deleteTempQueue + "}";
    }
 
    public boolean equals(Object o)
    {
-      if (this == o) return true;
-      if (o == null || getClass() != o.getClass()) return false;
+      if (this == o)
+      {
+         return true;
+      }
+      if (o == null || getClass() != o.getClass())
+      {
+         return false;
+      }
 
       Role role = (Role) o;
 
-      if (create != role.create) return false;
-      if (read != role.read) return false;
-      if (write != role.write) return false;
-      if (!name.equals(role.name)) return false;
+      if (consume != role.consume)
+      {
+         return false;
+      }
+      if (createDurableQueue != role.createDurableQueue)
+      {
+         return false;
+      }
+      if (createTempQueue != role.createTempQueue)
+      {
+         return false;
+      }
+      if (deleteDurableQueue != role.deleteDurableQueue)
+      {
+         return false;
+      }
+      if (deleteTempQueue != role.deleteTempQueue)
+      {
+         return false;
+      }
+      if (send != role.send)
+      {
+         return false;
+      }
+      if (!name.equals(role.name))
+      {
+         return false;
+      }
 
       return true;
    }
@@ -88,9 +169,17 @@
    {
       int result;
       result = name.hashCode();
-      result = 31 * result + (read ? 1 : 0);
-      result = 31 * result + (write ? 1 : 0);
-      result = 31 * result + (create ? 1 : 0);
+      result = 31 * result + (send ? 1 : 0);
+      result = 31 * result + (consume ? 1 : 0);
+      result = 31 * result + (createDurableQueue ? 1 : 0);
+      result = 31 * result + (deleteDurableQueue ? 1 : 0);
+      result = 31 * result + (createTempQueue ? 1 : 0);
+      result = 31 * result + (deleteTempQueue ? 1 : 0);
       return result;
    }
+
+   public boolean isManage()
+   {
+      return manage;
+   }
 }

Modified: trunk/src/main/org/jboss/messaging/core/security/impl/JBMSecurityManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/security/impl/JBMSecurityManagerImpl.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/security/impl/JBMSecurityManagerImpl.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,17 +22,17 @@
 
 package org.jboss.messaging.core.security.impl;
 
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.security.CheckType;
+import org.jboss.messaging.core.security.JBMUpdateableSecurityManager;
+import org.jboss.messaging.core.security.Role;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.security.CheckType;
-import org.jboss.messaging.core.security.JBMUpdateableSecurityManager;
-import org.jboss.messaging.core.security.Role;
-
 /**
  * A basic implementation of the JBMUpdateableSecurityManager. This can be used within an appserver and be deployed by
  * BasicSecurityDeployer or used standalone or embedded.
@@ -52,41 +52,41 @@
     */
    private Map<String, User> users = new HashMap<String, User>();
 
+   private String defaultUser = null;
+
    /**
     * the roles for the users
     */
    private Map<String, List<String>> roles = new HashMap<String, List<String>>();
 
-   public JBMSecurityManagerImpl(final boolean addGuestRole)
+
+   public boolean validateUser(final String user, final String password)
    {
-      if (addGuestRole)
+      if(user == null && defaultUser == null)
       {
-         //add some default roles!!
-         users.put("guest", new User("guest", "guest"));
-         ArrayList<String> roles = new ArrayList<String>();
-         roles.add("guest");
-         this.roles.put("guest", roles);
+         return false;
       }
-   }
+      User theUser = users.get(user == null ? defaultUser : user);
+      return theUser != null && theUser.isValid(user == null ? defaultUser : user, password == null ? defaultUser : password);
 
-   public boolean validateUser(final String user, final String password)
-   {
-      User theUser = users.get(user == null ? "guest" : user);
-      return theUser != null && theUser.isValid(user == null ? "guest" : user, password == null ? "guest" : password);
    }
 
    public boolean validateUserAndRole(final String user, final String password, final Set<Role> roles, final CheckType checkType)
    {
       if (validateUser(user, password))
       {
-         List<String> availableRoles = this.roles.get(user == null ? "guest" : user);
+         List<String> availableRoles = this.roles.get(user == null ? defaultUser : user);
+         if(availableRoles == null)
+         {
+            return false;
+         }
          for (String availableRole : availableRoles)
          {
             if (roles != null)
             {
                for (Role role : roles)
                {
-                  if (role.getName().equals(availableRole) && role.isCheckType(checkType))
+                  if (role.getName().equals(availableRole) && checkType.hasRole(role))
                   {
                      return true;
                   }
@@ -134,6 +134,14 @@
       roles.get(user).remove(role);
    }
 
+   /*
+   * set the default user for null users
+   */
+   public void setDefaultUser(String username)
+   {
+      defaultUser = username;
+   }
+
    static class User
    {
       final String user;
@@ -168,8 +176,7 @@
          {
             return false;
          }
-         return user.equals(this.user) && password
-                 .equals(this.password);
+         return this.user.equals(user) && this.password.equals(password);
       }
    }
 }

Modified: trunk/src/main/org/jboss/messaging/core/security/impl/SecurityStoreImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/security/impl/SecurityStoreImpl.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/security/impl/SecurityStoreImpl.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -23,9 +23,6 @@
 package org.jboss.messaging.core.security.impl;
 
 import static org.jboss.messaging.core.config.impl.ConfigurationImpl.DEFAULT_MANAGEMENT_CLUSTER_PASSWORD;
-
-import java.util.Set;
-
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.security.CheckType;
@@ -35,8 +32,13 @@
 import org.jboss.messaging.core.server.ServerSession;
 import org.jboss.messaging.core.settings.HierarchicalRepository;
 import org.jboss.messaging.core.settings.HierarchicalRepositoryChangeListener;
+import org.jboss.messaging.utils.ConcurrentHashSet;
 import org.jboss.messaging.utils.SimpleString;
 
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
 /**
  * The JBM SecurityStore implementation
  *
@@ -71,12 +73,8 @@
 
    private JBMSecurityManager securityManager;
 
-   private final Set<SimpleString> readCache = new org.jboss.messaging.utils.ConcurrentHashSet<SimpleString>();
+   private final ConcurrentMap<CheckType, ConcurrentHashSet<SimpleString>> cache = new ConcurrentHashMap<CheckType, ConcurrentHashSet<SimpleString>>();
 
-   private final Set<SimpleString> writeCache = new org.jboss.messaging.utils.ConcurrentHashSet<SimpleString>();
-
-   private final Set<SimpleString> createCache = new org.jboss.messaging.utils.ConcurrentHashSet<SimpleString>();
-
    private final long invalidationInterval;
 
    private volatile long lastCheck;
@@ -151,29 +149,14 @@
              throw new MessagingException(MessagingException.SECURITY_EXCEPTION, "Unable to validate user: " + session.getUsername());
          }
          // if we get here we're granted, add to the cache
-   
-         switch (checkType)
+         ConcurrentHashSet<SimpleString> set = new ConcurrentHashSet<SimpleString>();
+         ConcurrentHashSet<SimpleString> act = cache.putIfAbsent(checkType, set);
+         if(act != null)
          {
-            case READ:
-            {
-               readCache.add(address);
-               break;
-            }
-            case WRITE:
-            {
-               writeCache.add(address);
-               break;
-            }
-            case CREATE:
-            {
-               createCache.add(address);
-               break;
-            }
-            default:
-            {
-               throw new IllegalArgumentException("Invalid checkType:" + checkType);
-            }
+            set = act;
          }
+         set.add(address);
+
       }
    }
 
@@ -209,11 +192,7 @@
    // Private -------------------------------------------------------
    private void invalidateCache()
    {
-      readCache.clear();
-
-      writeCache.clear();
-
-      createCache.clear();
+      cache.clear();
    }
 
    private boolean checkCached(final SimpleString dest, final CheckType checkType)
@@ -228,27 +207,10 @@
       }
       else
       {
-         switch (checkType)
+         ConcurrentHashSet<SimpleString> act = cache.get(checkType);
+         if(act != null)
          {
-            case READ:
-            {
-               granted = readCache.contains(dest);
-               break;
-            }
-            case WRITE:
-            {
-               granted = writeCache.contains(dest);
-               break;
-            }
-            case CREATE:
-            {
-               granted = createCache.contains(dest);
-               break;
-            }
-            default:
-            {
-               throw new IllegalArgumentException("Invalid checkType:" + checkType);
-            }
+            granted = act.contains(dest);
          }
       }
 

Modified: trunk/src/main/org/jboss/messaging/core/server/Messaging.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/Messaging.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/server/Messaging.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -23,10 +23,6 @@
 
 package org.jboss.messaging.core.server;
 
-import java.lang.management.ManagementFactory;
-
-import javax.management.MBeanServer;
-
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
 import org.jboss.messaging.core.management.ManagementService;
@@ -41,6 +37,9 @@
 import org.jboss.messaging.core.server.impl.MessagingServerImpl;
 import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
 
+import javax.management.MBeanServer;
+import java.lang.management.ManagementFactory;
+
 /**
  * A Messaging
  *
@@ -63,7 +62,7 @@
 
       RemotingService remotingService = new RemotingServiceImpl(config);
 
-      JBMSecurityManager securityManager = new JBMSecurityManagerImpl(true);
+      JBMSecurityManager securityManager = new JBMSecurityManagerImpl();
 
       ManagementService managementService = new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(),
                                                                       config.isJMXManagementEnabled());
@@ -89,7 +88,7 @@
    {
       RemotingService remotingService = new RemotingServiceImpl(config);
 
-      JBMSecurityManager securityManager = new JBMSecurityManagerImpl(true);
+      JBMSecurityManager securityManager = new JBMSecurityManagerImpl();
 
       ManagementService managementService = new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(),
                                                                       config.isJMXManagementEnabled());
@@ -117,7 +116,7 @@
 
       RemotingService remotingService = new RemotingServiceImpl(config);
 
-      JBMSecurityManager securityManager = new JBMSecurityManagerImpl(true);
+      JBMSecurityManager securityManager = new JBMSecurityManagerImpl();
 
       ManagementService managementService = new ManagementServiceImpl(mbeanServer,
                                                                       config.isJMXManagementEnabled());
@@ -145,7 +144,7 @@
 
       RemotingService remotingService = new RemotingServiceImpl(config);
 
-      JBMSecurityManager securityManager = new JBMSecurityManagerImpl(true);
+      JBMSecurityManager securityManager = new JBMSecurityManagerImpl();
 
       ManagementService managementService = new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(), false);
 

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -11,20 +11,6 @@
 
 package org.jboss.messaging.core.server.impl;
 
-import static org.jboss.messaging.core.management.NotificationType.CONSUMER_CREATED;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executor;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
 import org.jboss.messaging.core.buffers.ChannelBuffers;
 import org.jboss.messaging.core.client.impl.ClientMessageImpl;
 import org.jboss.messaging.core.client.management.impl.ManagementHelper;
@@ -34,7 +20,7 @@
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.management.ManagementService;
 import org.jboss.messaging.core.management.Notification;
-import org.jboss.messaging.core.message.Message;
+import static org.jboss.messaging.core.management.NotificationType.CONSUMER_CREATED;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.Binding;
 import org.jboss.messaging.core.postoffice.BindingType;
@@ -97,6 +83,17 @@
 import org.jboss.messaging.utils.SimpleString;
 import org.jboss.messaging.utils.TypedProperties;
 
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executor;
+
 /*
  * Session implementation 
  * 
@@ -1192,7 +1189,7 @@
             throw new MessagingException(MessagingException.QUEUE_DOES_NOT_EXIST);
          }
 
-         securityStore.check(binding.getAddress(), CheckType.READ, this);
+         securityStore.check(binding.getAddress(), CheckType.CONSUME, this);
 
          Filter filter = null;
 
@@ -1303,16 +1300,15 @@
 
       try
       {
-         // FIXME: https://jira.jboss.org/jira/browse/JBMESSAGING-1535
          if (temporary)
          {
             // make sure the user has privileges to create this queue
-            securityStore.check(address, CheckType.READ, this);
+            securityStore.check(address, CheckType.CREATE_TEMP_QUEUE, this);
          }
-         else
+         if (durable)
          {
             // make sure the user has privileges to create this queue
-            securityStore.check(address, CheckType.CREATE, this);
+            securityStore.check(address, CheckType.CREATE_DURABLE_QUEUE, this);
          }
 
          Binding binding = postOffice.getBinding(name);
@@ -1408,7 +1404,16 @@
          {
             throw new MessagingException(MessagingException.ILLEGAL_STATE, "Cannot delete queue - it has consumers");
          }
-
+         if (queue.isDurable())
+         {
+            // make sure the user has privileges to delete this queue
+            securityStore.check(binding.getAddress(), CheckType.DELETE_DURABLE_QUEUE, this);
+         }
+         if (queue.isTemporary())
+         {
+            // make sure the user has privileges to delete this queue
+            securityStore.check(binding.getAddress(), CheckType.DELETE_TEMP_QUEUE, this);
+         }
          queue.deleteAllReferences();
 
          if (queue.isDurable())
@@ -2409,7 +2414,18 @@
 
    private void handleManagementMessage(final ServerMessage message) throws Exception
    {
-      doSecurity(message);
+      try
+      {
+         securityStore.check(message.getDestination(), CheckType.MANAGE, this);
+      }
+      catch (MessagingException e)
+      {
+         if (!autoCommitSends)
+         {
+            tx.markAsRollbackOnly(e);
+         }
+         throw e;
+      }
 
       ServerMessage reply = managementService.handleMessage(message);
 
@@ -2486,7 +2502,18 @@
    private void send(final ServerMessage msg) throws Exception
    {
       // check the user has write access to this address.
-      doSecurity(msg);
+      try
+      {
+         securityStore.check(msg.getDestination(), CheckType.SEND, this);
+      }
+      catch (MessagingException e)
+      {
+         if (!autoCommitSends)
+         {
+            tx.markAsRollbackOnly(e);
+         }
+         throw e;
+      }
 
       if (tx == null || autoCommitSends)
       {
@@ -2502,7 +2529,7 @@
    {
       try
       {
-         securityStore.check(msg.getDestination(), CheckType.WRITE, this);
+         securityStore.check(msg.getDestination(), CheckType.SEND, this);
       }
       catch (MessagingException e)
       {

Modified: trunk/src/main/org/jboss/messaging/integration/security/JAASSecurityManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/security/JAASSecurityManager.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/integration/security/JAASSecurityManager.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,28 +22,23 @@
 
 package org.jboss.messaging.integration.security;
 
-import static org.jboss.messaging.core.security.CheckType.CREATE;
-import static org.jboss.messaging.core.security.CheckType.READ;
-import static org.jboss.messaging.core.security.CheckType.WRITE;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.security.CheckType;
+import org.jboss.messaging.core.security.JBMSecurityManager;
+import org.jboss.messaging.core.security.Role;
+import org.jboss.messaging.core.server.MessagingComponent;
 
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
 import java.security.Principal;
 import java.security.acl.Group;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
-import javax.security.auth.Subject;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.login.Configuration;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.security.CheckType;
-import org.jboss.messaging.core.security.JBMSecurityManager;
-import org.jboss.messaging.core.security.Role;
-import org.jboss.messaging.core.server.MessagingComponent;
-
 /**
  * This implementation delegates to the JAAS security interfaces.
  * 
@@ -181,7 +176,10 @@
 
       Subject subject = new Subject();
 
-      subject.getPrincipals().add(principal);
+      if(user != null)
+      {
+         subject.getPrincipals().add(principal);
+      }
       subject.getPrivateCredentials().add(passwordChars);
 
       LoginContext lc = new LoginContext(configurationName, subject, callbackHandler, config);
@@ -211,9 +209,7 @@
       Set<Principal> principals = new HashSet<Principal>();
       for (Role role : roles)
       {
-         if ((checkType.equals(CREATE) && role.isCheckType(CREATE))
-          || (checkType.equals(WRITE) && role.isCheckType(WRITE))
-          || (checkType.equals(READ) && role.isCheckType(READ)))
+         if (checkType.hasRole(role))
          {
             principals.add(new SimplePrincipal(role.getName()));
          }

Modified: trunk/src/main/org/jboss/messaging/integration/security/JBossASSecurityManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/security/JBossASSecurityManager.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/integration/security/JBossASSecurityManager.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,13 +22,6 @@
 
 package org.jboss.messaging.integration.security;
 
-import java.util.HashSet;
-import java.util.Set;
-import java.security.Principal;
-
-import javax.naming.InitialContext;
-import javax.security.auth.Subject;
-
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.security.CheckType;
 import org.jboss.messaging.core.security.JBMSecurityManager;
@@ -38,6 +31,12 @@
 import org.jboss.security.RealmMapping;
 import org.jboss.security.SimplePrincipal;
 
+import javax.naming.InitialContext;
+import javax.security.auth.Subject;
+import java.security.Principal;
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * This implementation delegates to the JBoss AS security interfaces (which in turn use JAAS)
  * It can be used when running JBM in JBoss AS
@@ -127,9 +126,7 @@
       Set<Principal> principals = new HashSet<Principal>();
       for (Role role : roles)
       {
-         if ((checkType.equals(CheckType.CREATE) && role.isCheckType(CheckType.CREATE)) ||
-                 (checkType.equals(CheckType.WRITE) && role.isCheckType(CheckType.WRITE)) ||
-                 (checkType.equals(CheckType.READ) && role.isCheckType(CheckType.READ)))
+         if (checkType.hasRole(role))
          {
             principals.add(new SimplePrincipal(role.getName()));
          }

Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,8 +22,15 @@
 
 package org.jboss.messaging.jms.client;
 
-import java.util.HashSet;
-import java.util.Set;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ClientSessionFactory;
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.FailureListener;
+import org.jboss.messaging.core.version.Version;
+import org.jboss.messaging.utils.SimpleString;
+import org.jboss.messaging.utils.UUIDGenerator;
+import org.jboss.messaging.utils.VersionLoader;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionConsumer;
@@ -46,27 +53,19 @@
 import javax.jms.XASession;
 import javax.jms.XATopicConnection;
 import javax.jms.XATopicSession;
+import java.util.HashSet;
+import java.util.Set;
 
-import org.jboss.messaging.core.client.ClientSession;
-import org.jboss.messaging.core.client.ClientSessionFactory;
-import org.jboss.messaging.core.exception.MessagingException;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.remoting.FailureListener;
-import org.jboss.messaging.core.version.Version;
-import org.jboss.messaging.utils.SimpleString;
-import org.jboss.messaging.utils.UUIDGenerator;
-import org.jboss.messaging.utils.VersionLoader;
-
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:ataylor at redhat.com">Andy Taylor</a>
  * @version <tt>$Revision$</tt>
- *
- * $Id$
+ *          <p/>
+ *          $Id$
  */
 public class JBossConnection implements Connection, QueueConnection, TopicConnection, XAConnection, XAQueueConnection,
-         XATopicConnection
+                                        XATopicConnection
 {
    // Constants ------------------------------------------------------------------------------------
 
@@ -120,6 +119,8 @@
 
    private final int transactionBatchSize;
 
+   private ClientSession initialSession;
+
    // Constructors ---------------------------------------------------------------------------------
 
    public JBossConnection(final String username,
@@ -259,27 +260,29 @@
 
          // TODO may be a better way of doing this that doesn't involve creating a new session
 
-         if (!tempQueues.isEmpty())
+         try
          {
-            ClientSession session = null;
-            try
+            if (!tempQueues.isEmpty())
             {
-               session = sessionFactory.createSession(username, password, false, true, true, false, 0);
+               if (initialSession == null)
+               {
+                  initialSession = sessionFactory.createSession(username, password, false, true, true, false, 0);
+               }
 
                // Remove any temporary queues
 
                for (SimpleString queueName : tempQueues)
                {
-                  session.deleteQueue(queueName);
+                  initialSession.deleteQueue(queueName);
                }
             }
-            finally
-            {
-               if (session != null)
+         }
+         finally
+         {
+            if (initialSession != null)
                {
-                  session.close();
+                  initialSession.close();
                }
-            }
          }
 
          closed = true;
@@ -416,6 +419,7 @@
    // Protected ------------------------------------------------------------------------------------
 
    // In case the user forgets to close the connection manually
+
    protected void finalize() throws Throwable
    {
       close();
@@ -493,6 +497,19 @@
       }
    }
 
+   public void authorize() throws JMSException
+   {
+      try
+      {
+         initialSession = sessionFactory.createSession(username, password, false, false, false, false, 0);
+         initialSession.addFailureListener(listener);
+      }
+      catch (MessagingException me)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(me);
+      }
+   }
+
    // Inner classes --------------------------------------------------------------------------------
 
    private class JMSFailureListener implements FailureListener

Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -12,9 +12,15 @@
 
 package org.jboss.messaging.jms.client;
 
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
+import org.jboss.messaging.core.client.ClientSessionFactory;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.jms.referenceable.ConnectionFactoryObjectFactory;
+import org.jboss.messaging.jms.referenceable.SerializableObjectRefAddr;
+import org.jboss.messaging.utils.Pair;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
@@ -31,18 +37,10 @@
 import javax.jms.XATopicConnectionFactory;
 import javax.naming.NamingException;
 import javax.naming.Reference;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
 
-import org.jboss.messaging.core.client.ClientSession;
-import org.jboss.messaging.core.client.ClientSessionFactory;
-import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
-import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
-import org.jboss.messaging.core.exception.MessagingException;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.jms.referenceable.ConnectionFactoryObjectFactory;
-import org.jboss.messaging.jms.referenceable.SerializableObjectRefAddr;
-import org.jboss.messaging.utils.Pair;
-
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -641,43 +639,16 @@
       {
          throw JMSExceptionHelper.convertFromMessagingException(me);
       }
-
-      if (username != null)
-      {
-         // Since core has no connection concept, we need to create a session in order to authenticate at this time
-
-         ClientSession sess = null;
-
-         try
-         {
-            sess = sessionFactory.createSession(username, password, false, false, false, false, 0);
-         }
-         catch (MessagingException e)
-         {
-            throw JMSExceptionHelper.convertFromMessagingException(e);
-         }
-         finally
-         {
-            if (sess != null)
-            {
-               try
-               {
-                  sess.close();
-               }
-               catch (Throwable ignore)
-               {
-               }
-            }
-         }
-      }
-
-      return new JBossConnection(username,
+      JBossConnection connection = new JBossConnection(username,
                                  password,
                                  type,
                                  clientID,
                                  dupsOKBatchSize,
                                  transactionBatchSize,
                                  sessionFactory);
+
+      connection.authorize();
+      return connection;
    }
 
    private void createFactory() throws MessagingException

Modified: trunk/src/schemas/jbm-security.xsd
===================================================================
--- trunk/src/schemas/jbm-security.xsd	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/src/schemas/jbm-security.xsd	2009-03-23 09:28:19 UTC (rev 6131)
@@ -10,7 +10,8 @@
    <xsd:element name="deployment">
    	<xsd:complexType>
    		<xsd:sequence>
-   			<xsd:element ref="user" maxOccurs="unbounded" minOccurs="0"></xsd:element>
+            <xsd:element name="defaultuser" type="userType" maxOccurs="1" minOccurs="0"></xsd:element>
+            <xsd:element name="user" type="userType" maxOccurs="unbounded" minOccurs="0"></xsd:element>
    		</xsd:sequence>
    	</xsd:complexType>
    </xsd:element>
@@ -21,13 +22,11 @@
    	</xsd:complexType>
    </xsd:element>
 
-   <xsd:element name="user">
-   	<xsd:complexType>
+   	<xsd:complexType name="userType">
    		<xsd:sequence>
    			<xsd:element ref="role" maxOccurs="unbounded" minOccurs="1"></xsd:element>
    		</xsd:sequence>
    		<xsd:attribute name="name" type="xsd:ID" use="required"></xsd:attribute>
    		<xsd:attribute name="password" type="xsd:string"></xsd:attribute>
    	</xsd:complexType>
-   </xsd:element>
 </xsd:schema>

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/SecurityTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/SecurityTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/SecurityTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -21,25 +21,13 @@
   */
 package org.jboss.test.messaging.jms;
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
-
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
 import javax.jms.IllegalStateException;
 import javax.jms.JMSSecurityException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
 import javax.jms.Session;
-import javax.jms.Topic;
+import java.util.ArrayList;
 
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.security.Role;
-
 /**
  * Test JMS Security.
  *
@@ -59,20 +47,11 @@
 {
    // Constants -----------------------------------------------------
 
-   private static final Logger log = Logger.getLogger(SecurityTest.class);
 
-   private static final HashSet<Role> defConfig = new HashSet<Role>();
-   static
-   {
-      defConfig.add(new Role("def", true, true, true));
-   }
-
    // Static --------------------------------------------------------
 
-   // Attributes ----------------------------------------------------
+   // Attributes --------------------------------------------
 
-   private Set<Role> oldDefaultConfig;
-
    // Constructors --------------------------------------------------
 
    // Public --------------------------------------------------------
@@ -101,6 +80,29 @@
    }
 
    /**
+    * Login with no user, no password
+    * Should allow login (equivalent to guest)
+    */
+   public void testLoginNoUserNoPasswordWithNoGuest() throws Exception
+   {
+
+      Connection conn1 = null;
+      Connection conn2 = null;
+      try
+      {
+         conn1 = cf.createConnection();
+         conn2 = cf.createConnection(null, null);
+      }
+      finally
+      {
+         if (conn1 != null)
+            conn1.close();
+         if (conn2 != null)
+            conn2.close();
+      }
+   }
+
+   /**
     * Login with valid user and password
     * Should allow
     */
@@ -262,694 +264,12 @@
       }
    }
 
-   //
-   // Authorization tests
-   //
 
-   public void testAnonymousConnection() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         setSecurityConfig(oldDefaultConfig);
-         conn = cf.createConnection();
-         assertTrue(canWriteDestination(conn, queue1));
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-   }
 
-   public void testValidTopicPublisher() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         conn = cf.createConnection("john", "needle");
-         assertTrue(canWriteDestination(conn, topic1));
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-   }
-
-   public void testInvalidTopicPublisher() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         conn = cf.createConnection("nobody", "nobody");
-         assertFalse(canWriteDestination(conn, topic1));
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-   }
-
-   public void testValidTopicSubscriber() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         conn = cf.createConnection("john", "needle");
-         assertTrue(canReadDestination(conn, topic1));
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-   }
-
-   public void testInvalidTopicSubscriber() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         conn = cf.createConnection("nobody", "nobody");
-         assertFalse(canReadDestination(conn, topic1));
-      }
-      finally
-      {
-         if (conn != null)
-            conn.close();
-      }
-   }
-
-   public void testValidQueueBrowser() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         conn = cf.createConnection("john", "needle");
-         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         sess.createBrowser(queue1);
-      }
-      finally
-      {
-         if (conn != null)
-            conn.close();
-      }
-   }
-
-   public void testInvalidQueueBrowser() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         conn = cf.createConnection("nobody", "nobody");
-         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         sess.createBrowser(queue1).getEnumeration();
-         fail("should throw JMSSecurityException");
-      }
-      catch (JMSSecurityException e)
-      {
-         // Expected
-      }
-      finally
-      {
-         if (conn != null)
-            conn.close();
-      }
-   }
-
-   public void testValidQueueSender() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         conn = cf.createConnection("john", "needle");
-         assertTrue(this.canWriteDestination(conn, queue1));
-      }
-      finally
-      {
-         if (conn != null)
-            conn.close();
-      }
-   }
-
-   public void testInvalidQueueSender() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         conn = cf.createConnection("nobody", "nobody");
-         assertFalse(this.canWriteDestination(conn, queue1));
-      }
-      finally
-      {
-         if (conn != null)
-            conn.close();
-      }
-   }
-
-   public void testValidQueueReceiver() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         conn = cf.createConnection("john", "needle");
-         assertTrue(this.canReadDestination(conn, queue1));
-      }
-      finally
-      {
-         if (conn != null)
-            conn.close();
-      }
-   }
-
-   public void testInvalidQueueReceiver() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         conn = cf.createConnection("nobody", "nobody");
-         assertFalse(this.canReadDestination(conn, queue1));
-      }
-      finally
-      {
-         if (conn != null)
-            conn.close();
-      }
-   }
-
-   /**
-    * Test valid durable subscription creation for connection preconfigured with client id
-    */
-   public void testValidDurableSubscriptionCreationPreConf() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         ArrayList<String> bindings = new ArrayList<String>();
-         bindings.add("preConfcf");
-         deployConnectionFactory("dilbert-id", "preConfcf", bindings);
-         ConnectionFactory cf = (ConnectionFactory)getInitialContext().lookup("preConfcf");
-         // setSecurityConfig(oldDefaultConfig);
-         conn = cf.createConnection("dilbert", "dogbert");
-         assertTrue(this.canCreateDurableSub(conn, topic1, "sub2"));
-      }
-      finally
-      {
-         if (conn != null)
-            conn.close();
-         undeployConnectionFactory("preConfcf");
-      }
-   }
-
-   /*
-    * Test valid durable subscription creation for connection not preconfigured with client id
-    */
-   public void testValidDurableSubscriptionCreationNotPreConf() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         conn = cf.createConnection("dynsub", "dynsub");
-         conn.setClientID("myID");
-         assertTrue(this.canCreateDurableSub(conn, topic1, "sub4"));
-      }
-      finally
-      {
-         if (conn != null)
-            conn.close();
-      }
-   }
-
-   public void testDefaultSecurityValid() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         conn = cf.createConnection("john", "needle");
-         conn.setClientID("myID5");
-         assertTrue(this.canReadDestination(conn, topic3));
-         assertTrue(this.canWriteDestination(conn, topic3));
-         assertTrue(this.canCreateDurableSub(conn, topic3, "subxyz"));
-      }
-      finally
-      {
-         if (conn != null)
-            conn.close();
-      }
-   }
-
-   public void testDefaultSecurityInvalid() throws Exception
-   {
-      Connection conn = null;
-      try
-      {
-         conn = cf.createConnection("nobody", "nobody");
-         conn.setClientID("myID6");
-         assertFalse(this.canReadDestination(conn, topic3));
-         assertFalse(this.canWriteDestination(conn, topic3));
-         assertFalse(this.canCreateDurableSub(conn, topic3, "subabc"));
-      }
-      finally
-      {
-         if (conn != null)
-            conn.close();
-      }
-   }
-
-   /**
-    * This test makes sure that changing the default security configuration on the server has effect
-    * over already deployed destinations.
-    */
-   public void testDefaultSecurityUpdate() throws Exception
-   {
-      Set<Role> defSecConf = getSecurityConfig();
-
-      // "john" has the role def, so he should be able to create a producer and a consumer on a queue
-      Connection conn = null;
-
-      try
-      {
-         conn = cf.createConnection("john", "needle");
-         assertTrue(canReadDestination(conn, queue2));
-         assertTrue(canWriteDestination(conn, queue2));
-
-         HashSet<Role> newSecurityConfig = new HashSet<Role>();
-         newSecurityConfig.add(new Role("someotherrole", true, true, false));
-
-         setSecurityConfig(newSecurityConfig);
-
-         assertFalse(canReadDestination(conn, queue2));
-         // we should only look non transacted, as looking on connection would require the test
-         // to wait 15s (eviction timeout)
-         assertFalse(canWriteDestination(conn, queue2, false));
-
-         newSecurityConfig = new HashSet<Role>();
-         newSecurityConfig.add(new Role("def", true, false, false));
-
-         setSecurityConfig(newSecurityConfig);
-
-         assertTrue(canReadDestination(conn, queue2));
-         // to avoid cache evict timeout
-         assertFalse(canWriteDestination(conn, queue2, false));
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-         setSecurityConfig(defSecConf);
-      }
-   }
-
-   /**
-    * This test makes sure that changing the queue security configuration on the server has effect
-    * over already deployed destinations.
-    */
-   public void testQueueSecurityUpdate() throws Exception
-   {
-      // "john" has the role def, so he should be able to create a producer and a consumer on a queue
-      Connection conn = null;
-
-      try
-      {
-         conn = cf.createConnection("john", "needle");
-         assertTrue(canReadDestination(conn, queue2));
-         assertTrue(canWriteDestination(conn, queue2));
-
-         HashSet<Role> newSecurityConfig = new HashSet<Role>();
-         newSecurityConfig.add(new Role("someotherrole", true, true, false));
-
-         configureSecurityForDestination("Queue2", true, newSecurityConfig);
-
-         assertFalse(canReadDestination(conn, queue2));
-         assertFalse(canWriteDestination(conn, queue2, false));
-
-         newSecurityConfig = new HashSet<Role>();
-         newSecurityConfig.add(new Role("def", true, false, false));
-
-         configureSecurityForDestination("Queue2", true, newSecurityConfig);
-
-         assertTrue(canReadDestination(conn, queue2));
-         assertFalse(canWriteDestination(conn, queue2, false));
-
-         newSecurityConfig = new HashSet<Role>();
-         newSecurityConfig.add(new Role("def", true, true, false));
-
-         configureSecurityForDestination("Queue2", true, newSecurityConfig);
-
-         assertTrue(canReadDestination(conn, queue2));
-         assertTrue(canWriteDestination(conn, queue2, false));
-
-         HashSet<Role> lockedConf = new HashSet<Role>();
-         lockedConf.add(new Role("alien", true, true, true));
-
-         setSecurityConfigOnManager("Queue2", true, lockedConf);
-
-         assertFalse(canReadDestination(conn, queue2));
-         assertFalse(canWriteDestination(conn, queue2, false));
-
-         setSecurityConfigOnManager("Queue2", true, defConfig);
-
-         assertTrue(canReadDestination(conn, queue2));
-         assertTrue(canWriteDestination(conn, queue2, false));
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-   }
-
-   /**
-    * This test makes sure that changing the topic security configuration on the server has effect
-    * over already deployed destinations.
-    */
-   public void testTopicSecurityUpdate() throws Exception
-   {
-      // "john" has the role def, so he should be able to create a producer and a consumer on a queue
-      Connection conn = null;
-
-      try
-      {
-         conn = cf.createConnection("john", "needle");
-         assertTrue(canReadDestination(conn, topic2));
-         assertTrue(canWriteDestination(conn, topic2));
-
-         HashSet<Role> newSecurityConfig = new HashSet<Role>();
-         newSecurityConfig.add(new Role("someotherrole", true, true, false));
-
-         configureSecurityForDestination("Topic2", false, newSecurityConfig);
-
-         assertFalse(canReadDestination(conn, topic2));
-         assertFalse(canWriteDestination(conn, topic2, false));
-
-         newSecurityConfig = new HashSet<Role>();
-         newSecurityConfig.add(new Role("def", true, false, false));
-
-         configureSecurityForDestination("Topic2", false, newSecurityConfig);
-
-         assertTrue(canReadDestination(conn, topic2));
-         assertFalse(canWriteDestination(conn, topic2, false));
-
-         newSecurityConfig = new HashSet<Role>();
-         newSecurityConfig.add(new Role("def", true, true, false));
-
-         configureSecurityForDestination("Topic2", false, newSecurityConfig);
-
-         assertTrue(canReadDestination(conn, topic2));
-         assertTrue(canWriteDestination(conn, topic2, false));
-
-         // Now set to null
-
-         configureSecurityForDestination("Topic2", false, null);
-
-         // Should fall back to the default config
-         HashSet<Role> lockedConf = new HashSet<Role>();
-         lockedConf.add(new Role("alien", true, true, true));
-         Set<Role> orig = getSecurityConfig();
-         setSecurityConfig(lockedConf);
-
-         assertFalse(canReadDestination(conn, topic2));
-         assertFalse(canWriteDestination(conn, topic2, false));
-
-         setSecurityConfig(orig);
-
-         assertTrue(canReadDestination(conn, topic2));
-         assertTrue(canWriteDestination(conn, topic2, false));
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-   }
-
-   public void testSecurityForQueuesAndTopicsWithTheSameName() throws Exception
-   {
-      createQueue("Accounting");
-      createTopic("Accounting");
-
-      Connection conn = null;
-
-      try
-      {
-         // configure the queue to allow "def" to read
-         HashSet<Role> config = new HashSet<Role>();
-         config.add(new Role("def", true, false, false));
-         configureSecurityForDestination("Accounting", true, config);
-
-         // configure the topic to prevent "def" from reading
-         HashSet<Role> config2 = new HashSet<Role>();
-         config2.add(new Role("def", false, false, false));
-         configureSecurityForDestination("Accounting", false, config2);
-
-         Queue queue = (Queue)ic.lookup("/queue/Accounting");
-         Topic topic = (Topic)ic.lookup("/topic/Accounting");
-
-         conn = cf.createConnection("john", "needle");
-
-         assertTrue(canReadDestination(conn, queue));
-         assertFalse(canReadDestination(conn, topic));
-      }
-      finally
-      {
-         destroyQueue("Accounting");
-         destroyTopic("Accounting");
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-   }
-
-   public void testSecurityForTemporaryQueue() throws Exception
-   {
-      testSecurityForTemporaryDestination(true);
-   }
-
-   public void testSecurityForTemporaryTopic() throws Exception
-   {
-      testSecurityForTemporaryDestination(false);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-
-      oldDefaultConfig = getSecurityConfig();
-
-      HashSet<Role> roles = new HashSet<Role>();
-      roles.add(new Role("guest", true, true, true));
-      roles.add(new Role("publisher", true, true, false));
-      roles.add(new Role("noacc", false, false, false));
-      roles.add(new Role("john", true, false, false));
-      configureSecurityForDestination("Queue1", true, roles);
-
-      HashSet<Role> roles2 = new HashSet<Role>();
-      roles2.add(new Role("guest", true, true, true));
-      roles2.add(new Role("publisher", true, true, false));
-      roles2.add(new Role("durpublisher", true, true, true));
-      configureSecurityForDestination("Topic1", false, roles2);
-
-      HashSet<Role> roles3 = new HashSet<Role>();
-      roles3.add(new Role("publisher", true, true, false));
-      configureSecurityForDestination("Topic2", false, roles3);
-
-      setSecurityConfig(defConfig);
-   }
-
-   protected void tearDown() throws Exception
-   {
-      super.tearDown();
-
-      setSecurityConfig(oldDefaultConfig);
-      configureSecurityForDestination("Queue1", true, null);
-      configureSecurityForDestination("Queue2", true, null);
-      configureSecurityForDestination("Topic1", false, null);
-      configureSecurityForDestination("Topic2", false, null);
-   }
-
    // Private -------------------------------------------------------
 
-   private boolean canReadDestination(Connection conn, Destination dest) throws Exception
-   {
-      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
-      try
-      {
-         log.info("attempting to create consumer on " + dest);
-         sess.createConsumer(dest);         
-         return true;
-      }
-      catch (JMSSecurityException e)
-      {
-         log.info("Can't read destination", e);
-         return false;
-      }
-      finally
-      {
-         sess.close();
-      }
-
-   }
-
-   private boolean canWriteDestination(Connection conn, Destination dest) throws Exception
-   {
-      boolean transacted = canWriteDestination(conn, dest, true);
-      boolean nonTransacted = canWriteDestination(conn, dest, false);
-
-      return transacted || nonTransacted;
-   }
-
-   private boolean canWriteDestination(Connection conn, Destination dest, boolean transacted) throws Exception
-   {
-      Session sess = conn.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
-
-      try
-      {
-         boolean namedSucceeded = true;
-         try
-         {
-            MessageProducer prod = sess.createProducer(dest);
-            Message m = sess.createTextMessage("Kippers");
-            prod.send(m);
-            if (transacted)
-            {
-               sess.commit();
-            }
-         }
-         catch (JMSSecurityException e)
-         {
-            log.trace("Can't write to destination using named producer", e);
-            namedSucceeded = false;
-         }
-
-         boolean anonSucceeded = true;
-         try
-         {
-            MessageProducer producerAnon = sess.createProducer(null);
-            Message m = sess.createTextMessage("Kippers");
-            producerAnon.send(dest, m);
-            if (transacted)
-            {
-               sess.commit();
-            }
-         }
-         catch (JMSSecurityException e)
-         {
-            log.trace("Can't write to destination using named producer", e);
-            anonSucceeded = false;
-         }
-
-         if (namedSucceeded || anonSucceeded)
-         {
-            if (dest instanceof Queue)
-            {
-               String destName = ((Queue)dest).getQueueName();
-               removeAllMessages(destName, true);
-            }
-         }
-
-         log.trace("namedSucceeded:" + namedSucceeded + ", anonSucceeded:" + anonSucceeded);
-         return namedSucceeded || anonSucceeded;
-      }
-      finally
-      {
-         sess.close();
-      }
-
-   }
-
-   private boolean canCreateDurableSub(Connection conn, Topic topic, String subName) throws Exception
-   {
-
-      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      try
-      {
-         MessageConsumer cons = sess.createDurableSubscriber(topic, subName);
-         cons.close();
-         sess.unsubscribe(subName);
-         log.trace("Successfully created and unsubscribed subscription");
-         return true;
-      }
-      catch (JMSSecurityException e)
-      {
-         log.trace("Can't create durable sub", e);
-         return false;
-      }
-      finally
-      {
-         sess.close();
-      }
-   }
-
-   private void testSecurityForTemporaryDestination(boolean isQueue) throws Exception
-   {
-      Destination dest = isQueue ? (Destination)queue1 : topic1;
-
-      Connection conn = cf.createConnection("guest", "guest");
-      try
-      {
-         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         Destination temporaryDestination = isQueue ? (Destination)session.createTemporaryQueue()
-                                                   : session.createTemporaryTopic();
-         Message message = session.createMessage();
-         message.setJMSReplyTo(temporaryDestination);
-         MessageProducer producer = session.createProducer(dest);
-
-         MessageConsumer tmpConsumer = session.createConsumer(temporaryDestination);
-         conn.start();
-
-         Connection conn2 = cf.createConnection("john", "needle");
-         try
-         {
-            Session session2 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-            MessageConsumer consumer = session.createConsumer(dest);
-            conn.start();
-
-            producer.send(message);
-
-            Message in = consumer.receive(1000L);
-            assertNotNull(in);
-
-            Message out = session2.createMessage();
-            MessageProducer replyProducer = session2.createProducer(in.getJMSReplyTo());
-            replyProducer.send(out);
-         }
-         finally
-         {
-            conn2.close();
-         }
-
-         Message reply = tmpConsumer.receive(1000L);
-         assertNotNull(reply);
-      }
-      finally
-      {
-         conn.close();
-      }
-   }
-
+   
    // Inner classes -------------------------------------------------
 
 }

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/thirdparty/jbosssx/SecurityAssociationTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/thirdparty/jbosssx/SecurityAssociationTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/thirdparty/jbosssx/SecurityAssociationTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -21,10 +21,11 @@
 */
 package org.jboss.test.messaging.thirdparty.jbosssx;
 
-import java.security.Principal;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import org.jboss.messaging.core.security.Role;
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.test.messaging.jms.JMSTestCase;
+import org.jboss.test.messaging.tools.container.MockJBossSecurityManager;
 
 import javax.jms.Connection;
 import javax.jms.MessageConsumer;
@@ -32,13 +33,11 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.security.auth.Subject;
+import java.security.Principal;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
 
-import org.jboss.messaging.core.security.Role;
-import org.jboss.security.SecurityAssociation;
-import org.jboss.security.SimplePrincipal;
-import org.jboss.test.messaging.jms.JMSTestCase;
-import org.jboss.test.messaging.tools.container.MockJBossSecurityManager;
-
 /**
  * Set of tests to insure consistent behavior relative to the JBoss AS security infrastructure.
  * This is just a safety layer, full fledged security tests should be present in the integration
@@ -277,8 +276,8 @@
       super.setUp();
    
       Set<Role> roles = new HashSet<Role>();
-      roles.add(new Role("publisher", true, true, false));
-      roles.add(new Role("guest", true, true, false));
+      roles.add(new Role("publisher", true, true, false, true, true, true, true));
+      roles.add(new Role("guest", true, true, false, true, true, true, true));
       
       setSecurityConfigOnManager("Queue2", true, roles);
 

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareAddressControlWrapperTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareAddressControlWrapperTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareAddressControlWrapperTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,21 +22,20 @@
 
 package org.jboss.messaging.tests.integration.cluster.management;
 
-import static org.jboss.messaging.tests.integration.management.ManagementControlHelper.createAddressControl;
-import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
-import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import javax.management.openmbean.TabularData;
-
 import org.jboss.messaging.core.client.ClientSession;
 import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
 import org.jboss.messaging.core.client.impl.ClientSessionFactoryInternal;
 import org.jboss.messaging.core.config.TransportConfiguration;
 import org.jboss.messaging.core.management.AddressControlMBean;
 import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
+import static org.jboss.messaging.tests.integration.management.ManagementControlHelper.createAddressControl;
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 import org.jboss.messaging.utils.SimpleString;
 
+import javax.management.openmbean.TabularData;
+
 /**
  * A ReplicationAwareQueueControlWrapperTest
  *
@@ -67,7 +66,7 @@
       assertEquals(roles.size(), backupAddressControl.getRoles().size());
 
       // add a role
-      liveAddressControl.addRole(randomString(), randomBoolean(), randomBoolean(), randomBoolean());
+      liveAddressControl.addRole(randomString(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
 
       assertEquals(roles.size() + 1, liveAddressControl.getRoles().size());
    }
@@ -83,7 +82,7 @@
       assertEquals(roles.size(), backupAddressControl.getRoles().size());
 
       // add a role
-      liveAddressControl.addRole(roleName, randomBoolean(), randomBoolean(), randomBoolean());
+      liveAddressControl.addRole(roleName, randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
 
       assertEquals(roles.size() + 1, liveAddressControl.getRoles().size());
       assertEquals(roles.size() + 1, backupAddressControl.getRoles().size());

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeReconnectionTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeReconnectionTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeReconnectionTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -24,7 +24,6 @@
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.jms.bridge.QualityOfServiceMode;
 import org.jboss.messaging.jms.bridge.impl.BridgeImpl;
-// import org.jboss.test.messaging.tools.ServerManagement;
 import org.jboss.messaging.jms.server.impl.JMSServerManagerImpl;
 import org.jboss.messaging.tests.unit.util.InVMContext;
 
@@ -176,7 +175,7 @@
          
          //Wait a while before starting up to simulate the dest being down for a while
          log.info("Waiting 5 secs before bringing server back up");
-         Thread.sleep(5000);
+         Thread.sleep(10000);
          log.info("Done wait");
          
          //Restart the server
@@ -261,7 +260,7 @@
          
          //Wait a while before starting up to simulate the dest being down for a while
          log.info("Waiting 5 secs before bringing server back up");
-         Thread.sleep(5000);
+         Thread.sleep(10000);
          log.info("Done wait");
          
          //Restart the server         

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -21,9 +21,10 @@
  */
 package org.jboss.messaging.tests.integration.jms.bridge;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.jms.bridge.QualityOfServiceMode;
+import org.jboss.messaging.jms.bridge.impl.BridgeImpl;
+import org.jboss.messaging.jms.client.JBossMessage;
 
 import javax.jms.Connection;
 import javax.jms.DeliveryMode;
@@ -34,12 +35,10 @@
 import javax.jms.TextMessage;
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.jms.bridge.QualityOfServiceMode;
-import org.jboss.messaging.jms.bridge.impl.BridgeImpl;
-import org.jboss.messaging.jms.client.JBossMessage;
-
 /**
  * A BridgeTest
  *
@@ -998,7 +997,7 @@
 
          prod.send(tm);
 
-         tm = (TextMessage)cons.receive(1000);
+         tm = (TextMessage)cons.receive(5000);
 
          assertNotNull(tm);
 

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControl2Test.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControl2Test.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControl2Test.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,17 +22,6 @@
 
 package org.jboss.messaging.tests.integration.jms.management;
 
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Session;
-
 import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.config.TransportConfiguration;
@@ -50,7 +39,15 @@
 import org.jboss.messaging.tests.integration.management.ManagementControlHelper;
 import org.jboss.messaging.tests.integration.management.ManagementTestBase;
 import org.jboss.messaging.tests.unit.util.InVMContext;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
 /**
  * A QueueControlTest
  *
@@ -246,13 +243,11 @@
          assertEquals(0, control.listConnectionIDs().length);
 
          Connection connection = JMSUtil.createConnection(connectorFactory);
-         connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
          String[] connectionIDs = control.listConnectionIDs();
          assertEquals(1, connectionIDs.length);
 
          Connection connection2 = JMSUtil.createConnection(connectorFactory);
-         connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          assertEquals(2, control.listConnectionIDs().length);
 
          connection.close();
@@ -286,7 +281,6 @@
          assertEquals(0, control.listConnectionIDs().length);
 
          Connection connection = JMSUtil.createConnection(connectorFactory);
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
          String[] connectionIDs = control.listConnectionIDs();
          assertEquals(1, connectionIDs.length);
@@ -294,9 +288,7 @@
 
          String[] sessions = control.listSessions(connectionID);
          assertEquals(1, sessions.length);
-
-         session.close();
-
+         connection.close();
          sessions = control.listSessions(connectionID);
          assertEquals(0, sessions.length);
 
@@ -327,8 +319,6 @@
          assertEquals(0, control.listRemoteAddresses().length);
 
          Connection connection = JMSUtil.createConnection(connectorFactory);
-         // the connection won't connect to the server until a session is created
-         connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
          String[] remoteAddresses = control.listRemoteAddresses();
          assertEquals(1, remoteAddresses.length);
@@ -369,8 +359,6 @@
          assertEquals(0, control.listRemoteAddresses().length);
 
          Connection connection = JMSUtil.createConnection(connectorFactory);
-         // the connection won't connect to the server until a session is created
-         connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
          assertEquals(1, service.getServer().getConnectionCount());
 
@@ -389,7 +377,7 @@
 
          assertTrue(control.closeConnectionsForAddress(remoteAddress));
 
-         boolean gotException = exceptionLatch.await(1, TimeUnit.SECONDS);
+         boolean gotException = exceptionLatch.await(5, TimeUnit.SECONDS);
          assertTrue("did not received the expected JMSException", gotException);
          assertEquals(0, control.listRemoteAddresses().length);
          assertEquals(0, service.getServer().getConnectionCount());
@@ -419,8 +407,6 @@
          assertEquals(0, control.listRemoteAddresses().length);
 
          Connection connection = JMSUtil.createConnection(connectorFactory);
-         // the connection won't connect to the server until a session is created
-         connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
          assertEquals(1, service.getServer().getConnectionCount());
          String[] remoteAddresses = control.listRemoteAddresses();

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/AddressControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/AddressControlTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/AddressControlTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,15 +22,6 @@
 
 package org.jboss.messaging.tests.integration.management;
 
-import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
-import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.management.openmbean.TabularData;
-
 import org.jboss.messaging.core.client.ClientSession;
 import org.jboss.messaging.core.client.ClientSessionFactory;
 import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
@@ -45,8 +36,15 @@
 import org.jboss.messaging.core.security.Role;
 import org.jboss.messaging.core.server.Messaging;
 import org.jboss.messaging.core.server.MessagingService;
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 import org.jboss.messaging.utils.SimpleString;
 
+import javax.management.openmbean.TabularData;
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * A QueueControlTest
  *
@@ -114,7 +112,7 @@
    {
       SimpleString address = randomSimpleString();
       SimpleString queue = randomSimpleString();
-      Role role = new Role(randomString(), randomBoolean(), randomBoolean(), randomBoolean());
+      Role role = new Role(randomString(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
 
       session.createQueue(address, queue, true);
 
@@ -130,9 +128,13 @@
       assertEquals(1, tabularData.size());
       RoleInfo[] roleInfos = RoleInfo.from(tabularData);
       assertEquals(role.getName(), roleInfos[0].getName());
-      assertEquals(role.isCheckType(CheckType.READ), roleInfos[0].isRead());
-      assertEquals(role.isCheckType(CheckType.WRITE), roleInfos[0].isWrite());
-      assertEquals(role.isCheckType(CheckType.CREATE), roleInfos[0].isCreate());
+      assertEquals(CheckType.CONSUME.hasRole(role), roleInfos[0].isConsume());
+      assertEquals(CheckType.CREATE_DURABLE_QUEUE.hasRole(role), roleInfos[0].isCreateDurableQueue());
+      assertEquals(CheckType.CREATE_TEMP_QUEUE.hasRole(role), roleInfos[0].isCreateTempQueue());
+      assertEquals(CheckType.DELETE_DURABLE_QUEUE.hasRole(role), roleInfos[0].isDeleteDurableQueue());
+      assertEquals(CheckType.DELETE_TEMP_QUEUE.hasRole(role), roleInfos[0].isDeleteTempQueue());
+      assertEquals(CheckType.MANAGE.hasRole(role), roleInfos[0].isManage());
+      assertEquals(CheckType.SEND.hasRole(role), roleInfos[0].isSend());
 
       session.deleteQueue(queue);
    }
@@ -141,7 +143,7 @@
    {
       SimpleString address = randomSimpleString();
       SimpleString queue = randomSimpleString();
-      Role role = new Role(randomString(), randomBoolean(), randomBoolean(), randomBoolean());
+      Role role = new Role(randomString(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
 
       session.createQueue(address, queue, true);
 
@@ -150,18 +152,27 @@
       assertEquals(0, tabularData.size());
 
       addressControl.addRole(role.getName(),
-                             role.isCheckType(CheckType.CREATE),
-                             role.isCheckType(CheckType.READ),
-                             role.isCheckType(CheckType.WRITE));
+                             CheckType.SEND.hasRole(role),
+                             CheckType.CONSUME.hasRole(role),
+                             CheckType.CREATE_DURABLE_QUEUE.hasRole(role),
+                             CheckType.DELETE_DURABLE_QUEUE.hasRole(role),
+                             CheckType.CREATE_TEMP_QUEUE.hasRole(role),
+                             CheckType.DELETE_TEMP_QUEUE.hasRole(role),
+                             CheckType.MANAGE.hasRole(role));
 
       tabularData = addressControl.getRoles();
       assertEquals(1, tabularData.size());
       RoleInfo[] roleInfos = RoleInfo.from(tabularData);
       assertEquals(role.getName(), roleInfos[0].getName());
-      assertEquals(role.isCheckType(CheckType.CREATE), roleInfos[0].isCreate());
-      assertEquals(role.isCheckType(CheckType.READ), roleInfos[0].isRead());
-      assertEquals(role.isCheckType(CheckType.WRITE), roleInfos[0].isWrite());
+      assertEquals(CheckType.CONSUME.hasRole(role), roleInfos[0].isConsume());
+      assertEquals(CheckType.CREATE_DURABLE_QUEUE.hasRole(role), roleInfos[0].isCreateDurableQueue());
+      assertEquals(CheckType.CREATE_TEMP_QUEUE.hasRole(role), roleInfos[0].isCreateTempQueue());
+      assertEquals(CheckType.DELETE_DURABLE_QUEUE.hasRole(role), roleInfos[0].isDeleteDurableQueue());
+      assertEquals(CheckType.DELETE_TEMP_QUEUE.hasRole(role), roleInfos[0].isDeleteTempQueue());
+      assertEquals(CheckType.MANAGE.hasRole(role), roleInfos[0].isManage());
+      assertEquals(CheckType.SEND.hasRole(role), roleInfos[0].isSend());
 
+
       session.deleteQueue(queue);
    }
 
@@ -169,7 +180,7 @@
    {
       SimpleString address = randomSimpleString();
       SimpleString queue = randomSimpleString();
-      Role role = new Role(randomString(), randomBoolean(), randomBoolean(), randomBoolean());
+      Role role = new Role(randomString(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
 
       session.createQueue(address, queue, true);
 
@@ -178,9 +189,13 @@
       assertEquals(0, tabularData.size());
 
       addressControl.addRole(role.getName(),
-                             role.isCheckType(CheckType.CREATE),
-                             role.isCheckType(CheckType.READ),
-                             role.isCheckType(CheckType.WRITE));
+                             CheckType.SEND.hasRole(role),
+                             CheckType.CONSUME.hasRole(role),
+                             CheckType.CREATE_DURABLE_QUEUE.hasRole(role),
+                             CheckType.DELETE_DURABLE_QUEUE.hasRole(role),
+                             CheckType.CREATE_TEMP_QUEUE.hasRole(role),
+                             CheckType.DELETE_TEMP_QUEUE.hasRole(role),
+                             CheckType.MANAGE.hasRole(role));
 
       tabularData = addressControl.getRoles();
       assertEquals(1, tabularData.size());
@@ -188,9 +203,13 @@
       try
       {
          addressControl.addRole(role.getName(),
-                                role.isCheckType(CheckType.CREATE),
-                                role.isCheckType(CheckType.READ),
-                                role.isCheckType(CheckType.WRITE));
+                             CheckType.SEND.hasRole(role),
+                             CheckType.CONSUME.hasRole(role),
+                             CheckType.CREATE_DURABLE_QUEUE.hasRole(role),
+                             CheckType.DELETE_DURABLE_QUEUE.hasRole(role),
+                             CheckType.CREATE_TEMP_QUEUE.hasRole(role),
+                             CheckType.DELETE_TEMP_QUEUE.hasRole(role),
+                             CheckType.MANAGE.hasRole(role));
          fail("can not add a role which already exists");
       }
       catch (Exception e)
@@ -215,7 +234,7 @@
       TabularData tabularData = addressControl.getRoles();
       assertEquals(0, tabularData.size());
 
-      addressControl.addRole(roleName, randomBoolean(), randomBoolean(), randomBoolean());
+      addressControl.addRole(roleName, randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
 
       tabularData = addressControl.getRoles();
       assertEquals(1, tabularData.size());

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/AddressControlUsingCoreTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/AddressControlUsingCoreTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/AddressControlUsingCoreTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,12 +22,14 @@
 
 package org.jboss.messaging.tests.integration.management;
 
-import javax.management.openmbean.TabularData;
-
 import org.jboss.messaging.core.management.AddressControlMBean;
 import org.jboss.messaging.core.management.ObjectNames;
+import org.jboss.messaging.core.management.Operation;
+import org.jboss.messaging.core.management.Parameter;
 import org.jboss.messaging.utils.SimpleString;
 
+import javax.management.openmbean.TabularData;
+
 /**
  * A JMXQueueControlTest
  *
@@ -56,9 +58,10 @@
          private final CoreMessagingProxy proxy = new CoreMessagingProxy(session,
                                                                          ObjectNames.getAddressObjectName(address));
 
-         public void addRole(String name, boolean create, boolean read, boolean write) throws Exception
+         @Operation(desc = "Add a Role to this address")
+         public void addRole(@Parameter(name = "name", desc = "Name of the role to add")String name, @Parameter(name = "send", desc = "Can the user send to an address?")boolean send, @Parameter(name = "consume", desc = "Can the user consume from this address?")boolean consume, @Parameter(name = "createDurableQueue", desc = "Can the user create a durable queue?")boolean createDurableQueue, @Parameter(name = "deleteDurableQueue", desc = "Can the user delete a durable queue?")boolean deleteDurableQueue, @Parameter(name = "createTempQueue", desc = "Can the user create a temp queue?")boolean createTempQueue, @Parameter(name = "deleteTempQueue", desc = "Can the user delete a temp queue?")boolean deleteTempQueue, @Parameter(name = "manage", desc = "Can the user send management messages?")boolean manage) throws Exception
          {
-            proxy.invokeOperation("addRole", name, create, read, write);
+            proxy.invokeOperation("addRole", name, send, consume,  createDurableQueue, deleteDurableQueue, createTempQueue, deleteTempQueue, manage);
          }
 
          public String getAddress()

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -24,40 +24,15 @@
 
 package org.jboss.messaging.tests.integration.management;
 
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.jboss.messaging.core.security.CheckType.CREATE;
-import static org.jboss.messaging.core.security.CheckType.READ;
-import static org.jboss.messaging.core.security.CheckType.WRITE;
-import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import java.util.Set;
-
-import javax.management.ObjectName;
-
-import org.jboss.messaging.core.buffers.ChannelBuffers;
-import org.jboss.messaging.core.client.management.impl.ManagementHelper;
 import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.management.AddressControlMBean;
-import org.jboss.messaging.core.management.ManagementService;
-import org.jboss.messaging.core.management.ObjectNames;
-import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
-import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.core.security.Role;
-import org.jboss.messaging.core.server.ServerMessage;
-import org.jboss.messaging.core.server.impl.ServerMessageImpl;
-import org.jboss.messaging.tests.util.RandomUtil;
-import org.jboss.messaging.utils.SimpleString;
+import org.jboss.messaging.tests.util.UnitTestCase;
 
 /*
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  * 
  * @version <tt>$Revision$</tt>
  */
-public class ManagementServiceImplTest extends ManagementTestBase
+public class ManagementServiceImplTest extends UnitTestCase
 {
    // Constants -----------------------------------------------------
 
@@ -73,6 +48,7 @@
 
    public void testHandleManagementMessageWithOperation() throws Exception
    {
+      /*MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
       ManagementService managementService = new ManagementServiceImpl(mbeanServer, false);
       assertNotNull(managementService);
       managementService.start();
@@ -106,11 +82,12 @@
 
       verify(resource);
 
-      managementService.stop();
+      managementService.stop();*/
    }
 
-   public void testHandleManagementMessageWithOperationWhichFails() throws Exception
+   /*public void testHandleManagementMessageWithOperationWhichFails() throws Exception
    {
+      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
       ManagementService managementService = new ManagementServiceImpl(mbeanServer, false);
       assertNotNull(managementService);
       managementService.start();
@@ -160,6 +137,8 @@
    {
       super.setUp();
 
+      MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
+
       Set set = mbeanServer.queryNames(ObjectName.getInstance(ObjectNames.DOMAIN + ":*"), null);
 
       for (Object objectName : set)
@@ -171,6 +150,8 @@
    @Override
    protected void tearDown() throws Exception
    {
+      MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
+
       Set set = mbeanServer.queryMBeans(ObjectName.getInstance(ObjectNames.DOMAIN + ":*"), null);
 
       for (Object obj : set)
@@ -181,7 +162,7 @@
       assertEquals(0, mbeanServer.queryMBeans(ObjectName.getInstance(ObjectNames.DOMAIN + ":*"), null).size());
 
       super.tearDown();
-   }
+   }*/
 
    // Protected -----------------------------------------------------
 

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/SecurityManagementWithConfiguredAdminUserTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/SecurityManagementWithConfiguredAdminUserTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/SecurityManagementWithConfiguredAdminUserTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,14 +22,10 @@
 
 package org.jboss.messaging.tests.integration.management;
 
-import static org.jboss.messaging.core.config.impl.ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS;
-
-import java.util.HashSet;
-import java.util.Set;
-
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.config.TransportConfiguration;
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import static org.jboss.messaging.core.config.impl.ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS;
 import org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory;
 import org.jboss.messaging.core.security.Role;
 import org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl;
@@ -38,6 +34,9 @@
 import org.jboss.messaging.core.server.MessagingService;
 import org.jboss.messaging.core.settings.HierarchicalRepository;
 
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * A SecurityManagementTest
  *
@@ -110,10 +109,10 @@
       securityManager.addRole(invalidAdminUser, "guest");
 
       Set<Role> adminRole = new HashSet<Role>();
-      adminRole.add(new Role("admin", true, true, false));
+      adminRole.add(new Role("admin", true, true, false, true, true, true, true));
       securityRepository.addMatch(DEFAULT_MANAGEMENT_ADDRESS.toString(), adminRole);
       Set<Role> guestRole = new HashSet<Role>();
-      guestRole.add(new Role("guest", true, true, true));
+      guestRole.add(new Role("guest", true, true, true, true, true, true, true));
       securityRepository.addMatch("*", guestRole);
       
       return service;

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/paging/PageCrashTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/paging/PageCrashTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/paging/PageCrashTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,13 +22,6 @@
 
 package org.jboss.messaging.tests.integration.paging;
 
-import java.io.File;
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.List;
-import java.util.concurrent.Executor;
-
 import org.jboss.messaging.core.client.ClientConsumer;
 import org.jboss.messaging.core.client.ClientMessage;
 import org.jboss.messaging.core.client.ClientProducer;
@@ -59,6 +52,13 @@
 import org.jboss.messaging.utils.OrderedExecutorFactory;
 import org.jboss.messaging.utils.SimpleString;
 
+import java.io.File;
+import java.lang.management.ManagementFactory;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.Executor;
+
 /**
  * This test will make sure that a failing depage won't cause duplicated messages
  *
@@ -237,7 +237,7 @@
 
       RemotingService remotingService = new RemotingServiceImpl(configuration);
 
-      JBMSecurityManager securityManager = new JBMSecurityManagerImpl(true);
+      JBMSecurityManager securityManager = new JBMSecurityManagerImpl();
 
       ManagementService managementService = new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(), false);
 
@@ -327,11 +327,6 @@
          {
 
             /**
-             * @param pagingManager
-             * @param storageManager
-             * @param postOffice
-             * @param fileFactory
-             * @param storeFactory
              * @param storeName
              * @param addressSettings
              * @param executor

Added: trunk/tests/src/org/jboss/messaging/tests/integration/security/SecurityTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/security/SecurityTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/security/SecurityTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -0,0 +1,953 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.tests.integration.security;
+
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ClientSessionFactory;
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.security.JBMUpdateableSecurityManager;
+import org.jboss.messaging.core.security.Role;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.settings.HierarchicalRepository;
+import org.jboss.messaging.integration.security.JAASSecurityManager;
+import org.jboss.messaging.tests.util.ServiceTestBase;
+import org.jboss.messaging.utils.SimpleString;
+import org.jboss.security.SimpleGroup;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+import java.io.IOException;
+import java.security.acl.Group;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ */
+public class SecurityTest extends ServiceTestBase
+{
+   /*
+   *  create session tests
+    *  */
+   private static final String addressA = "addressA";
+
+   private static final String queueA = "queueA";
+
+   public void testCreateSessionWithNullUserPass() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+      JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+      securityManager.addUser("guest", "guest");
+      securityManager.setDefaultUser("guest");
+      try
+      {
+         messagingService.start();
+         ClientSessionFactory cf = createInVMFactory();
+
+         try
+         {
+            ClientSession session = cf.createSession(false, true, true);
+         }
+         catch (MessagingException e)
+         {
+            fail("should not throw exception");
+         }
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testCreateSessionWithNullUserPassNoGuest() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+      try
+      {
+         messagingService.start();
+         ClientSessionFactory cf = createInVMFactory();
+         try
+         {
+            ClientSession session = cf.createSession(false, true, true);
+            fail("should not throw exception");
+         }
+         catch (MessagingException e)
+         {
+            assertEquals(MessagingException.SECURITY_EXCEPTION, e.getCode());
+         }
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testCreateSessionWithCorrectUserWrongPass() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+      JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+      securityManager.addUser("newuser", "apass");
+      try
+      {
+         messagingService.start();
+         ClientSessionFactory cf = createInVMFactory();
+
+         try
+         {
+            ClientSession session = cf.createSession("newuser", "awrongpass", false, true, true, false, -1);
+            fail("should not throw exception");
+         }
+         catch (MessagingException e)
+         {
+            assertEquals(MessagingException.SECURITY_EXCEPTION, e.getCode());
+         }
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testCreateSessionWithCorrectUserCorrectPass() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+      JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+      securityManager.addUser("newuser", "apass");
+      try
+      {
+         messagingService.start();
+         ClientSessionFactory cf = createInVMFactory();
+
+         try
+         {
+            ClientSession session = cf.createSession("newuser", "apass", false, true, true, false, -1);
+         }
+         catch (MessagingException e)
+         {
+            fail("should not throw exception");
+         }
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+
+   public void testCreateDurableQueueWithRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", false, false, true, false, false, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(addressA, roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         session.createQueue(addressA, queueA, true);
+         session.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testCreateDurableQueueWithoutRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", false, false, false, false, false, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(addressA, roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         try
+         {
+            session.createQueue(addressA, queueA, true);
+            fail("should throw exception");
+         }
+         catch (MessagingException e)
+         {
+            assertEquals(MessagingException.SECURITY_EXCEPTION, e.getCode());
+         }
+         session.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testDeleteDurableQueueWithRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", false, false, true, true, false, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(addressA, roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         session.createQueue(addressA, queueA, true);
+         session.deleteQueue(queueA);
+         session.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testDeleteDurableQueueWithoutRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", false, false, true, false, false, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(addressA, roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         session.createQueue(addressA, queueA, true);
+         try
+         {
+            session.deleteQueue(queueA);
+            fail("should throw exception");
+         }
+         catch (MessagingException e)
+         {
+            assertEquals(MessagingException.SECURITY_EXCEPTION, e.getCode());
+         }
+         session.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testCreateTempQueueWithRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", false, false, false, false, true, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(addressA, roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         session.createQueue(addressA, queueA, false, true);
+         session.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+
+   public void testCreateTempQueueWithoutRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", false, false, false, false, false, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(addressA, roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         try
+         {
+            session.createQueue(addressA, queueA, false, true);
+            fail("should throw exception");
+         }
+         catch (MessagingException e)
+         {
+            assertEquals(MessagingException.SECURITY_EXCEPTION, e.getCode());
+         }
+         session.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testDeleteTempQueueWithRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", false, false, false, false, true, true, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(addressA, roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         session.createQueue(addressA, queueA, false, true);
+         session.deleteQueue(queueA);
+         session.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testDeleteTempQueueWithoutRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", false, false, false, false, true, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(addressA, roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         session.createQueue(addressA, queueA, false, true);
+         try
+         {
+            session.deleteQueue(queueA);
+            fail("should throw exception");
+         }
+         catch (MessagingException e)
+         {
+            assertEquals(MessagingException.SECURITY_EXCEPTION, e.getCode());
+         }
+         session.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+
+   public void testSendWithRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", true, false, true, false, false, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(addressA, roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         cf.setBlockOnNonPersistentSend(true);
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         session.createQueue(addressA, queueA, true);
+         ClientProducer cp = session.createProducer(addressA);
+         cp.send(session.createClientMessage(false));
+         session.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testSendWithoutRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", false, false, true, false, false, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(addressA, roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         cf.setBlockOnNonPersistentSend(true);
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         session.createQueue(addressA, queueA, true);
+         ClientProducer cp = session.createProducer(addressA);
+         try
+         {
+            cp.send(session.createClientMessage(false));
+         }
+         catch (MessagingException e)
+         {
+            assertEquals(MessagingException.SECURITY_EXCEPTION, e.getCode());
+         }
+         session.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testNonBlockSendWithoutRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", false, false, true, false, false, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(addressA, roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         session.createQueue(addressA, queueA, true);
+         ClientProducer cp = session.createProducer(addressA);
+         cp.send(session.createClientMessage(false));
+         session.close();
+
+         Queue binding = (Queue) messagingService.getServer().getPostOffice().getBinding(new SimpleString(queueA)).getBindable();
+         assertEquals(0, binding.getMessageCount());
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testCreateConsumerWithRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         securityManager.addUser("guest", "guest");
+         securityManager.addRole("guest", "guest");
+         securityManager.setDefaultUser("guest");
+         Role role = new Role("arole", false, true, false, false, false, false, false);
+         Role sendRole = new Role("guest", true, false, true, false, false, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(sendRole);
+         roles.add(role);
+         securityRepository.addMatch(addressA, roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         ClientSession senSession = cf.createSession(false, true, true);
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         senSession.createQueue(addressA, queueA, true);
+         ClientProducer cp = senSession.createProducer(addressA);
+         cp.send(session.createClientMessage(false));
+         ClientConsumer cc = session.createConsumer(queueA);
+         session.close();
+         senSession.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testCreateConsumerWithoutRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         securityManager.addUser("guest", "guest");
+         securityManager.addRole("guest", "guest");
+         securityManager.setDefaultUser("guest");
+         Role role = new Role("arole", false, false, false, false, false, false, false);
+         Role sendRole = new Role("guest", true, false, true, false, false, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(sendRole);
+         roles.add(role);
+         securityRepository.addMatch(addressA, roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         ClientSession senSession = cf.createSession(false, true, true);
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         senSession.createQueue(addressA, queueA, true);
+         ClientProducer cp = senSession.createProducer(addressA);
+         cp.send(session.createClientMessage(false));
+         try
+         {
+            ClientConsumer cc = session.createConsumer(queueA);
+         }
+         catch (MessagingException e)
+         {
+            assertEquals(MessagingException.SECURITY_EXCEPTION, e.getCode());
+         }
+         session.close();
+         senSession.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testSendManagementWithRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", false, false, false, false, false, false, true);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(configuration.getManagementAddress().toString(), roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         cf.setBlockOnNonPersistentSend(true);
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         ClientProducer cp = session.createProducer(configuration.getManagementAddress());
+         cp.send(session.createClientMessage(false));
+         session.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testSendManagementWithoutRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", false, false, true, false, false, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(configuration.getManagementAddress().toString(), roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         session.createQueue(configuration.getManagementAddress().toString(), queueA, true);
+         ClientProducer cp = session.createProducer(configuration.getManagementAddress());
+         cp.send(session.createClientMessage(false));
+         try
+         {
+            cp.send(session.createClientMessage(false));
+         }
+         catch (MessagingException e)
+         {
+            assertEquals(MessagingException.SECURITY_EXCEPTION, e.getCode());
+         }
+         session.close();
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testNonBlockSendManagementWithoutRole() throws Exception
+   {
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+
+      try
+      {
+         messagingService.start();
+         HierarchicalRepository<Set<Role>> securityRepository = messagingService.getServer().getSecurityRepository();
+         JBMUpdateableSecurityManager securityManager = (JBMUpdateableSecurityManager) messagingService.getServer().getSecurityManager();
+         securityManager.addUser("auser", "pass");
+         Role role = new Role("arole", false, false, true, false, false, false, false);
+         Set<Role> roles = new HashSet<Role>();
+         roles.add(role);
+         securityRepository.addMatch(configuration.getManagementAddress().toString(), roles);
+         securityManager.addRole("auser", "arole");
+         ClientSessionFactory cf = createInVMFactory();
+         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         session.createQueue(configuration.getManagementAddress().toString(), queueA, true);
+         ClientProducer cp = session.createProducer(configuration.getManagementAddress());
+         cp.send(session.createClientMessage(false));
+         session.close();
+
+         Queue binding = (Queue) messagingService.getServer().getPostOffice().getBinding(new SimpleString(queueA)).getBindable();
+         assertEquals(0, binding.getMessageCount());
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+   /*
+  * basic JAAS tests
+  * */
+
+
+   public void testJaasCreateSessionSucceeds() throws Exception
+   {
+      String domainName = SimpleLogingModule.class.getName();
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+      JAASSecurityManager securityManager = new JAASSecurityManager();
+      messagingService.getServer().setSecurityManager(securityManager);
+
+      securityManager.setConfigurationName(domainName);
+      securityManager.setCallbackHandler(new CallbackHandler()
+      {
+         public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
+         {
+            // empty callback, auth info are directly passed as options to the login module
+         }
+      });
+      Map<String, Object> options = new HashMap<String, Object>();
+      options.put("authenticated", Boolean.TRUE);
+      securityManager.setConfiguration(new SimpleConfiguration(domainName, options));
+      try
+      {
+         messagingService.start();
+         ClientSessionFactory cf = createInVMFactory();
+
+         try
+         {
+            ClientSession session = cf.createSession(false, true, true);
+         }
+         catch (MessagingException e)
+         {
+            fail("should not throw exception");
+         }
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public void testJaasCreateSessionFails() throws Exception
+   {
+      String domainName = SimpleLogingModule.class.getName();
+      Configuration configuration = createDefaultConfig(false);
+      configuration.setSecurityEnabled(true);
+      MessagingService messagingService = createService(false, configuration);
+      JAASSecurityManager securityManager = new JAASSecurityManager();
+      messagingService.getServer().setSecurityManager(securityManager);
+
+      securityManager.setConfigurationName(domainName);
+      securityManager.setCallbackHandler(new CallbackHandler()
+      {
+         public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
+         {
+            // empty callback, auth info are directly passed as options to the login module
+         }
+      });
+      Map<String, Object> options = new HashMap<String, Object>();
+      options.put("authenticated", Boolean.FALSE);
+      securityManager.setConfiguration(new SimpleConfiguration(domainName, options));
+      try
+      {
+         messagingService.start();
+         ClientSessionFactory cf = createInVMFactory();
+
+         try
+         {
+            ClientSession session = cf.createSession(false, true, true);
+            fail("should not throw exception");
+         }
+         catch (MessagingException e)
+         {
+            assertEquals(MessagingException.SECURITY_EXCEPTION, e.getCode());
+         }
+      }
+      finally
+      {
+         if (messagingService.isStarted())
+         {
+            messagingService.stop();
+         }
+      }
+   }
+
+   public static class SimpleLogingModule implements LoginModule
+   {
+      private Map<String, ?> options;
+
+      private Subject subject;
+
+      public SimpleLogingModule()
+      {
+      }
+
+      public boolean abort() throws LoginException
+      {
+         return true;
+      }
+
+      public boolean commit() throws LoginException
+      {
+         return true;
+      }
+
+      public void initialize(Subject subject,
+                             CallbackHandler callbackHandler,
+                             Map<String, ?> sharedState,
+                             Map<String, ?> options)
+      {
+         this.subject = subject;
+         this.options = options;
+      }
+
+      public boolean login() throws LoginException
+      {
+         boolean authenticated = (Boolean) options.get("authenticated");
+         if (authenticated)
+         {
+            Group roles = new SimpleGroup("Roles");
+            roles.addMember(new JAASSecurityManager.SimplePrincipal((String) options.get("role")));
+            subject.getPrincipals().add(roles);
+         }
+         return authenticated;
+
+      }
+
+      public Subject getSubject()
+      {
+         return subject;
+      }
+
+      public boolean logout() throws LoginException
+      {
+         return true;
+      }
+   }
+
+   public static class SimpleConfiguration extends javax.security.auth.login.Configuration
+   {
+      private Map<String, ?> options;
+
+      private String loginModuleName;
+
+      public SimpleConfiguration(String loginModuleName, Map<String, ?> options)
+      {
+         this.loginModuleName = loginModuleName;
+         this.options = options;
+      }
+
+      @Override
+      public AppConfigurationEntry[] getAppConfigurationEntry(String name)
+      {
+         AppConfigurationEntry entry = new AppConfigurationEntry(loginModuleName,
+                                                                 AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
+                                                                 options);
+         return new AppConfigurationEntry[]{entry};
+      }
+
+      @Override
+      public void refresh()
+      {
+      }
+   }
+}

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/SecurityDeployerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/SecurityDeployerTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/SecurityDeployerTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,23 +22,14 @@
 
 package org.jboss.messaging.tests.unit.core.deployers.impl;
 
-import java.util.HashSet;
-import java.util.Set;
-
-import org.easymock.EasyMock;
-import org.jboss.messaging.core.deployers.DeploymentManager;
-import org.jboss.messaging.core.deployers.impl.SecurityDeployer;
-import org.jboss.messaging.core.security.Role;
-import org.jboss.messaging.core.settings.HierarchicalRepository;
 import org.jboss.messaging.tests.util.UnitTestCase;
-import org.w3c.dom.Element;
 
 /**
  * @author <a href="ataylor at redhat.com">Andy Taylor</a>
  */
 public class SecurityDeployerTest extends UnitTestCase
 {
-   private SecurityDeployer deployer;
+   /*private SecurityDeployer deployer;
    private String conf = 
            "   <security match=\"topics.testTopic\">\n" +
            "      <permission type=\"create\" roles=\"durpublisher\"/>\n" +
@@ -66,13 +57,13 @@
       DeploymentManager deploymentManager = EasyMock.createNiceMock(DeploymentManager.class);
       deployer = new SecurityDeployer(deploymentManager, repository);
    }
-
+   **/
    public void testSingle() throws Exception
    {
-      Element e = org.jboss.messaging.utils.XMLUtil.stringToElement(conf);
-      Role role = new Role("durpublisher", true, true, true);
-      Role role2 = new Role("guest", true, true, false);
-      Role role3 = new Role("publisher", true, true, false);
+      /*Element e = org.jboss.messaging.utils.XMLUtil.stringToElement(conf);
+      Role role = new Role("durpublisher", true, true, true, true, true, true);
+      Role role2 = new Role("guest", true, true, false, true, true, true);
+      Role role3 = new Role("publisher", true, true, false, true, true, true);
       HashSet<Role> roles = new HashSet<Role>();
       roles.add(role);
       roles.add(role2);
@@ -80,14 +71,14 @@
       repository.addMatch("topics.testTopic", roles);
       EasyMock.replay(repository);
       deployer.deploy(e);
-      EasyMock.verify(repository);
+      EasyMock.verify(repository);*/
    }
-
+   /**
    public void testMultiple() throws Exception
    {
-      Role role = new Role("durpublisher", true, true, true);
-      Role role2 = new Role("guest", true, true, false);
-      Role role3 = new Role("publisher", true, true, false);
+      Role role = new Role("durpublisher", true, true, true, true, true, true);
+      Role role2 = new Role("guest", true, true, false, true, true, true);
+      Role role3 = new Role("publisher", true, true, false, true, true, true);
       HashSet<Role> roles = new HashSet<Role>();
       roles.add(role);
       roles.add(role2);
@@ -107,5 +98,5 @@
       EasyMock.replay(repository);
       deployer.deploy(org.jboss.messaging.utils.XMLUtil.stringToElement(noRoles));
       EasyMock.verify(repository);
-   }
+   }*/
 }

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/management/RoleInfoTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/management/RoleInfoTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/management/RoleInfoTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,13 +22,6 @@
 
 package org.jboss.messaging.tests.unit.core.management;
 
-import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
-
-import org.jboss.messaging.core.management.RoleInfo;
 import org.jboss.messaging.tests.util.UnitTestCase;
 
 /**
@@ -45,7 +38,7 @@
 
    // Static --------------------------------------------------------
 
-   private static void assertEquals(RoleInfo expected, CompositeData actual)
+   /*private static void assertEquals(RoleInfo expected, CompositeData actual)
    {
       assertTrue(actual.getCompositeType().equals(RoleInfo.TYPE));
 
@@ -58,26 +51,26 @@
    // Constructors --------------------------------------------------
 
    // Public --------------------------------------------------------
-
+   **/
    public void testToCompositeData() throws Exception
    {
-      String name = randomString();
+     /* String name = randomString();
       boolean create = randomBoolean();
       boolean read = randomBoolean();
       boolean write = randomBoolean();
 
-      RoleInfo info = new RoleInfo(name, create, read, write);
+      RoleInfo info = new RoleInfo(name, create, read, write, deleteDurableQueue, createTempQueue, deleteTempQueue);
       CompositeData data = info.toCompositeData();
 
-      assertEquals(info, data);
+      assertEquals(info, data);*/
    }
-
+   /**
    public void testToTabularData() throws Exception
    {
       RoleInfo info_1 = new RoleInfo(randomString(), randomBoolean(),
-            randomBoolean(), randomBoolean());
+            randomBoolean(), randomBoolean(), deleteDurableQueue, createTempQueue, deleteTempQueue);
       RoleInfo info_2 = new RoleInfo(randomString(), randomBoolean(),
-            randomBoolean(), randomBoolean());
+            randomBoolean(), randomBoolean(), deleteDurableQueue, createTempQueue, deleteTempQueue);
       RoleInfo[] roles = new RoleInfo[] { info_1, info_2 };
 
       TabularData data = RoleInfo.toTabularData(roles);
@@ -93,7 +86,7 @@
    {
       TabularData data = RoleInfo.toTabularData(new RoleInfo[0]);
       assertEquals(0, data.size());
-   }
+   }*/
 
    // Package protected ---------------------------------------------
 

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/security/RoleTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/security/RoleTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/security/RoleTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,10 +22,12 @@
 
 package org.jboss.messaging.tests.unit.core.security;
 
-import static org.jboss.messaging.core.security.CheckType.CREATE;
-import static org.jboss.messaging.core.security.CheckType.READ;
-import static org.jboss.messaging.core.security.CheckType.WRITE;
-
+import static org.jboss.messaging.core.security.CheckType.CONSUME;
+import static org.jboss.messaging.core.security.CheckType.CREATE_DURABLE_QUEUE;
+import static org.jboss.messaging.core.security.CheckType.CREATE_TEMP_QUEUE;
+import static org.jboss.messaging.core.security.CheckType.DELETE_DURABLE_QUEUE;
+import static org.jboss.messaging.core.security.CheckType.DELETE_TEMP_QUEUE;
+import static org.jboss.messaging.core.security.CheckType.SEND;
 import org.jboss.messaging.core.security.Role;
 import org.jboss.messaging.tests.util.UnitTestCase;
 
@@ -47,47 +49,48 @@
 
    // Public --------------------------------------------------------
 
-   public void testDefaultRole() throws Exception
-   {
-      Role role = new Role("testDefaultRole");
-      assertEquals("testDefaultRole", role.getName());
-      assertFalse(role.isCheckType(READ));
-      assertFalse(role.isCheckType(WRITE));
-      assertFalse(role.isCheckType(CREATE));      
-   }
    
    public void testReadRole() throws Exception
    {
-      Role role = new Role("testReadRole", true, false, false);
-      assertTrue(role.isCheckType(READ));
-      assertFalse(role.isCheckType(WRITE));
-      assertFalse(role.isCheckType(CREATE));      
+      Role role = new Role("testReadRole", true, false, false, false, false, false, false);
+      assertTrue(SEND.hasRole(role));
+      assertFalse(CONSUME.hasRole(role));
+      assertFalse(CREATE_DURABLE_QUEUE.hasRole(role));
+      assertFalse(CREATE_TEMP_QUEUE.hasRole(role));
+      assertFalse(DELETE_DURABLE_QUEUE.hasRole(role));
+      assertFalse(DELETE_TEMP_QUEUE.hasRole(role));
    }
    
    public void testWriteRole() throws Exception
    {
-      Role role = new Role("testWriteRole", false, true, false);
-      assertFalse(role.isCheckType(READ));
-      assertTrue(role.isCheckType(WRITE));
-      assertFalse(role.isCheckType(CREATE));      
+      Role role = new Role("testWriteRole", false, true, false, false, false, false, false);
+      assertFalse(SEND.hasRole(role));
+      assertTrue(CONSUME.hasRole(role));
+      assertFalse(CREATE_DURABLE_QUEUE.hasRole(role));
+      assertFalse(CREATE_TEMP_QUEUE.hasRole(role));
+      assertFalse(DELETE_DURABLE_QUEUE.hasRole(role));
+      assertFalse(DELETE_TEMP_QUEUE.hasRole(role));
    }
 
    public void testCreateRole() throws Exception
    {
-      Role role = new Role("testWriteRole", false, false, true);
-      assertFalse(role.isCheckType(READ));
-      assertFalse(role.isCheckType(WRITE));
-      assertTrue(role.isCheckType(CREATE));      
+      Role role = new Role("testWriteRole", false, false, true, false, false, false, false);
+      assertFalse(SEND.hasRole(role));
+      assertFalse(CONSUME.hasRole(role));
+      assertTrue(CREATE_DURABLE_QUEUE.hasRole(role));
+      assertFalse(CREATE_TEMP_QUEUE.hasRole(role));
+      assertFalse(DELETE_DURABLE_QUEUE.hasRole(role));
+      assertFalse(DELETE_TEMP_QUEUE.hasRole(role));
    }
    
    public void testEqualsAndHashcode() throws Exception
    {
-      Role role = new Role("testEquals", true, true, true);
-      Role sameRole = new Role("testEquals", true, true, true);
-      Role roleWithDifferentName = new Role("notEquals", true, true, true);
-      Role roleWithDifferentRead = new Role("testEquals", false, true, true);
-      Role roleWithDifferentWrite = new Role("testEquals", true, false, true);
-      Role roleWithDifferentCreate = new Role("testEquals", true, true, false);
+      Role role = new Role("testEquals", true, true, true, false, false, false, false);
+      Role sameRole = new Role("testEquals", true, true, true, false, false, false, false);
+      Role roleWithDifferentName = new Role("notEquals", true, true, true, false, false, false, false);
+      Role roleWithDifferentRead = new Role("testEquals", false, true, true, false, false, false, false);
+      Role roleWithDifferentWrite = new Role("testEquals", true, false, true, false, false, false, false);
+      Role roleWithDifferentCreate = new Role("testEquals", true, true, false, false, false, false, false);
 
       assertTrue(role.equals(role));
 

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/JAASSecurityManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/JAASSecurityManagerTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/JAASSecurityManagerTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,31 +22,30 @@
 
 package org.jboss.messaging.tests.unit.core.security.impl;
 
-import java.io.IOException;
-import java.security.Principal;
-import java.security.acl.Group;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
+import org.jboss.messaging.core.security.CheckType;
+import org.jboss.messaging.core.security.Role;
+import org.jboss.messaging.integration.security.JAASSecurityManager;
+import org.jboss.messaging.tests.util.UnitTestCase;
+import org.jboss.security.SimpleGroup;
 
 import javax.security.auth.Subject;
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
 import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
 import javax.security.auth.login.Configuration;
 import javax.security.auth.login.LoginException;
-import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
 import javax.security.auth.spi.LoginModule;
+import java.io.IOException;
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
 
-import org.jboss.messaging.core.security.CheckType;
-import org.jboss.messaging.core.security.Role;
-import org.jboss.messaging.integration.security.JAASSecurityManager;
-import org.jboss.messaging.tests.util.UnitTestCase;
-import org.jboss.security.SimpleGroup;
-
 /**
  * tests the JAASSecurityManager
  *
@@ -103,13 +102,13 @@
    public void testValidatingUserAndRole()
    {
       Set<Role> roles = new HashSet<Role>();
-      roles.add(new Role(ROLE, true, true, true));
+      roles.add(new Role(ROLE, true, true, true, true, true, true, true));
 
-      assertTrue(securityManager.validateUserAndRole(USER, PASSWORD, roles, CheckType.CREATE));
+      assertTrue(securityManager.validateUserAndRole(USER, PASSWORD, roles, CheckType.CREATE_DURABLE_QUEUE));
 
       roles.clear();
-      roles.add(new Role(INVALID_ROLE, true, true, true));
-      assertFalse(securityManager.validateUserAndRole(USER, PASSWORD, roles, CheckType.CREATE));
+      roles.add(new Role(INVALID_ROLE, true, true, true, true, true, true, true));
+      assertFalse(securityManager.validateUserAndRole(USER, PASSWORD, roles, CheckType.CREATE_DURABLE_QUEUE));
    }
 
    public static class SimpleLogingModule implements LoginModule

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/JBMSecurityManagerImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/JBMSecurityManagerImplTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/JBMSecurityManagerImplTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,13 +22,13 @@
 
 package org.jboss.messaging.tests.unit.core.security.impl;
 
-import java.util.HashSet;
-
 import org.jboss.messaging.core.security.CheckType;
 import org.jboss.messaging.core.security.Role;
 import org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl;
 import org.jboss.messaging.tests.util.UnitTestCase;
 
+import java.util.HashSet;
+
 /**
  * tests JBMSecurityManagerImpl
  *
@@ -42,7 +42,7 @@
    {
       super.setUp();
       
-      securityManager = new JBMSecurityManagerImpl(true);
+      securityManager = new JBMSecurityManagerImpl();
    }
 
    protected void tearDown() throws Exception
@@ -54,28 +54,31 @@
 
    public void testDefaultSecurity()
    {
+      securityManager.addUser("guest", "guest");
+      securityManager.addRole("guest", "guest");
+      securityManager.setDefaultUser("guest");
       assertTrue(securityManager.validateUser(null, null));
       assertTrue(securityManager.validateUser("guest", "guest"));
       HashSet<Role> roles = new HashSet<Role>();
-      roles.add(new Role("guest", true, true, true));
-      assertTrue(securityManager.validateUserAndRole(null, null, roles, CheckType.CREATE));
-      assertTrue(securityManager.validateUserAndRole(null, null, roles, CheckType.WRITE));
-      assertTrue(securityManager.validateUserAndRole(null, null, roles, CheckType.READ));
+      roles.add(new Role("guest", true, true, true, true, true, true, true));
+      assertTrue(securityManager.validateUserAndRole(null, null, roles, CheckType.CREATE_DURABLE_QUEUE));
+      assertTrue(securityManager.validateUserAndRole(null, null, roles, CheckType.SEND));
+      assertTrue(securityManager.validateUserAndRole(null, null, roles, CheckType.CONSUME));
       roles = new HashSet<Role>();
-      roles.add(new Role("guest", true, true, false));
-      assertFalse(securityManager.validateUserAndRole(null, null, roles, CheckType.CREATE));
-      assertTrue(securityManager.validateUserAndRole(null, null, roles, CheckType.WRITE));
-      assertTrue(securityManager.validateUserAndRole(null, null, roles, CheckType.READ));
+      roles.add(new Role("guest", true, true, false, true, true, true, true));
+      assertFalse(securityManager.validateUserAndRole(null, null, roles, CheckType.CREATE_DURABLE_QUEUE));
+      assertTrue(securityManager.validateUserAndRole(null, null, roles, CheckType.SEND));
+      assertTrue(securityManager.validateUserAndRole(null, null, roles, CheckType.CONSUME));
       roles = new HashSet<Role>();
-      roles.add(new Role("guest", true, false, false));
-      assertFalse(securityManager.validateUserAndRole(null, null, roles, CheckType.CREATE));
-      assertFalse(securityManager.validateUserAndRole(null, null, roles, CheckType.WRITE));
-      assertTrue(securityManager.validateUserAndRole(null, null, roles, CheckType.READ));
+      roles.add(new Role("guest", true, false, false, true, true, true, true));
+      assertFalse(securityManager.validateUserAndRole(null, null, roles, CheckType.CREATE_DURABLE_QUEUE));
+      assertTrue(securityManager.validateUserAndRole(null, null, roles, CheckType.SEND));
+      assertFalse(securityManager.validateUserAndRole(null, null, roles, CheckType.CONSUME));
       roles = new HashSet<Role>();
-      roles.add(new Role("guest", false, false, false));
-      assertFalse(securityManager.validateUserAndRole(null, null, roles, CheckType.CREATE));
-      assertFalse(securityManager.validateUserAndRole(null, null, roles, CheckType.WRITE));
-      assertFalse(securityManager.validateUserAndRole(null, null, roles, CheckType.READ));
+      roles.add(new Role("guest", false, false, false, true, true, true, true));
+      assertFalse(securityManager.validateUserAndRole(null, null, roles, CheckType.CREATE_DURABLE_QUEUE));
+      assertFalse(securityManager.validateUserAndRole(null, null, roles, CheckType.SEND));
+      assertFalse(securityManager.validateUserAndRole(null, null, roles, CheckType.CONSUME));
    }
 
    public void testAddingUsers()
@@ -128,20 +131,20 @@
       securityManager.addRole("newuser1", "role3");
       securityManager.addRole("newuser1", "role4");
       HashSet<Role> roles = new HashSet<Role>();
-      roles.add(new Role("role1", true, true, true));
-      assertTrue(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.WRITE));
+      roles.add(new Role("role1", true, true, true, true, true, true, true));
+      assertTrue(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.SEND));
       roles = new HashSet<Role>();
-      roles.add(new Role("role2", true, true, true));
-      assertTrue(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.WRITE));
+      roles.add(new Role("role2", true, true, true, true, true, true, true));
+      assertTrue(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.SEND));
       roles = new HashSet<Role>();
-      roles.add(new Role("role3", true, true, true));
-      assertTrue(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.WRITE));
+      roles.add(new Role("role3", true, true, true, true, true, true, true));
+      assertTrue(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.SEND));
       roles = new HashSet<Role>();
-      roles.add(new Role("role4", true, true, true));
-      assertTrue(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.WRITE));
+      roles.add(new Role("role4", true, true, true, true, true, true, true));
+      assertTrue(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.SEND));
       roles = new HashSet<Role>();
-      roles.add(new Role("role5", true, true, true));
-      assertFalse(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.WRITE));
+      roles.add(new Role("role5", true, true, true, true, true, true, true));
+      assertFalse(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.SEND));
    }
 
    public void testRemovingRoles()
@@ -154,19 +157,19 @@
       securityManager.removeRole("newuser1", "role2");
       securityManager.removeRole("newuser1", "role4");
       HashSet<Role> roles = new HashSet<Role>();
-      roles.add(new Role("role1", true, true, true));
-      assertTrue(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.WRITE));
+      roles.add(new Role("role1", true, true, true, true, true, true, true));
+      assertTrue(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.SEND));
       roles = new HashSet<Role>();
-      roles.add(new Role("role2", true, true, true));
-      assertFalse(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.WRITE));
+      roles.add(new Role("role2", true, true, true, true, true, true, true));
+      assertFalse(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.SEND));
       roles = new HashSet<Role>();
-      roles.add(new Role("role3", true, true, true));
-      assertTrue(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.WRITE));
+      roles.add(new Role("role3", true, true, true, true, true, true, true));
+      assertTrue(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.SEND));
       roles = new HashSet<Role>();
-      roles.add(new Role("role4", true, true, true));
-      assertFalse(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.WRITE));
+      roles.add(new Role("role4", true, true, true, true, true, true, true));
+      assertFalse(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.SEND));
       roles = new HashSet<Role>();
-      roles.add(new Role("role5", true, true, true));
-      assertFalse(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.WRITE));
+      roles.add(new Role("role5", true, true, true, true, true, true, true));
+      assertFalse(securityManager.validateUserAndRole("newuser1", "newpassword1", roles, CheckType.SEND));
    }
 }

Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/JBossASSecurityManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/JBossASSecurityManagerTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/JBossASSecurityManagerTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -1,155 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
-
-package org.jboss.messaging.tests.unit.core.security.impl;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import org.easymock.EasyMock;
-import org.easymock.IArgumentMatcher;
-import org.jboss.messaging.core.security.CheckType;
-import org.jboss.messaging.core.security.Role;
-import org.jboss.messaging.integration.security.JBossASSecurityManager;
-import org.jboss.messaging.tests.util.UnitTestCase;
-import org.jboss.security.AuthenticationManager;
-import org.jboss.security.RealmMapping;
-import org.jboss.security.SimplePrincipal;
-
-/**
- * tests the JBossASSecurityManager
- *
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-public class JBossASSecurityManagerTest extends UnitTestCase
-{
-   private JBossASSecurityManager securityManager;
-
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-      
-      securityManager = new JBossASSecurityManager();
-   }
-
-   protected void tearDown() throws Exception
-   {
-      securityManager = null;
-      
-      super.tearDown();
-   }
-
-   public void testValidatingUser()
-   {
-      AuthenticationManager authenticationManager = EasyMock.createStrictMock(AuthenticationManager.class);
-      securityManager.setAuthenticationManager(authenticationManager);
-      SimplePrincipal principal = new SimplePrincipal("newuser1");
-      char[] passwordChars = "newpassword1".toCharArray();
-      Subject subject = new Subject();
-      EasyMock.expect(authenticationManager.isValid(principal(principal), EasyMock.aryEq(passwordChars), subject(subject))).andReturn(true);
-      EasyMock.replay(authenticationManager);
-
-      securityManager.validateUser("newuser1", "newpassword1");
-   }
-
-   public void testValidatingUserAndRole()
-   {
-      AuthenticationManager authenticationManager = EasyMock.createStrictMock(AuthenticationManager.class);
-      securityManager.setAuthenticationManager(authenticationManager);
-      RealmMapping realmMapping = EasyMock.createStrictMock(RealmMapping.class);
-      securityManager.setRealmMapping(realmMapping);
-      SimplePrincipal principal = new SimplePrincipal("newuser1");
-      char[] passwordChars = "newpassword1".toCharArray();
-      Subject subject = new Subject();
-      EasyMock.expect(authenticationManager.isValid(principal(principal), EasyMock.aryEq(passwordChars), subject(subject))).andReturn(true);
-      EasyMock.replay(authenticationManager);
-      EasyMock.expect(realmMapping.doesUserHaveRole(principal(principal), EasyMock.isA(Set.class))).andReturn(true);
-      EasyMock.replay(realmMapping);
-      HashSet<Role> roleHashSet = new HashSet<Role>();
-      roleHashSet.add(new Role("newuser1", true, true, true));
-      securityManager.validateUserAndRole("newuser1", "newpassword1", roleHashSet, CheckType.CREATE);
-   }
-   
-   public static SimplePrincipal principal(SimplePrincipal principal)
-   {
-      EasyMock.reportMatcher(new SimplePrincipalMatcher(principal));
-      return principal;
-   }
-
-   public static Subject subject(Subject subject)
-   {
-      EasyMock.reportMatcher(new SubjectMatcher(subject));
-      return subject;
-   }
-
-   private static class SimplePrincipalMatcher implements IArgumentMatcher
-   {
-      SimplePrincipal principal;
-
-      public SimplePrincipalMatcher(SimplePrincipal principal)
-      {
-         this.principal = principal;
-      }
-
-      public boolean matches(Object o)
-      {
-         if (o instanceof SimplePrincipal)
-         {
-            SimplePrincipal that = (SimplePrincipal) o;
-            return that.getName().equals(principal.getName());
-         }
-         return false;
-      }
-
-      public void appendTo(StringBuffer stringBuffer)
-      {
-         stringBuffer.append("Invalid Principal created");
-      }
-   }
-
-   private static class SubjectMatcher implements IArgumentMatcher
-   {
-      Subject subject;
-
-      public SubjectMatcher(Subject subject)
-      {
-         this.subject = subject;
-      }
-
-      public boolean matches(Object o)
-      {
-         if (o instanceof Subject)
-         {
-            Subject that = (Subject) o;
-            return true;
-         }
-         return false;
-      }
-
-      public void appendTo(StringBuffer stringBuffer)
-      {
-         stringBuffer.append("Invalid Subject created");
-      }
-   }     
-}

Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/SecurityStoreImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/SecurityStoreImplTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/security/impl/SecurityStoreImplTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -1,227 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
-
-package org.jboss.messaging.tests.unit.core.security.impl;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.easymock.EasyMock;
-import org.jboss.messaging.core.security.CheckType;
-import org.jboss.messaging.core.security.JBMSecurityManager;
-import org.jboss.messaging.core.security.Role;
-import org.jboss.messaging.core.security.impl.SecurityStoreImpl;
-import org.jboss.messaging.core.server.ServerSession;
-import org.jboss.messaging.core.settings.HierarchicalRepository;
-import org.jboss.messaging.tests.util.UnitTestCase;
-import org.jboss.messaging.utils.SimpleString;
-
-/**
- * tests SecurityStoreImpl
- *
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-public class SecurityStoreImplTest extends UnitTestCase
-{
-   SecurityStoreImpl securityStore;
-
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-      
-      securityStore = new SecurityStoreImpl(1000000000, true);
-   }
-
-   protected void tearDown() throws Exception
-   {
-      securityStore = null;
-      
-      super.tearDown();
-   }
-
-   public void testSuccessfulAuthentication() throws Exception
-   {
-      JBMSecurityManager securityManager = EasyMock.createStrictMock(JBMSecurityManager.class);
-      securityStore.setSecurityManager(securityManager);
-      EasyMock.expect(securityManager.validateUser("user", "password")).andReturn(true);
-      EasyMock.replay(securityManager);
-      securityStore.authenticate("user", "password");
-   }
-
-   public void testFailedAuthentication() throws Exception
-   {
-      JBMSecurityManager securityManager = EasyMock.createStrictMock(JBMSecurityManager.class);
-      securityStore.setSecurityManager(securityManager);
-      EasyMock.expect(securityManager.validateUser("user", "password")).andReturn(false);
-      EasyMock.replay(securityManager);
-      try
-      {
-         securityStore.authenticate("user", "password");
-         fail("should throw exception");
-      }
-      catch (Exception e)
-      {
-         //pass
-      }
-   }
-   
-   public void testSuccessfulCheck() throws Exception
-   {
-      testSuccessfulCheck(CheckType.CREATE);
-      testSuccessfulCheck(CheckType.READ);
-      testSuccessfulCheck(CheckType.WRITE);
-   }
- 
-   public void testUnsuccessfulCheck() throws Exception
-   {
-      testUnsuccessfulCheck(CheckType.CREATE);
-      testUnsuccessfulCheck(CheckType.READ);
-      testUnsuccessfulCheck(CheckType.WRITE);
-   }
-     
-   public void testSuccessfulCheckInvalidateCache() throws Exception
-   {
-      JBMSecurityManager securityManager = EasyMock.createStrictMock(JBMSecurityManager.class);
-      securityStore.setSecurityManager(securityManager);
-      //noinspection unchecked
-      HierarchicalRepository<Set<Role>> repository = EasyMock.createStrictMock(HierarchicalRepository.class);
-
-      SimpleString address = new SimpleString("anaddress");
-      Set<Role> roles = new HashSet<Role>();
-      roles.add(new Role("user", false, false, true));
-      repository.registerListener(securityStore);
-      EasyMock.expect(repository.getMatch(address.toString())).andReturn(roles);
-      ServerSession serverSession = EasyMock.createNiceMock(ServerSession.class);
-      EasyMock.expect(serverSession.getUsername()).andReturn("user");
-      EasyMock.expect(serverSession.getPassword()).andReturn("password");
-      EasyMock.expect(securityManager.validateUserAndRole("user", "password", roles, CheckType.CREATE)).andReturn(true);
-      EasyMock.expect(repository.getMatch(address.toString())).andReturn(roles);
-      EasyMock.expect(serverSession.getUsername()).andReturn("user");
-      EasyMock.expect(serverSession.getPassword()).andReturn("password");
-      EasyMock.expect(securityManager.validateUserAndRole("user", "password", roles, CheckType.CREATE)).andReturn(true);
-      EasyMock.replay(repository, securityManager, serverSession);
-      securityStore.setSecurityRepository(repository);
-      securityStore.check(address, CheckType.CREATE, serverSession);
-      securityStore.onChange();
-      securityStore.check(address, CheckType.CREATE, serverSession);
-      EasyMock.verify(repository, securityManager, serverSession);
-   }
-
-   public void testSuccessfulCheckTimeoutCache() throws Exception
-   {
-      testSuccessfulCheckTimeoutCache(CheckType.CREATE);
-      testSuccessfulCheckTimeoutCache(CheckType.READ);
-      testSuccessfulCheckTimeoutCache(CheckType.WRITE);
-   }
-     
-   // Private -----------------------------------------------------------------------
-   
-   private void testSuccessfulCheck(final CheckType checkType) throws Exception
-   {
-      JBMSecurityManager securityManager = EasyMock.createStrictMock(JBMSecurityManager.class);
-      securityStore.setSecurityManager(securityManager);
-      //noinspection unchecked
-      HierarchicalRepository<Set<Role>> repository = EasyMock.createStrictMock(HierarchicalRepository.class);
-
-      SimpleString address = new SimpleString("anaddress");
-      Set<Role> roles = new HashSet<Role>();
-      roles.add(new Role("user", false, false, true));
-      repository.registerListener(securityStore);
-      EasyMock.expect(repository.getMatch(address.toString())).andReturn(roles);
-      ServerSession serverSession = EasyMock.createNiceMock(ServerSession.class);
-      EasyMock.expect(serverSession.getUsername()).andReturn("user");
-      EasyMock.expect(serverSession.getPassword()).andReturn("password");
-      EasyMock.expect(securityManager.validateUserAndRole("user", "password", roles, checkType)).andReturn(true);
-      EasyMock.replay(repository, securityManager, serverSession);
-      securityStore.setSecurityRepository(repository);
-      securityStore.check(address, checkType, serverSession);
-      EasyMock.verify(repository, securityManager, serverSession);
-      //now checked its cached
-      EasyMock.reset(repository, securityManager, serverSession);
-      EasyMock.replay(repository, securityManager, serverSession);
-      securityStore.check(address, checkType, serverSession);
-      EasyMock.verify(repository, securityManager, serverSession);
-   }
-   
-   private void testUnsuccessfulCheck(final CheckType checkType) throws Exception
-   {
-      JBMSecurityManager securityManager = EasyMock.createStrictMock(JBMSecurityManager.class);
-      securityStore.setSecurityManager(securityManager);
-      //noinspection unchecked
-      HierarchicalRepository<Set<Role>> repository = EasyMock.createStrictMock(HierarchicalRepository.class);
-
-      SimpleString address = new SimpleString("anaddress");
-      Set<Role> roles = new HashSet<Role>();
-      roles.add(new Role("user", false, false, true));
-      repository.registerListener(securityStore);
-      EasyMock.expect(repository.getMatch(address.toString())).andReturn(roles);
-      ServerSession serverSession = EasyMock.createNiceMock(ServerSession.class);
-      EasyMock.expect(serverSession.getUsername()).andReturn("user");
-      EasyMock.expect(serverSession.getPassword()).andReturn("password");
-      EasyMock.expect(securityManager.validateUserAndRole("user", "password", roles, checkType)).andReturn(false);
-      EasyMock.replay(repository, securityManager, serverSession);
-      securityStore.setSecurityRepository(repository);
-      try
-      {
-         securityStore.check(address, checkType, serverSession);
-         fail("should throw exception");
-      }
-      catch (Exception e)
-      {
-         //pass
-      }
-      EasyMock.verify(repository, securityManager, serverSession);
-   }
-   
-   private void testSuccessfulCheckTimeoutCache(final CheckType checkType) throws Exception
-   {
-      securityStore = new SecurityStoreImpl(100, true);
-      JBMSecurityManager securityManager = EasyMock.createStrictMock(JBMSecurityManager.class);
-      securityStore.setSecurityManager(securityManager);
-      //noinspection unchecked
-      HierarchicalRepository<Set<Role>> repository = EasyMock.createStrictMock(HierarchicalRepository.class);
-
-      SimpleString address = new SimpleString("anaddress");
-      Set<Role> roles = new HashSet<Role>();
-      roles.add(new Role("user", false, false, true));
-      repository.registerListener(securityStore);
-      
-      EasyMock.expect(repository.getMatch(address.toString())).andReturn(roles);
-      ServerSession serverSession = EasyMock.createNiceMock(ServerSession.class);
-            
-      EasyMock.expect(serverSession.getUsername()).andReturn("user");
-      EasyMock.expect(serverSession.getPassword()).andReturn("password");
-      EasyMock.expect(securityManager.validateUserAndRole("user", "password", roles, checkType)).andReturn(true);
-            
-      EasyMock.expect(repository.getMatch(address.toString())).andReturn(roles);      
-      EasyMock.expect(serverSession.getUsername()).andReturn("user");
-      EasyMock.expect(serverSession.getPassword()).andReturn("password");
-      EasyMock.expect(securityManager.validateUserAndRole("user", "password", roles, checkType)).andReturn(true);
-           
-      EasyMock.replay(repository, securityManager, serverSession);
-      securityStore.setSecurityRepository(repository);
-      securityStore.check(address, checkType, serverSession);
-      Thread.sleep(110);
-      securityStore.check(address, checkType, serverSession);
-      EasyMock.verify(repository, securityManager, serverSession);
-   }
-}

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/settings/impl/RepositoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/settings/impl/RepositoryTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/settings/impl/RepositoryTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,15 +22,15 @@
 
 package org.jboss.messaging.tests.unit.core.settings.impl;
 
-import java.util.ArrayList;
-import java.util.HashSet;
-
 import org.jboss.messaging.core.security.Role;
 import org.jboss.messaging.core.settings.HierarchicalRepository;
 import org.jboss.messaging.core.settings.Mergeable;
 import org.jboss.messaging.core.settings.impl.HierarchicalObjectRepository;
 import org.jboss.messaging.tests.util.UnitTestCase;
 
+import java.util.ArrayList;
+import java.util.HashSet;
+
 /**
  * @author <a href="ataylor at redhat.com">Andy Taylor</a>
  */
@@ -65,13 +65,13 @@
    {
       securityRepository.addMatch("queues.another.aq.*", new HashSet<Role>());
       HashSet<Role> roles = new HashSet<Role>(2);
-      roles.add(new Role("test1"));
-      roles.add(new Role("test2"));
+      roles.add(new Role("test1", true, true, true, true, true, true, true));
+      roles.add(new Role("test2", true, true, true, true, true, true, true));
       securityRepository.addMatch("queues.aq", roles);
       HashSet<Role> roles2 = new HashSet<Role>(2);
-      roles2.add(new Role("test1"));
-      roles2.add(new Role("test2"));
-      roles2.add(new Role("test3"));
+      roles2.add(new Role("test1", true, true, true, true, true, true, true));
+      roles2.add(new Role("test2", true, true, true, true, true, true, true));
+      roles2.add(new Role("test3", true, true, true, true, true, true, true));
       securityRepository.addMatch("queues.another.andanother", roles2);
       
       HashSet<Role> hashSet = securityRepository.getMatch("queues.another.andanother");
@@ -82,8 +82,8 @@
    {
       securityRepository.addMatch("queues.1.*", new HashSet<Role>());
       HashSet<Role> roles = new HashSet<Role>(2);
-      roles.add(new Role("test1"));
-      roles.add(new Role("test2"));
+      roles.add(new Role("test1", true, true, true, true, true, true, true));
+      roles.add(new Role("test2", true, true, true, true, true, true, true));
       securityRepository.addMatch("queues.2.aq", roles);
       HashSet<Role> hashSet = securityRepository.getMatch("queues.2.aq");
       assertEquals(hashSet.size(), 2);

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossTemporaryTopicTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossTemporaryTopicTest.java	2009-03-20 23:36:55 UTC (rev 6130)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossTemporaryTopicTest.java	2009-03-23 09:28:19 UTC (rev 6131)
@@ -22,26 +22,17 @@
 
 package org.jboss.messaging.tests.unit.jms;
 
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import java.util.ArrayList;
-
-import javax.jms.Session;
-
 import org.easymock.EasyMock;
 import org.jboss.messaging.core.client.ClientSession;
 import org.jboss.messaging.core.client.ClientSessionFactory;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryResponseMessage;
 import org.jboss.messaging.jms.JBossTemporaryTopic;
 import org.jboss.messaging.jms.client.JBossConnection;
 import org.jboss.messaging.jms.client.JBossSession;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 import org.jboss.messaging.tests.util.UnitTestCase;
-import org.jboss.messaging.utils.SimpleString;
 
+import javax.jms.Session;
+
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  * 




More information about the jboss-cvs-commits mailing list