[jboss-remoting-commits] JBoss Remoting SVN: r5005 - remoting2/branches/2.x/src/main/org/jboss/remoting/samples/detection/jndi.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Tue Apr 14 06:16:19 EDT 2009


Author: ron.sigal at jboss.com
Date: 2009-04-14 06:16:19 -0400 (Tue, 14 Apr 2009)
New Revision: 5005

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

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/samples/detection/jndi/SimpleJNDIServer.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/samples/detection/jndi/SimpleJNDIServer.java	2009-04-14 10:15:47 UTC (rev 5004)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/samples/detection/jndi/SimpleJNDIServer.java	2009-04-14 10:16:19 UTC (rev 5005)
@@ -5,6 +5,9 @@
 
 import java.lang.reflect.Method;
 import java.net.InetAddress;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 
 /**
  * A JNDI server that should be run before running the simple detector client/server.
@@ -95,7 +98,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)
@@ -129,5 +132,28 @@
    {
       System.out.println(new java.util.Date() + ": [SERVER]: " + msg);
    }
-
+   
+   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();
+      }
+   }
 }




More information about the jboss-remoting-commits mailing list