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

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Tue Mar 25 04:51:44 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-03-25 04:51:44 -0400 (Tue, 25 Mar 2008)
New Revision: 3741

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/ident/Identity.java
Log:
JBREM-934: Put MBeanServer.getAttribute() in AccessController.doPrivileged() call.

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-25 04:46:15 UTC (rev 3740)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ident/Identity.java	2008-03-25 08:51:44 UTC (rev 3741)
@@ -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;
@@ -34,6 +35,9 @@
 import java.io.Serializable;
 import java.net.InetAddress;
 import java.rmi.dgc.VMID;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Random;
@@ -194,7 +198,7 @@
       return false;
    }
 
-   public static synchronized final Identity get(MBeanServer server)
+   public static synchronized final Identity get(final MBeanServer server)
    {
       if(identities.containsKey(server))
       {
@@ -212,7 +216,22 @@
             localHost = InetAddress.getByName("127.0.0.1");
          }
          
-         String serverid = (String) server.getAttribute(new ObjectName("JMImplementation:type=MBeanServerDelegate"), "MBeanServerId");
+         String serverid = null;
+         try
+         {
+            serverid = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+            {
+               public Object run() throws Exception
+               {
+                  return server.getAttribute(new ObjectName("JMImplementation:type=MBeanServerDelegate"), "MBeanServerId");
+               }
+            });
+         }
+         catch (PrivilegedActionException e)
+         {
+            throw (Exception) e.getCause();
+         }
+
          Identity identity = new Identity(localHost, createId(server), serverid);
          identities.put(server, identity);
          return identity;




More information about the jboss-remoting-commits mailing list