[hornetq-commits] JBoss hornetq SVN: r11444 - in branches/Branch_2_2_EAP: src/main/org/hornetq/core/security/impl and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Sep 29 18:02:54 EDT 2011


Author: clebert.suconic at jboss.com
Date: 2011-09-29 18:02:54 -0400 (Thu, 29 Sep 2011)
New Revision: 11444

Modified:
   branches/Branch_2_2_EAP/src/main/org/hornetq/core/security/SecurityStore.java
   branches/Branch_2_2_EAP/src/main/org/hornetq/core/security/impl/SecurityStoreImpl.java
   branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
   branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/security/SecurityTest.java
Log:
JBPAPP-7256 & SOA-3363 - added a test for this on 

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/security/SecurityStore.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/security/SecurityStore.java	2011-09-29 19:53:05 UTC (rev 11443)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/security/SecurityStore.java	2011-09-29 22:02:54 UTC (rev 11444)
@@ -28,4 +28,6 @@
    void authenticate(String user, String password) throws Exception;
 
    void check(SimpleString address, CheckType checkType, ServerSession session) throws Exception;
+
+   void stop();
 }

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/security/impl/SecurityStoreImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/security/impl/SecurityStoreImpl.java	2011-09-29 19:53:05 UTC (rev 11443)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/security/impl/SecurityStoreImpl.java	2011-09-29 22:02:54 UTC (rev 11444)
@@ -97,9 +97,15 @@
       this.managementClusterUser = managementClusterUser;
       this.managementClusterPassword = managementClusterPassword;
       this.notificationService = notificationService;
+      this.securityRepository.registerListener(this);
    }
 
    // SecurityManager implementation --------------------------------
+   
+   public void stop()
+   {
+      securityRepository.unRegisterListener(this);
+   }
 
    public void authenticate(final String user, final String password) throws Exception
    {

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java	2011-09-29 19:53:05 UTC (rev 11443)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java	2011-09-29 22:02:54 UTC (rev 11444)
@@ -493,7 +493,10 @@
       for (ServerSession session : sessions.values())
       {
          session.close(true);
-         session.waitContextCompletion();
+         if (!criticalIOError)
+         {
+            session.waitContextCompletion();
+         }
       }
 
       remotingService.stop();
@@ -601,7 +604,9 @@
          {
             // Ignore
          }
-
+         
+         securityStore.stop();
+ 
          threadPool = null;
 
          scheduledPool = null;

Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/security/SecurityTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/security/SecurityTest.java	2011-09-29 19:53:05 UTC (rev 11443)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/security/SecurityTest.java	2011-09-29 22:02:54 UTC (rev 11444)
@@ -493,21 +493,68 @@
       try
       {
          server.start();
+         
          HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
+         
          HornetQSecurityManager securityManager = server.getSecurityManager();
+         
          securityManager.addUser("auser", "pass");
-         Role role = new Role("arole", true, false, true, false, false, false, false);
+         
+         Role role = new Role("arole", true, true, true, false, false, false, false);
+         
          Set<Role> roles = new HashSet<Role>();
+         
          roles.add(role);
+         
          securityRepository.addMatch(SecurityTest.addressA, roles);
+         
          securityManager.addRole("auser", "arole");
+         
          locator.setBlockOnNonDurableSend(true);
+         
          ClientSessionFactory cf = locator.createSessionFactory();
+         
          ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
+         
          session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
+         
          ClientProducer cp = session.createProducer(SecurityTest.addressA);
+         
          cp.send(session.createMessage(false));
+         
+         session.start();
+         
+         ClientConsumer cons = session.createConsumer(queueA);
+         
+         ClientMessage receivedMessage = cons.receive(5000);
+         
+         assertNotNull(receivedMessage);
+         
+         receivedMessage.acknowledge();
+         
+         role = new Role("arole", false, false, true, false, false, false, false);
+         
+         roles = new HashSet<Role>();
+         
+         roles.add(role);
+         
+         securityRepository.addMatch(SecurityTest.addressA, roles);
+         
+         boolean failed = false;
+         try
+         {
+            cp.send(session.createMessage(true));
+         }
+         catch (HornetQException e)
+         {
+            failed = true;
+         }
+         
+         assertTrue("Failure expected on send after removing the match", failed);
+         
+         
          session.close();
+         
       }
       finally
       {



More information about the hornetq-commits mailing list