[jboss-remoting-commits] JBoss Remoting SVN: r3827 - remoting2/branches/2.x/src/main/org/jboss/remoting/callback.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Tue Apr 1 23:33:04 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-04-01 23:33:04 -0400 (Tue, 01 Apr 2008)
New Revision: 3827

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java
Log:
JBREM-934: (1) Put MBeanServer calls in AccessController.doPrivileged() calls; (2) replace System.getProperty() with SystemUtility.getSystemProperty().

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java	2008-04-02 03:29:52 UTC (rev 3826)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java	2008-04-02 03:33:04 UTC (rev 3827)
@@ -34,6 +34,7 @@
 import org.jboss.remoting.security.SSLSocketBuilder;
 import org.jboss.remoting.security.SSLSocketBuilderMBean;
 import org.jboss.remoting.security.SSLSocketFactoryService;
+import org.jboss.remoting.util.SystemUtility;
 
 import javax.management.MBeanServer;
 import javax.management.MBeanServerInvocationHandler;
@@ -284,17 +285,47 @@
       String serverSocketFactoryString = (String) clientConfig.get(ServerInvoker.SERVER_SOCKET_FACTORY);
       if (serverSocketFactoryString != null && serverSocketFactoryString.length() > 0)
       {
-         MBeanServer server = serverInvoker.getMBeanServer();
+         final MBeanServer server = serverInvoker.getMBeanServer();
          try
          {
-            ObjectName serverSocketFactoryObjName = new ObjectName(serverSocketFactoryString);
+            final ObjectName serverSocketFactoryObjName = new ObjectName(serverSocketFactoryString);
             if (server != null)
             {
-               boolean isCorrectType = server.isInstanceOf(serverSocketFactoryObjName, SSLServerSocketFactoryServiceMBean.class.getName());
+               boolean isCorrectType = false;
+               try
+               {
+                  isCorrectType = ((Boolean)AccessController.doPrivileged( new PrivilegedExceptionAction()
+                  {
+                     public Object run() throws Exception
+                     {
+                        String className = SSLServerSocketFactoryServiceMBean.class.getName();
+                        return new Boolean(server.isInstanceOf(serverSocketFactoryObjName, className));
+                     }
+                  })).booleanValue();
+               }
+               catch (PrivilegedActionException e)
+               {
+                  throw (Exception) e.getCause();
+               }
+
                if (isCorrectType)
                {
-                  SSLSocketBuilderMBean sslSocketBuilder = (SSLSocketBuilderMBean)server.
-                  getAttribute(serverSocketFactoryObjName, "SSLSocketBuilder");
+                  SSLSocketBuilderMBean sslSocketBuilder = null;             
+                  try
+                  {
+                     sslSocketBuilder = (SSLSocketBuilderMBean)AccessController.doPrivileged( new PrivilegedExceptionAction()
+                     {
+                        public Object run() throws Exception
+                        {
+                           return server.getAttribute(serverSocketFactoryObjName, "SSLSocketBuilder");
+                        }
+                     });
+                  }
+                  catch (PrivilegedActionException e)
+                  {
+                     throw (Exception) e.getCause();
+                  }
+                  
                   if (sslSocketBuilder != null)
                   {
                      SSLSocketBuilder clonedSSLSocketBuilder = (SSLSocketBuilder) sslSocketBuilder.clone();
@@ -438,24 +469,8 @@
             }
          }
          
-         String separator = "/";
-         try
-         {
-            separator = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
-            {
-               public Object run() throws Exception
-               {
-                  return System.getProperty("file.separator");
-               }
-            });
-         }
-         catch (PrivilegedActionException e)
-         {
-            log.debug("error", e.getCause());
-         }
-         
-         newFilePath = newFilePath + separator + "remoting" +
-         System.getProperty("file.separator") + sessionId;
+         String separator = SystemUtility.getSystemProperty("file.separator");
+         newFilePath = newFilePath + separator + "remoting" + separator + sessionId;
 
          storeConfig.put(CallbackStore.FILE_PATH_KEY, newFilePath);
 




More information about the jboss-remoting-commits mailing list