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

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Wed Apr 2 00:22:05 EDT 2008


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

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java
Log:
JBREM-934: Put InetAddress.getByName() and Class().getMethods() calls in AccessController.doPrivileged() calls.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java	2008-04-02 04:20:20 UTC (rev 3849)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java	2008-04-02 04:22:05 UTC (rev 3850)
@@ -49,7 +49,6 @@
 
 import javax.net.ServerSocketFactory;
 
-import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.net.InetAddress;
@@ -356,8 +355,22 @@
             MessageBytes remoteAddressMB = req.remoteAddr();
             if (remoteAddressMB != null)
             {
-               String remoteAddressString = remoteAddressMB.toString();
-               InetAddress remoteAddress = InetAddress.getByName(remoteAddressString);
+               final String remoteAddressString = remoteAddressMB.toString();
+               InetAddress remoteAddress = null;
+               try
+               {
+                  remoteAddress = (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction()
+                  {
+                     public Object run() throws UnknownHostException
+                     {
+                        return InetAddress.getByName(remoteAddressString);
+                     }
+                  });
+               }
+               catch (PrivilegedActionException e)
+               {
+                  throw (UnknownHostException) e.getCause();
+               }
                invocationRequest.getRequestPayload().put(Remoting.CLIENT_ADDRESS, remoteAddress);  
             }
             else
@@ -972,13 +985,20 @@
     * int or boolean we'll convert value to the right type before) - that means
     * you can have setDebug(1).
     */
-   public static boolean setProperty(Object o, String name, String value)
+   public static boolean setProperty(final Object o, String name, final String value)
    {
       String setter = "set" + capitalize(name);
 
       try
       {
-         Method methods[] = o.getClass().getMethods();
+         Method methods[] = (Method[]) AccessController.doPrivileged( new PrivilegedAction()
+         {
+            public Object run()
+            {
+               return o.getClass().getMethods();
+            }
+         });
+         
          Method setPropertyMethod = null;
 
          // First, the ideal case - a setFoo( String ) method
@@ -1046,7 +1066,20 @@
                {
                   try
                   {
-                     params[0] = InetAddress.getByName(value);
+                     try
+                     {
+                        params[0] = AccessController.doPrivileged( new PrivilegedExceptionAction()
+                        {
+                           public Object run() throws UnknownHostException
+                           {
+                              return InetAddress.getByName(value);
+                           }
+                        });
+                     }
+                     catch (PrivilegedActionException e)
+                     {
+                        throw (UnknownHostException) e.getCause();
+                     }
                   }
                   catch(UnknownHostException exc)
                   {




More information about the jboss-remoting-commits mailing list