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

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Wed Apr 2 00:04:08 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-04-02 00:04:08 -0400 (Wed, 02 Apr 2008)
New Revision: 3840

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java
Log:
JBREM-934: Put ServerSocketFactory.createServerSocket() calls in AccessController.doPrivileged() calls.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java	2008-04-02 04:02:50 UTC (rev 3839)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java	2008-04-02 04:04:08 UTC (rev 3840)
@@ -25,6 +25,9 @@
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.ServerSocket;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 
 /**
  * @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
@@ -38,24 +41,84 @@
       this.serverSocketFactory = serverSocketFactory;
    }
 
-   public ServerSocket createServerSocket(int i) throws IOException
+   public ServerSocket createServerSocket(final int i) throws IOException
    {
-      return serverSocketFactory.createServerSocket(i);
+      ServerSocket ss = null;
+      try
+      {
+          ss = (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+          {
+             public Object run() throws Exception
+             {
+                 return serverSocketFactory.createServerSocket(i);
+             }
+          });
+      }
+      catch (PrivilegedActionException e)
+      {
+          throw (IOException) e.getCause();
+      }
+      return ss;
    }
 
-   public ServerSocket createServerSocket(int i, int i1) throws IOException
+   public ServerSocket createServerSocket(final int i, final int i1) throws IOException
    {
-      return serverSocketFactory.createServerSocket(i, i1);
+      ServerSocket ss = null;
+      try
+      {
+          ss = (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+          {
+             public Object run() throws Exception
+             {
+                return serverSocketFactory.createServerSocket(i, i1);
+             }
+          });
+      }
+      catch (PrivilegedActionException e)
+      {
+          throw (IOException) e.getCause();
+      }
+      return ss;
    }
 
-   public ServerSocket createServerSocket(int i, int i1, InetAddress inetAddress) throws IOException
+   public ServerSocket createServerSocket(final int i, final int i1, final InetAddress inetAddress) throws IOException
    {
-      return serverSocketFactory.createServerSocket(i, i1, inetAddress);
+      ServerSocket ss = null;
+      try
+      {
+          ss = (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+          {
+             public Object run() throws Exception
+             {
+                return serverSocketFactory.createServerSocket(i, i1, inetAddress);
+             }
+          });
+      }
+      catch (PrivilegedActionException e)
+      {
+          throw (IOException) e.getCause();
+      }
+      return ss;
    }
 
    public ServerSocket createServerSocket() throws IOException
    {
-      return serverSocketFactory.createServerSocket();
+      ServerSocket ss = null;
+      try
+      {
+          ss = (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+          {
+             public Object run() throws Exception
+             {
+                return serverSocketFactory.createServerSocket();
+             }
+          });
+      }
+      catch (PrivilegedActionException e)
+      {
+          throw (IOException) e.getCause();
+      }
+      return ss;
    }
 
    public ServerSocketFactoryMBean getDelegate()




More information about the jboss-remoting-commits mailing list