[hornetq-commits] JBoss hornetq SVN: r8877 - in trunk/src/main/org/hornetq: core/management/impl and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Feb 15 15:45:11 EST 2010


Author: clebert.suconic at jboss.com
Date: 2010-02-15 15:45:11 -0500 (Mon, 15 Feb 2010)
New Revision: 8877

Modified:
   trunk/src/main/org/hornetq/api/core/management/AddressControl.java
   trunk/src/main/org/hornetq/core/management/impl/AddressControlImpl.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-299 - Fixing crossed collections over security

Modified: trunk/src/main/org/hornetq/api/core/management/AddressControl.java
===================================================================
--- trunk/src/main/org/hornetq/api/core/management/AddressControl.java	2010-02-15 17:33:11 UTC (rev 8876)
+++ trunk/src/main/org/hornetq/api/core/management/AddressControl.java	2010-02-15 20:45:11 UTC (rev 8877)
@@ -88,4 +88,10 @@
     */
    @Operation(desc = "Remove a Role from this address")
    void removeRole(@Parameter(name = "name", desc = "Name of the role to remove") String name) throws Exception;
+   
+   /**
+    * This method will remove any matching associated with this address. This will basically reset the security for this address.
+    */
+   @Operation(desc = "Reset the security configuration for this address by using default values")
+   void resetSecurity();
 }

Modified: trunk/src/main/org/hornetq/core/management/impl/AddressControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/management/impl/AddressControlImpl.java	2010-02-15 17:33:11 UTC (rev 8876)
+++ trunk/src/main/org/hornetq/core/management/impl/AddressControlImpl.java	2010-02-15 20:45:11 UTC (rev 8877)
@@ -13,6 +13,7 @@
 
 package org.hornetq.core.management.impl;
 
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
@@ -193,6 +194,9 @@
       try
       {
          Set<Role> roles = securityRepository.getMatch(address.toString());
+         HashSet<Role> newroles = new HashSet<Role>();
+         newroles.addAll(roles);
+         
          Role newRole = new Role(name,
                                  send,
                                  consume,
@@ -201,12 +205,12 @@
                                  createNonDurableQueue,
                                  deleteNonDurableQueue,
                                  manage);
-         boolean added = roles.add(newRole);
+         boolean added = newroles.add(newRole);
          if (!added)
          {
             throw new IllegalArgumentException("Role " + name + " already exists");
          }
-         securityRepository.addMatch(address.toString(), roles);
+         securityRepository.addMatch(address.toString(), newroles);
       }
       finally
       {
@@ -220,7 +224,11 @@
       try
       {
          Set<Role> roles = securityRepository.getMatch(address.toString());
-         Iterator<Role> it = roles.iterator();
+         
+         HashSet<Role> newroles = new HashSet<Role>();
+         newroles.addAll(roles);
+
+         Iterator<Role> it = newroles.iterator();
          boolean removed = false;
          while (it.hasNext())
          {
@@ -236,7 +244,10 @@
          {
             throw new IllegalArgumentException("Role " + role + " does not exist");
          }
-         securityRepository.addMatch(address.toString(), roles);
+
+         securityRepository.removeMatch(address.toString());
+         
+         securityRepository.addMatch(address.toString(), newroles);
       }
       finally
       {
@@ -244,6 +255,15 @@
       }
    }
    
+   /* (non-Javadoc)
+    * @see org.hornetq.api.core.management.AddressControl#resetSecurity()
+    */
+   public void resetSecurity()
+   {
+      securityRepository.removeMatch(address.toString());
+   }
+
+
    @Override
    MBeanOperationInfo[] fillMBeanOperationInfo()
    {



More information about the hornetq-commits mailing list