[jboss-remoting-commits] JBoss Remoting SVN: r3706 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Thu Mar 20 21:37:51 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-03-20 21:37:50 -0400 (Thu, 20 Mar 2008)
New Revision: 3706

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi/RemotingRMIServerSocketFactory.java
Log:
JBREM-934: Put ServerSocket creation in AccessController.doPrivileged() call.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi/RemotingRMIServerSocketFactory.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi/RemotingRMIServerSocketFactory.java	2008-03-21 01:37:02 UTC (rev 3705)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi/RemotingRMIServerSocketFactory.java	2008-03-21 01:37:50 UTC (rev 3706)
@@ -23,6 +23,7 @@
 package org.jboss.remoting.transport.rmi;
 
 import org.jboss.logging.Logger;
+import org.jboss.remoting.loading.ClassByteClassLoader;
 
 import javax.net.ServerSocketFactory;
 import java.io.IOException;
@@ -31,6 +32,9 @@
 import java.net.ServerSocket;
 import java.net.UnknownHostException;
 import java.rmi.server.RMIServerSocketFactory;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 
 
 /**
@@ -144,33 +148,49 @@
     * @return a new <code>ServerSocket</code>
     * @throws IOException if there is a problem creating a server socket
     */
-   public ServerSocket createServerSocket(int port) throws IOException
+   public ServerSocket createServerSocket(final int port) throws IOException
    {
       ServerSocket svrSocket = null;
 
-      if(serverSocketFactory != null)
+      try
       {
-         svrSocket = serverSocketFactory.createServerSocket(port, backlog, bindAddress);
-      }
+         svrSocket = (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+         {
+            public Object run() throws Exception
+            {
+               ServerSocket ss = null;
 
-//      if (constructor != null)
-//      {
-//         try
-//         {
-//            if (portPosition != -1)
-//               args[portPosition] = new Integer(port);
-//
-//            return (ServerSocket) constructor.newInstance(args);
-//         }
-//         catch (Exception e)
-//         {
-//            throw new IOException(e.getMessage());
-//         }
-//      }
+               if(serverSocketFactory != null)
+               {
+                  ss = serverSocketFactory.createServerSocket(port, backlog, bindAddress);
+               }
 
-      else
+//                if (constructor != null)
+//                {
+//                   try
+//                   {
+//                      if (portPosition != -1)
+//                         args[portPosition] = new Integer(port);
+          //
+//                      return (ServerSocket) constructor.newInstance(args);
+//                   }
+//                   catch (Exception e)
+//                   {
+//                      throw new IOException(e.getMessage());
+//                   }
+//                }
+
+               else
+               {
+                  ss = new ServerSocket(port, backlog, bindAddress);
+               }
+               return ss;
+            }
+         });
+      }
+      catch (PrivilegedActionException e)
       {
-         svrSocket = new ServerSocket(port, backlog, bindAddress);
+         throw (IOException) e.getCause();
       }
 
       svrSocket.setSoTimeout(timeout);




More information about the jboss-remoting-commits mailing list