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

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Tue Apr 14 06:09:59 EDT 2009


Author: ron.sigal at jboss.com
Date: 2009-04-14 06:09:59 -0400 (Tue, 14 Apr 2009)
New Revision: 4994

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/InvokerRegistry.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/InvokerRegistry.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/InvokerRegistry.java	2009-04-14 10:09:35 UTC (rev 4993)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/InvokerRegistry.java	2009-04-14 10:09:59 UTC (rev 4994)
@@ -33,6 +33,9 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -444,9 +447,9 @@
       if(transportFactoryClass != null)
       {
          ClientFactory transportFactory = (ClientFactory)transportFactoryClass.newInstance();
-         Method getClientInvokerMethod = SecurityUtility.getMethod(transportFactoryClass,
-                                                                   "createClientInvoker",
-                                                                   new Class[] {InvokerLocator.class, Map.class});
+         Method getClientInvokerMethod = getMethod(transportFactoryClass,
+                                                   "createClientInvoker",
+                                                   new Class[] {InvokerLocator.class, Map.class});
          clientInvoker = (ClientInvoker)getClientInvokerMethod.invoke(transportFactory, new Object[] {locator, configuration});
       }
       else
@@ -465,9 +468,9 @@
       if(transportFactoryClass != null)
       {
          ServerFactory transportFactory = (ServerFactory)transportFactoryClass.newInstance();
-         Method getServerInvokerMethod = SecurityUtility.getMethod(transportFactoryClass,
-                                                                   "createServerInvoker",
-                                                                   new Class[] {InvokerLocator.class, Map.class});         
+         Method getServerInvokerMethod = getMethod(transportFactoryClass,
+                                                   "createServerInvoker",
+                                                   new Class[] {InvokerLocator.class, Map.class});         
          serverInvoker = (ServerInvoker)getServerInvokerMethod.invoke(transportFactory, new Object[] {locator, configuration});
       }
       else
@@ -675,7 +678,7 @@
             transportFactoryClass = getTransportClientFactory(transport);
          }
          ClientFactory clientFactory = (ClientFactory)transportFactoryClass.newInstance();
-         Method meth = SecurityUtility.getMethod(transportFactoryClass, "supportsSSL", new Class[]{});         
+         Method meth = getMethod(transportFactoryClass, "supportsSSL", new Class[]{});         
          Boolean boolVal = (Boolean)meth.invoke(clientFactory, null);
          isSSLSupported = boolVal.booleanValue();
       }
@@ -783,4 +786,28 @@
       }
 
    }
+   
+   static private Method getMethod(final Class c, final String name, final Class[] parameterTypes)
+   throws NoSuchMethodException
+   {
+      if (SecurityUtility.skipAccessControl())
+      {
+         return c.getMethod(name, parameterTypes);
+      }
+
+      try
+      {
+         return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction()
+         {
+            public Object run() throws NoSuchMethodException
+            {
+               return c.getMethod(name, parameterTypes);
+            }
+         });
+      }
+      catch (PrivilegedActionException e)
+      {
+         throw (NoSuchMethodException) e.getCause();
+      }
+   }
 }




More information about the jboss-remoting-commits mailing list