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

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Tue Apr 1 23:39:18 EDT 2008


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

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/detection/jndi/JNDIDetector.java
Log:
JBREM-934: Put Class.getClassLoader() and InetAddress.getLocalHost() calls in AccessController.doPrivileged() calls.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/detection/jndi/JNDIDetector.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/detection/jndi/JNDIDetector.java	2008-04-02 03:36:08 UTC (rev 3828)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/detection/jndi/JNDIDetector.java	2008-04-02 03:39:18 UTC (rev 3829)
@@ -37,7 +37,13 @@
 import javax.naming.NameAlreadyBoundException;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
+
+import java.io.IOException;
 import java.net.InetAddress;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.Map;
 import java.util.Properties;
 
@@ -291,7 +297,14 @@
                   }
                   // Need to actually detect if servers registered in JNDI server
                   // are actually there (since could die before unregistering)
-                  ClassLoader cl = JNDIDetector.this.getClass().getClassLoader();
+                  ClassLoader cl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
+                  {
+                     public Object run()
+                     {
+                        return JNDIDetector.class.getClassLoader();
+                     }
+                  });
+                  
                   if(!checkInvokerServer(regMsg, cl))
                   {
                      unregisterDetection(regMsg.getIdentity().getInstanceId());
@@ -428,7 +441,22 @@
          try
          {
             log.info("JNDI Server configuration information not present so will create a local server.");
-            host = InetAddress.getLocalHost().getHostName();
+            
+            try
+            {
+                host = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+                {
+                   public Object run() throws IOException
+                   {
+                       return InetAddress.getLocalHost().getHostName();
+                   }
+                });
+            }
+            catch (PrivilegedActionException e)
+            {
+               throw (IOException) e.getCause();
+            }
+            
             port = PortUtil.findFreePort(host);
 
             log.info("Remoting JNDI detector starting JNDI server instance since none where specified via configuration.");




More information about the jboss-remoting-commits mailing list