[jboss-remoting-commits] JBoss Remoting SVN: r5004 - remoting2/branches/2.x/src/main/org/jboss/remoting/network.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Tue Apr 14 06:15:47 EDT 2009


Author: ron.sigal at jboss.com
Date: 2009-04-14 06:15:47 -0400 (Tue, 14 Apr 2009)
New Revision: 5004

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/network/NetworkRegistry.java
   remoting2/branches/2.x/src/main/org/jboss/remoting/network/NetworkRegistryQuery.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/network/NetworkRegistry.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/network/NetworkRegistry.java	2009-04-14 10:15:03 UTC (rev 5003)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/network/NetworkRegistry.java	2009-04-14 10:15:47 UTC (rev 5004)
@@ -22,6 +22,9 @@
 
 package org.jboss.remoting.network;
 
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -269,9 +272,9 @@
       Identity identity = Identity.get(this.mBeanServer);
       // this is a slight hack, but we have to have some way to know the main
       // JBoss MBeanServer data
-      SecurityUtility.setSystemProperty("jboss.remoting.jmxid", identity.getJMXId());
-      SecurityUtility.setSystemProperty("jboss.remoting.instanceid", identity.getInstanceId());
-      SecurityUtility.setSystemProperty("jboss.remoting.domain", identity.getDomain());
+      setSystemProperty("jboss.remoting.jmxid", identity.getJMXId());
+      setSystemProperty("jboss.remoting.instanceid", identity.getInstanceId());
+      setSystemProperty("jboss.remoting.domain", identity.getDomain());
       return objectName;
    }
 
@@ -282,7 +285,7 @@
     */
    public synchronized void changeDomain(String newDomain)
    {
-      SecurityUtility.setSystemProperty("jboss.remoting.domain", newDomain);
+      setSystemProperty("jboss.remoting.domain", newDomain);
       NetworkInstance servers[] = getServers();
       if(servers == null || servers.length <= 0)
       {
@@ -305,5 +308,28 @@
          }
       }.start();
    }
-
+   
+   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();
+      }
+   }
 }

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/network/NetworkRegistryQuery.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/network/NetworkRegistryQuery.java	2009-04-14 10:15:03 UTC (rev 5003)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/network/NetworkRegistryQuery.java	2009-04-14 10:15:47 UTC (rev 5004)
@@ -22,6 +22,10 @@
 
 package org.jboss.remoting.network;
 
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
 import javax.management.BadAttributeValueExpException;
 import javax.management.BadBinaryOpValueExpException;
 import javax.management.BadStringOperationException;
@@ -48,7 +52,7 @@
    {
       try
       {
-         return SecurityUtility.isInstanceOf(server, objectName, NetworkRegistryMBean.class.getName());
+         return isInstanceOf(server, objectName, NetworkRegistryMBean.class.getName());
       }
       catch (InstanceNotFoundException e)
       {
@@ -61,4 +65,28 @@
    {
       this.server = mBeanServer;
    }
+   
+   static private boolean isInstanceOf(final MBeanServer server, final ObjectName objectName, final String className)
+   throws InstanceNotFoundException
+   {
+      if (SecurityUtility.skipAccessControl())
+      {
+         return server.isInstanceOf(objectName, className);
+      }
+      
+      try
+      {
+         return ((Boolean)AccessController.doPrivileged( new PrivilegedExceptionAction()
+         {
+            public Object run() throws Exception
+            {
+               return new Boolean(server.isInstanceOf(objectName, className));
+            }
+         })).booleanValue();
+      }
+      catch (PrivilegedActionException e)
+      {
+         throw (InstanceNotFoundException) e.getCause();
+      }
+   }
 }




More information about the jboss-remoting-commits mailing list