[jboss-remoting-commits] JBoss Remoting SVN: r5013 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket.
jboss-remoting-commits at lists.jboss.org
jboss-remoting-commits at lists.jboss.org
Tue Apr 14 06:19:39 EDT 2009
Author: ron.sigal at jboss.com
Date: 2009-04-14 06:19:39 -0400 (Tue, 14 Apr 2009)
New Revision: 5013
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java 2009-04-14 10:19:06 UTC (rev 5012)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java 2009-04-14 10:19:39 UTC (rev 5013)
@@ -26,6 +26,9 @@
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.Socket;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -630,7 +633,7 @@
try
{
- Method purge = SecurityUtility.getDeclaredMethod(Timer.class, "purge", new Class[]{});
+ Method purge = getDeclaredMethod(Timer.class, "purge", new Class[]{});
purge.invoke(timer, new Object[]{});
}
catch (Exception e)
@@ -685,4 +688,32 @@
this.flag = flag;
}
}
+
+ static private Method getDeclaredMethod(final Class c, final String name, final Class[] parameterTypes)
+ throws NoSuchMethodException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ Method m = c.getDeclaredMethod(name, parameterTypes);
+ m.setAccessible(true);
+ return m;
+ }
+
+ try
+ {
+ return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws NoSuchMethodException
+ {
+ Method m = c.getDeclaredMethod(name, parameterTypes);
+ m.setAccessible(true);
+ return m;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (NoSuchMethodException) e.getCause();
+ }
+ }
}
\ No newline at end of file
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2009-04-14 10:19:06 UTC (rev 5012)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2009-04-14 10:19:39 UTC (rev 5013)
@@ -1205,7 +1205,7 @@
try
{
- Method purge = SecurityUtility.getDeclaredMethod(Timer.class, "purge", new Class[]{});
+ Method purge = getDeclaredMethod(Timer.class, "purge", new Class[]{});
purge.invoke(timer, new Object[]{});
}
catch (Exception e)
@@ -1308,4 +1308,32 @@
{
private static final long serialVersionUID = 2846502029152028732L;
}
+
+ static private Method getDeclaredMethod(final Class c, final String name, final Class[] parameterTypes)
+ throws NoSuchMethodException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ Method m = c.getDeclaredMethod(name, parameterTypes);
+ m.setAccessible(true);
+ return m;
+ }
+
+ try
+ {
+ return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws NoSuchMethodException
+ {
+ Method m = c.getDeclaredMethod(name, parameterTypes);
+ m.setAccessible(true);
+ return m;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (NoSuchMethodException) e.getCause();
+ }
+ }
}
\ No newline at end of file
More information about the jboss-remoting-commits
mailing list