[jboss-remoting-commits] JBoss Remoting SVN: r5006 - remoting2/branches/2.x/src/main/org/jboss/remoting/samples/transporter/custom/server.

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


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

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/samples/transporter/custom/server/JNDIServer.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/samples/transporter/custom/server/JNDIServer.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/samples/transporter/custom/server/JNDIServer.java	2009-04-14 10:16:19 UTC (rev 5005)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/samples/transporter/custom/server/JNDIServer.java	2009-04-14 10:16:38 UTC (rev 5006)
@@ -27,6 +27,9 @@
 
 import java.lang.reflect.Method;
 import java.net.InetAddress;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 
 /**
  * @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
@@ -46,7 +49,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)
@@ -81,4 +84,28 @@
       }
 
    }
+   
+   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();
+      }
+   }
 }
\ No newline at end of file




More information about the jboss-remoting-commits mailing list