Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:31:30 -0400 (Tue, 14 Apr 2009)
New Revision: 5028
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/Server.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/Server.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/Server.java 2009-04-14
10:31:06 UTC (rev 5027)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/Server.java 2009-04-14
10:31:30 UTC (rev 5028)
@@ -45,6 +45,9 @@
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import java.util.Map;
@@ -201,7 +204,7 @@
namingBeanImplClass = Class.forName("org.jnp.server.NamingBeanImpl");
namingBean = namingBeanImplClass.newInstance();
Method startMethod = namingBeanImplClass.getMethod("start", new
Class[] {});
- SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
+ setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
startMethod.invoke(namingBean, new Object[] {});
}
catch (Exception e)
@@ -317,6 +320,29 @@
}
}
-
+
+ static private void setSystemProperty(final String name, final String value)
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ System.setProperty(name, value);
+ return;
+ }
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return System.setProperty(name, value);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (RuntimeException) e.getCause();
+ }
+ }
}
Show replies by date