Author: ron.sigal(a)jboss.com
Date: 2008-03-26 01:28:46 -0400 (Wed, 26 Mar 2008)
New Revision: 3778
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterHandler.java
Log:
JBREM-934: Put Class.getMethod() in AccessController.doPrivileged() call.
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 2008-03-26
05:28:29 UTC (rev 3777)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterHandler.java 2008-03-26
05:28:46 UTC (rev 3778)
@@ -29,6 +29,9 @@
import javax.management.MBeanServer;
import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
/**
* Simple handler that uses reflection to make calls on target POJO (as supplied in the
constructor)
@@ -61,10 +64,10 @@
// Am expecting a NameBasedInvocation as the parameter
NameBasedInvocation nbInvocation = (NameBasedInvocation) request;
- String methodName = nbInvocation.getMethodName();
+ final String methodName = nbInvocation.getMethodName();
Object[] params = nbInvocation.getParameters();
String[] sig = nbInvocation.getSignature();
- Class[] classSig = new Class[sig.length];
+ final Class[] classSig = new Class[sig.length];
for(int x = 0; x < sig.length; x++)
{
Class signature = getPrimitiveType(sig[x]);
@@ -79,7 +82,22 @@
}
// use reflection to make the call
- Method method = targetPOJO.getClass().getMethod(methodName, classSig);
+ Method method = null;
+ try
+ {
+ method = (Method)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return targetPOJO.getClass().getMethod(methodName, classSig);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+
Object responseObject = method.invoke(targetPOJO, params);
return responseObject;
Show replies by date