[jboss-cvs] JBoss Messaging SVN: r3779 - in trunk/src/main/org/jboss: jms/server/endpoint and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Feb 24 07:38:55 EST 2008


Author: timfox
Date: 2008-02-24 07:38:54 -0500 (Sun, 24 Feb 2008)
New Revision: 3779

Removed:
   trunk/src/main/org/jboss/jms/server/endpoint/SecurityActions.java
Modified:
   trunk/src/main/org/jboss/jms/client/impl/ClientConsumerImpl.java
   trunk/src/main/org/jboss/jms/server/endpoint/MessagingServerPacketHandler.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
   trunk/src/main/org/jboss/messaging/core/MessagingServer.java
   trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java
Log:
More tweaks


Modified: trunk/src/main/org/jboss/jms/client/impl/ClientConsumerImpl.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/impl/ClientConsumerImpl.java	2008-02-24 12:15:29 UTC (rev 3778)
+++ trunk/src/main/org/jboss/jms/client/impl/ClientConsumerImpl.java	2008-02-24 12:38:54 UTC (rev 3779)
@@ -312,7 +312,7 @@
          {
          	//Execute using executor
          	
-         	synchronized (buffer)
+         	synchronized (this)
          	{
          		buffer.addLast(message, message.getMessage().getPriority());
          	}
@@ -323,11 +323,11 @@
       else
       {
       	 // Add it to the buffer
-
-      	buffer.addLast(message, message.getMessage().getPriority());
       	
       	synchronized (this)
       	{
+      		buffer.addLast(message, message.getMessage().getPriority());
+         	      		
       		notify();
       	}
       }      
@@ -422,7 +422,7 @@
    		
    		DeliverMessage message;
    		
-   		synchronized (buffer)
+   		synchronized (this)
    		{
    		   message = buffer.removeFirst();
    		}

Modified: trunk/src/main/org/jboss/jms/server/endpoint/MessagingServerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/MessagingServerPacketHandler.java	2008-02-24 12:15:29 UTC (rev 3778)
+++ trunk/src/main/org/jboss/jms/server/endpoint/MessagingServerPacketHandler.java	2008-02-24 12:38:54 UTC (rev 3779)
@@ -24,16 +24,10 @@
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.CREATECONNECTION;
 
 import org.jboss.jms.client.impl.ClientConnectionFactoryImpl;
-import org.jboss.jms.server.ConnectionManager;
-import org.jboss.jms.server.SecurityStore;
 import org.jboss.logging.Logger;
-import org.jboss.messaging.core.PersistenceManager;
-import org.jboss.messaging.core.PostOffice;
-import org.jboss.messaging.core.ResourceManager;
-import org.jboss.messaging.core.remoting.PacketDispatcher;
+import org.jboss.messaging.core.MessagingServer;
 import org.jboss.messaging.core.remoting.PacketSender;
 import org.jboss.messaging.core.remoting.wireformat.CreateConnectionRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
 import org.jboss.messaging.core.remoting.wireformat.Packet;
 import org.jboss.messaging.core.remoting.wireformat.PacketType;
 import org.jboss.messaging.util.MessagingException;
@@ -49,34 +43,11 @@
 {
    private static final Logger log = Logger.getLogger(MessagingServerPacketHandler.class);
    
-   private final PacketDispatcher dispatcher;
-   
-   private final ResourceManager resourceManager;
-   
-   private final PersistenceManager persistenceManager;
-   
-   private final PostOffice postOffice;
-   
-   private final SecurityStore securityStore;
-   
-   private final ConnectionManager connectionManager;
+   private final MessagingServer server;
 
-   public MessagingServerPacketHandler(final PacketDispatcher dispatcher, final ResourceManager resourceManager,
-   		                              final PersistenceManager persistenceManager,
-   		                              final PostOffice postOffice, final SecurityStore securityStore,
-   		                              final ConnectionManager connectionManager)
+   public MessagingServerPacketHandler(final MessagingServer server)
    {
-      this.dispatcher = dispatcher;
-      
-      this.resourceManager = resourceManager;
-      
-      this.persistenceManager = persistenceManager;
-      
-      this.postOffice = postOffice;
-      
-      this.securityStore = securityStore;
-      
-      this.connectionManager = connectionManager;
+      this.server = server;
    }
    
    /*
@@ -102,9 +73,10 @@
       {
          CreateConnectionRequest request = (CreateConnectionRequest) packet;
          
-         response = createConnection(request
-               .getUsername(), request.getPassword(), request.getRemotingSessionID(),
-               request.getClientVMID(), request.getPrefetchSize(), sender.getRemoteAddress());
+         response = server.createConnection(request.getUsername(), request.getPassword(),
+         		                             request.getRemotingSessionID(),
+                                            request.getClientVMID(), request.getPrefetchSize(),
+                                            sender.getRemoteAddress());
       }     
       else
       {
@@ -114,32 +86,5 @@
       
       return response;
    }
-
-   private CreateConnectionResponse createConnection(final String username, final String password,
-                              final String remotingClientSessionID, final String clientVMID, final int prefetchSize,
-                              final String clientAddress)
-      throws Exception
-   {
-      log.trace("creating a new connection for user " + username);
-
-      // Authenticate. Successful autentication will place a new SubjectContext on thread local,
-      // which will be used in the authorization process. However, we need to make sure we clean
-      // up thread local immediately after we used the information, otherwise some other people
-      // security my be screwed up, on account of thread local security stack being corrupted.
-
-      securityStore.authenticate(username, password);
-
-      // We don't need the SubjectContext on thread local anymore, clean it up
-      SecurityActions.popSubjectContext();
-
-      final ServerConnection connection =
-         new ServerConnectionEndpoint(username, password,
-                                      remotingClientSessionID, clientVMID, clientAddress,
-                                      prefetchSize, dispatcher, resourceManager, persistenceManager,
-                                      postOffice, securityStore, connectionManager);
-
-      dispatcher.register(new ServerConnectionPacketHandler(connection));
-
-      return new CreateConnectionResponse(connection.getID());
-   }
-}
+  
+}
\ No newline at end of file

Deleted: trunk/src/main/org/jboss/jms/server/endpoint/SecurityActions.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/SecurityActions.java	2008-02-24 12:15:29 UTC (rev 3778)
+++ trunk/src/main/org/jboss/jms/server/endpoint/SecurityActions.java	2008-02-24 12:38:54 UTC (rev 3779)
@@ -1,133 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * 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.jms.server.endpoint;
-
-import java.security.AccessController;
-import java.security.Principal;
-import java.security.PrivilegedAction;
-
-import javax.security.auth.Subject;
-
-import org.jboss.security.SecurityAssociation;
-
-
-/** A collection of privileged actions for this package
- * @author Scott.Stark at jboss.org
- * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
- * @author tim.fox at jboss.com
- * @author anil.saldhana at jboss.com
- * @version $Revison: 1.0$
- */
-class SecurityActions
-{
-   interface PrincipalInfoAction
-   {
-      PrincipalInfoAction PRIVILEGED = new PrincipalInfoAction()
-      {
-         public void push(final Principal principal, final Object credential,
-            final Subject subject)
-         {
-            AccessController.doPrivileged(
-               new PrivilegedAction()
-               {
-                  public Object run()
-                  {
-                     SecurityAssociation.pushSubjectContext(subject, principal, credential);
-                     return null;
-                  }
-               }
-            );
-         }
-         public void dup()
-         {
-            AccessController.doPrivileged(
-               new PrivilegedAction()
-               {
-                  public Object run()
-                  {
-                     SecurityAssociation.dupSubjectContext();
-                     return null;
-                  }
-               }
-            );
-         }
-         public void pop()
-         {
-            AccessController.doPrivileged(
-               new PrivilegedAction()
-               {
-                  public Object run()
-                  {
-                     SecurityAssociation.popSubjectContext();
-                     return null;
-                  }
-               }
-            );
-         }
-      };
-
-      PrincipalInfoAction NON_PRIVILEGED = new PrincipalInfoAction()
-      {
-         public void push(Principal principal, Object credential, Subject subject)
-         {
-            SecurityAssociation.pushSubjectContext(subject, principal, credential);
-         }
-         public void dup()
-         {
-            SecurityAssociation.dupSubjectContext();
-         }
-         public void pop()
-         {
-            SecurityAssociation.popSubjectContext();
-         }
-      };
-
-      void push(Principal principal, Object credential, Subject subject);
-      void dup();
-      void pop();
-   }
-
-   static void pushSubjectContext(Principal principal, Object credential,
-      Subject subject)
-   {
-      if(System.getSecurityManager() == null)
-      {
-         PrincipalInfoAction.NON_PRIVILEGED.push(principal, credential, subject);
-      }
-      else
-      {
-         PrincipalInfoAction.PRIVILEGED.push(principal, credential, subject);
-      }
-   }
-   
-   static void popSubjectContext()
-   {
-      if(System.getSecurityManager() == null)
-      {
-         PrincipalInfoAction.NON_PRIVILEGED.pop();
-      }
-      else
-      {
-         PrincipalInfoAction.PRIVILEGED.pop();
-      }
-   }
-  }

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2008-02-24 12:15:29 UTC (rev 3778)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2008-02-24 12:38:54 UTC (rev 3779)
@@ -230,6 +230,8 @@
       {
          throw new IllegalStateException("Cannot find session with id " + sessionId + " to remove");
       }      
+      
+      dispatcher.unregister(sessionId);
    }
 
    public void addTemporaryQueue(final Queue queue)

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2008-02-24 12:15:29 UTC (rev 3778)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2008-02-24 12:38:54 UTC (rev 3779)
@@ -244,8 +244,6 @@
       deliveries.clear();
 
       connection.removeSession(id);
-
-      dispatcher.unregister(id);
    }
    
    public void promptDelivery(final Queue queue)

Modified: trunk/src/main/org/jboss/messaging/core/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/MessagingServer.java	2008-02-24 12:15:29 UTC (rev 3778)
+++ trunk/src/main/org/jboss/messaging/core/MessagingServer.java	2008-02-24 12:38:54 UTC (rev 3779)
@@ -26,6 +26,7 @@
 import org.jboss.jms.server.ConnectionManager;
 import org.jboss.jms.server.security.Role;
 import org.jboss.messaging.core.remoting.RemotingService;
+import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
 import org.jboss.messaging.util.HierarchicalRepository;
 import org.jboss.messaging.util.Version;
 
@@ -96,4 +97,8 @@
    void removeAllMessagesForBinding(String name) throws Exception;
 
    void removeMessageForBinding(String name, Filter filter) throws Exception;
+   
+   CreateConnectionResponse createConnection(String username, String password,
+                                             String remotingClientSessionID, String clientVMID,
+                                             int prefetchSize, String clientAddress) throws Exception;
 }

Modified: trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java	2008-02-24 12:15:29 UTC (rev 3778)
+++ trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java	2008-02-24 12:38:54 UTC (rev 3779)
@@ -32,6 +32,9 @@
 import org.jboss.jms.server.ConnectionManager;
 import org.jboss.jms.server.connectionmanager.SimpleConnectionManager;
 import org.jboss.jms.server.endpoint.MessagingServerPacketHandler;
+import org.jboss.jms.server.endpoint.ServerConnection;
+import org.jboss.jms.server.endpoint.ServerConnectionEndpoint;
+import org.jboss.jms.server.endpoint.ServerConnectionPacketHandler;
 import org.jboss.jms.server.security.NullAuthenticationManager;
 import org.jboss.jms.server.security.Role;
 import org.jboss.jms.server.security.SecurityMetadataStore;
@@ -58,6 +61,7 @@
 import org.jboss.messaging.core.remoting.RemotingConfiguration;
 import org.jboss.messaging.core.remoting.RemotingService;
 import org.jboss.messaging.core.remoting.impl.mina.MinaService;
+import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
 import org.jboss.messaging.deployers.queue.QueueSettingsDeployer;
 import org.jboss.messaging.deployers.security.SecurityDeployer;
 import org.jboss.messaging.util.ExceptionUtil;
@@ -203,12 +207,8 @@
          memoryManager.start();
          postOffice.start();
          
-         MessagingServerPacketHandler serverPacketHandler =
-         	new MessagingServerPacketHandler(remotingService.getDispatcher(), resourceManager,
-         			                           persistenceManager, postOffice, securityStore,
-         			                           connectionManager);
-         
-         
+         MessagingServerPacketHandler serverPacketHandler =	new MessagingServerPacketHandler(this);
+                  
          getRemotingService().getDispatcher().register(serverPacketHandler);
 
          ClassLoader loader = Thread.currentThread().getContextClassLoader();
@@ -501,6 +501,31 @@
    {
       return "MessagingServer[" + configuration.getMessagingServerID() + "]";
    }
+   
+   public CreateConnectionResponse createConnection(final String username, final String password,
+                                                    final String remotingClientSessionID, final String clientVMID,
+                                                    final int prefetchSize, final String clientAddress)
+      throws Exception
+   {
+      log.trace("creating a new connection for user " + username);
+      
+      // Authenticate. Successful autentication will place a new SubjectContext on thread local,
+      // which will be used in the authorization process. However, we need to make sure we clean
+      // up thread local immediately after we used the information, otherwise some other people
+      // security my be screwed up, on account of thread local security stack being corrupted.
+      
+      securityStore.authenticate(username, password);
+      
+      final ServerConnection connection =
+         new ServerConnectionEndpoint(username, password,
+                          remotingClientSessionID, clientVMID, clientAddress,
+                          prefetchSize, remotingService.getDispatcher(), resourceManager, persistenceManager,
+                          postOffice, securityStore, connectionManager);
+      
+      remotingService.getDispatcher().register(new ServerConnectionPacketHandler(connection));
+      
+      return new CreateConnectionResponse(connection.getID());
+   }
 
    // Public ---------------------------------------------------------------------------------------
 




More information about the jboss-cvs-commits mailing list