Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:26:05 -0400 (Tue, 14 Apr 2009)
New Revision: 5023
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/InternalTransporterServices.java
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterClient.java
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterHandler.java
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterServer.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/InternalTransporterServices.java
===================================================================
---
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/InternalTransporterServices.java 2009-04-14
10:25:23 UTC (rev 5022)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/InternalTransporterServices.java 2009-04-14
10:26:05 UTC (rev 5023)
@@ -240,7 +240,7 @@
if (registerDetector)
{
- SecurityUtility.registerMBean(m_mBeanServer, m_detector, m_detectorName);
+ registerMBean(m_mBeanServer, m_detector, m_detectorName);
}
}
@@ -299,7 +299,7 @@
if (registerRegistry)
{
- SecurityUtility.registerMBean(m_mBeanServer, m_networkRegistry,
m_networkRegistryName);
+ registerMBean(m_mBeanServer, m_networkRegistry, m_networkRegistryName);
}
}
@@ -390,4 +390,30 @@
return;
}
+
+ static private void registerMBean(final MBeanServer server, final Object o, final
ObjectName name)
+ throws Exception
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ server.registerMBean(o, name);
+ return;
+ }
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ server.registerMBean(o, name);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+ }
}
\ No newline at end of file
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterClient.java
===================================================================
---
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterClient.java 2009-04-14
10:25:23 UTC (rev 5022)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterClient.java 2009-04-14
10:26:05 UTC (rev 5023)
@@ -34,6 +34,8 @@
import org.jboss.remoting.util.SecurityUtility;
import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
@@ -41,6 +43,8 @@
import java.lang.reflect.Proxy;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
/**
@@ -133,7 +137,7 @@
if (!services.isSetup())
{
// we need an MBeanServer to store our network registry and multicast detector
services
- MBeanServer server = SecurityUtility.createMBeanServer();
+ MBeanServer server = createMBeanServer();
// multicast detector will detect new network registries that come online
MulticastDetector detector = new MulticastDetector();
@@ -427,5 +431,26 @@
return paramSig;
}
-
+ static private MBeanServer createMBeanServer() throws Exception
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return MBeanServerFactory.createMBeanServer();
+ }
+
+ try
+ {
+ return (MBeanServer) AccessController.doPrivileged( new
PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return MBeanServerFactory.createMBeanServer();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+ }
}
\ No newline at end of file
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterHandler.java
===================================================================
---
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterHandler.java 2009-04-14
10:25:23 UTC (rev 5022)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterHandler.java 2009-04-14
10:26:05 UTC (rev 5023)
@@ -83,7 +83,7 @@
}
// use reflection to make the call
- Method method = SecurityUtility.getMethod(targetPOJO.getClass(), methodName,
classSig);
+ Method method = getMethod(targetPOJO.getClass(), methodName, classSig);
Object responseObject = method.invoke(targetPOJO, params);
return responseObject;
@@ -146,4 +146,27 @@
//NOOP
}
+ 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();
+ }
+ }
}
\ No newline at end of file
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterServer.java
===================================================================
---
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterServer.java 2009-04-14
10:25:23 UTC (rev 5022)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterServer.java 2009-04-14
10:26:05 UTC (rev 5023)
@@ -221,7 +221,7 @@
if (!services.isSetup())
{
// we need an MBeanServer to store our network registry and multicast detector
services
- MBeanServer server = SecurityUtility.createMBeanServer();
+ MBeanServer server = createMBeanServer();
// multicast detector will detect new network registries that come online
MulticastDetector detector = new MulticastDetector();
@@ -507,4 +507,26 @@
return createTransporterServer(new InvokerLocator(locatorURI), target, subsystem,
false);
}
+ static private MBeanServer createMBeanServer() throws Exception
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return MBeanServerFactory.createMBeanServer();
+ }
+
+ try
+ {
+ return (MBeanServer) AccessController.doPrivileged( new
PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return MBeanServerFactory.createMBeanServer();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+ }
}
\ No newline at end of file