[jboss-remoting-commits] JBoss Remoting SVN: r3830 - remoting2/branches/2.x/src/main/org/jboss/remoting/detection/multicast.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Tue Apr 1 23:41:43 EDT 2008


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

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/detection/multicast/MulticastDetector.java
Log:
JBREM-934: Put InetAddress.getByName(), InetAddress.getByName(), and new MulticastSocket() calls in AccessController.doPrivileged() calls.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/detection/multicast/MulticastDetector.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/detection/multicast/MulticastDetector.java	2008-04-02 03:39:18 UTC (rev 3829)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/detection/multicast/MulticastDetector.java	2008-04-02 03:41:43 UTC (rev 3830)
@@ -34,6 +34,9 @@
 import java.net.InetSocketAddress;
 import java.net.MulticastSocket;
 import java.net.SocketAddress;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 
 /**
  * MulticastDetector is a remoting detector that broadcasts detection messages using
@@ -142,19 +145,62 @@
    {
       if(addr == null)
       {
-         this.addr = InetAddress.getByName(defaultIP);
+         try
+         {
+            this.addr = (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction()
+            {
+               public Object run() throws IOException
+               {
+                  return InetAddress.getByName(defaultIP);
+               }
+            });
+         }
+         catch (PrivilegedActionException e)
+         {
+            throw (IOException) e.getCause();
+         }
       }
       // check to see if we're running on a machine with loopback and no NIC
-      InetAddress localHost = InetAddress.getLocalHost();
+      InetAddress localHost = null;
+      try
+      {
+         localHost = (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction()
+         {
+            public Object run() throws IOException
+            {
+               return InetAddress.getLocalHost();
+            }
+         });
+      }
+      catch (PrivilegedActionException e)
+      {
+         throw (IOException) e.getCause();
+      }
+      
       if(bindAddr == null && localHost.getHostAddress().equals("127.0.0.1"))
       {
          // use this to bind so multicast will work w/o network
          this.bindAddr = localHost;
       }
-      SocketAddress saddr = new InetSocketAddress(bindAddr, port);
-      socket = new MulticastSocket(saddr);
-      socket.joinGroup(addr);
 
+      try
+      {
+         final SocketAddress saddr = new InetSocketAddress(bindAddr, port);
+         AccessController.doPrivileged( new PrivilegedExceptionAction()
+         {
+            public Object run() throws IOException
+            {
+               socket = new MulticastSocket(saddr);
+               socket.joinGroup(addr);
+               return null;
+            }
+         });
+      }
+      catch (PrivilegedActionException e)
+      {
+         throw (IOException) e.getCause();
+      }
+
       super.start();
 
       if(listener == null)




More information about the jboss-remoting-commits mailing list