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

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Wed Mar 26 04:24:42 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-03-26 04:24:42 -0400 (Wed, 26 Mar 2008)
New Revision: 3783

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/ident/Identity.java
Log:
JBREM-934: Put File.mkdirs(), System.getProperty(), and MBeanServer.getAttribute() in AccessController.doPrivileged() calls.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ident/Identity.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ident/Identity.java	2008-03-26 08:16:00 UTC (rev 3782)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ident/Identity.java	2008-03-26 08:24:42 UTC (rev 3783)
@@ -21,6 +21,7 @@
 */
 package org.jboss.remoting.ident;
 
+import org.jboss.remoting.loading.ClassByteClassLoader;
 import org.jboss.remoting.network.NetworkRegistry;
 
 import javax.management.MBeanServer;
@@ -264,10 +265,17 @@
       }
    }
 
-   private static final synchronized String createId(MBeanServer server)
+   private static final synchronized String createId(final MBeanServer server)
    {
       // we can set as a system property
-      String myid = System.getProperty("jboss.identity");
+      String myid = (String)AccessController.doPrivileged( new PrivilegedAction()
+      {
+         public Object run()
+         {
+            return  System.getProperty("jboss.identity");
+         }
+      });
+      
       if(myid != null)
       {
          return myid;
@@ -277,13 +285,37 @@
       try
       {
          // FIRST TRY THE JBOSS guy to determine our data directory
-         ObjectName obj = new ObjectName("jboss.system:type=ServerConfig");
-         File dir = (File) server.getAttribute(obj, "ServerDataDir");
+         final ObjectName obj = new ObjectName("jboss.system:type=ServerConfig");
+         File dir = null;
+         
+         try
+         {
+             dir = (File)AccessController.doPrivileged( new PrivilegedExceptionAction()
+             {
+                public Object run() throws Exception
+                {
+                    return server.getAttribute(obj, "ServerDataDir");
+                }
+             });
+         }
+         catch (PrivilegedActionException e)
+         {
+             throw (Exception) e.getCause();
+         }
+         
          if(dir != null)
          {
             if(dir.exists() == false)
             {
-               dir.mkdirs();
+               final File finalDir = dir;
+               AccessController.doPrivileged( new PrivilegedAction()
+               {
+                  public Object run()
+                  {
+                     finalDir.mkdirs();
+                     return null;
+                  }
+               });
             }
             file = new File(dir, "jboss.identity");
          }
@@ -321,7 +353,6 @@
                   return null;
                }
             });
-            
          }
          file = new File(dir, "jboss.identity");
       }




More information about the jboss-remoting-commits mailing list