JBoss Remoting SVN: r3836 - remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/encryption.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-01 23:56:30 -0400 (Tue, 01 Apr 2008)
New Revision: 3836
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/encryption/EncryptionManager.java
Log:
JBREM-934: Put Thread().getContextClassLoader() call in AccessController.doPrivileged() call.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/encryption/EncryptionManager.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/encryption/EncryptionManager.java 2008-04-02 03:55:07 UTC (rev 3835)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/encryption/EncryptionManager.java 2008-04-02 03:56:30 UTC (rev 3836)
@@ -29,7 +29,9 @@
import java.io.InputStream;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
+import java.security.AccessController;
import java.security.Key;
+import java.security.PrivilegedAction;
import java.util.Map;
//$Id$
@@ -164,7 +166,13 @@
*/
private static Key loadKey(String algo) throws Exception
{
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ ClassLoader tcl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
String file = "org/jboss/remoting/marshall/encryption/"+algo+".key";
InputStream is = tcl.getResourceAsStream(file);
if(is == null)
16 years, 8 months
JBoss Remoting SVN: r3835 - remoting2/branches/2.x/src/main/org/jboss/remoting/loading.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-01 23:55:07 -0400 (Tue, 01 Apr 2008)
New Revision: 3835
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/loading/CompressedClassBytes.java
Log:
JBREM-934: Put ClassLoader.getSystemClassLoader() call in AccessController.doPrivileged() call.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/loading/CompressedClassBytes.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/loading/CompressedClassBytes.java 2008-04-02 03:53:52 UTC (rev 3834)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/loading/CompressedClassBytes.java 2008-04-02 03:55:07 UTC (rev 3835)
@@ -82,7 +82,14 @@
byte buf [] = org.jboss.remoting.loading.ClassUtil.serialize(string);
CompressedClassBytes cb = new CompressedClassBytes("java.lang.String", buf, 9);
byte b1[] = org.jboss.remoting.loading.ClassUtil.serialize(cb);
- Object obj = ClassUtil.deserialize(b1, ClassLoader.getSystemClassLoader());
+ ClassLoader classLoader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return ClassLoader.getSystemClassLoader();
+ }
+ });
+ Object obj = ClassUtil.deserialize(b1, classLoader);
}
catch (Throwable ex)
{
16 years, 8 months
JBoss Remoting SVN: r3834 - remoting2/branches/2.x/src/main/org/jboss/remoting/loading.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-01 23:53:52 -0400 (Tue, 01 Apr 2008)
New Revision: 3834
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassUtil.java
Log:
JBREM-934: Put Thread().getContextClassLoader() and ClassLoader.getSystemClassLoader() calls in AccessController.doPrivileged() calls.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassUtil.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassUtil.java 2008-04-02 03:52:05 UTC (rev 3833)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassUtil.java 2008-04-02 03:53:52 UTC (rev 3834)
@@ -24,6 +24,8 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.HashSet;
import java.util.Set;
import org.jboss.logging.Logger;
@@ -58,11 +60,16 @@
public static Object deserialize(byte buf[])
throws IOException, ClassNotFoundException
{
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if(cl == null)
+ ClassLoader cl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
{
- cl = ClassUtil.class.getClassLoader();
- }
+ public Object run()
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null) loader = ClassUtil.class.getClassLoader();
+ return loader;
+ }
+ });
+
return deserialize(buf, cl);
}
@@ -194,7 +201,13 @@
if(cl == null)
{
- cl = ClassLoader.getSystemClassLoader();
+ cl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return ClassLoader.getSystemClassLoader();
+ }
+ });
}
if(cl != null)
{
16 years, 8 months
JBoss Remoting SVN: r3833 - remoting2/branches/2.x/src/main/org/jboss/remoting/loading.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-01 23:52:05 -0400 (Tue, 01 Apr 2008)
New Revision: 3833
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassByteClassLoader.java
Log:
JBREM-934: Put ClassLoader.getSystemClassLoader() call in AccessController.doPrivileged() call.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassByteClassLoader.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassByteClassLoader.java 2008-04-02 03:49:26 UTC (rev 3832)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassByteClassLoader.java 2008-04-02 03:52:05 UTC (rev 3833)
@@ -23,7 +23,6 @@
import org.jboss.logging.Logger;
import org.jboss.remoting.Client;
-
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -31,6 +30,9 @@
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -152,7 +154,7 @@
super.finalize();
}
- public Class loadClass(String className, ClassBytes bytes[])
+ public Class loadClass(final String className, ClassBytes bytes[])
throws ClassNotFoundException, java.io.IOException
{
// make sure we're OK on the reference queue
@@ -179,7 +181,20 @@
{
return cl;
}
- cl = Class.forName(className, false, ClassLoader.getSystemClassLoader());
+ try
+ {
+ cl = (Class)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws ClassNotFoundException
+ {
+ return Class.forName(className, false, ClassLoader.getSystemClassLoader());
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (ClassNotFoundException) e.getCause();
+ }
if(cl != null)
{
return cl;
16 years, 8 months
JBoss Remoting SVN: r3832 - remoting2/branches/2.x/src/main/org/jboss/remoting/ident.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-01 23:49:26 -0400 (Tue, 01 Apr 2008)
New Revision: 3832
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/ident/Identity.java
Log:
JBREM-934: Put InetAddress.getLocalHost(), System.getProperty(), File.exists(), File.canRead()), new FileInputStream(), File.createNewFile(), and System.setProperty() calls 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-04-02 03:44:36 UTC (rev 3831)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ident/Identity.java 2008-04-02 03:49:26 UTC (rev 3832)
@@ -22,6 +22,7 @@
package org.jboss.remoting.ident;
import org.jboss.remoting.network.NetworkRegistry;
+import org.jboss.remoting.util.SystemUtility;
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -228,11 +229,24 @@
InetAddress localHost = null;
try
{
- localHost = InetAddress.getLocalHost();
+ localHost = (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws IOException
+ {
+ try
+ {
+ return InetAddress.getLocalHost();
+ }
+ catch (IOException e)
+ {
+ return InetAddress.getByName("127.0.0.1");
+ }
+ }
+ });
}
- catch (IOException e)
+ catch (PrivilegedActionException e)
{
- localHost = InetAddress.getByName("127.0.0.1");
+ throw (IOException) e.getCause();
}
String serverid = null;
@@ -267,14 +281,7 @@
private static final synchronized String createId(final MBeanServer server)
{
// we can set as a system property
- String myid = (String)AccessController.doPrivileged( new PrivilegedAction()
- {
- public Object run()
- {
- return System.getProperty("jboss.identity");
- }
- });
-
+ String myid = SystemUtility.getSystemProperty("jboss.identity");
if(myid != null)
{
return myid;
@@ -304,7 +311,7 @@
if(dir != null)
{
- if(dir.exists() == false)
+ if(fileExists(dir) == false)
{
final File finalDir = dir;
AccessController.doPrivileged( new PrivilegedAction()
@@ -342,7 +349,7 @@
}
final File dir = new File(fl);
- if(dir.exists() == false)
+ if(fileExists(dir) == false)
{
AccessController.doPrivileged( new PrivilegedAction()
{
@@ -356,12 +363,37 @@
}
file = new File(dir, "jboss.identity");
}
- if(file.exists() && file.canRead())
+
+ final File finalFile = file;
+ boolean canRead = ((Boolean)AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return new Boolean(finalFile.canRead());
+ }
+ })).booleanValue();
+
+
+ if(fileExists(file) && canRead)
{
InputStream is = null;
try
{
- is = new FileInputStream(file);
+ try
+ {
+ is = (FileInputStream) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return new FileInputStream(finalFile);
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ throw (Exception) e.getCause();
+ }
+
byte buf[] = new byte[800];
int c = is.read(buf);
id = new String(buf, 0, c);
@@ -390,11 +422,39 @@
try
{
id = createUniqueID();
- if(file.exists() == false)
+ if(fileExists(file) == false)
{
- file.createNewFile();
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ finalFile.createNewFile();
+ return null;
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ throw (Exception) e.getCause();
+ }
}
- out = new FileOutputStream(file);
+
+ try
+ {
+ out = (FileOutputStream) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return new FileOutputStream(finalFile);
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ throw (Exception) e.getCause();
+ }
out.write(id.getBytes());
}
catch(Exception ex)
@@ -416,7 +476,23 @@
}
}
}
- System.setProperty("jboss.identity", id);
+
+ try
+ {
+ final String finalId = id;
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ System.setProperty("jboss.identity", finalId);
+ return null;
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ }
+
return id;
}
@@ -426,4 +502,22 @@
// colons don't work in JMX
return id.replace(':', 'x') + random.nextInt(1000);
}
+
+ private static boolean fileExists(final File file)
+ {
+ try
+ {
+ return ((Boolean)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return new Boolean(file.exists());
+ }
+ })).booleanValue();
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
}
16 years, 8 months
JBoss Remoting SVN: r3831 - remoting2/branches/2.x/src/main/org/jboss/remoting/detection/util.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-01 23:44:36 -0400 (Tue, 01 Apr 2008)
New Revision: 3831
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/detection/util/DetectorUtil.java
Log:
JBREM-934: Put MBeanServerFactory.createMBeanServer() and MBeanServer.registerMBean() calls in AccessController.doPrivileged() calls.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/detection/util/DetectorUtil.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/detection/util/DetectorUtil.java 2008-04-02 03:41:43 UTC (rev 3830)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/detection/util/DetectorUtil.java 2008-04-02 03:44:36 UTC (rev 3831)
@@ -21,6 +21,10 @@
*/
package org.jboss.remoting.detection.util;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
@@ -101,10 +105,40 @@
System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis()));
- MBeanServer server = MBeanServerFactory.createMBeanServer();
+ MBeanServer server = null;
+ try
+ {
+ server = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return MBeanServerFactory.createMBeanServer();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
- NetworkRegistry registry = NetworkRegistry.getInstance();
- server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry"));
+ final MBeanServer finalServer = server;
+ final NetworkRegistry registry = NetworkRegistry.getInstance();
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ finalServer.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry"));
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
InvokerLocator locator = new InvokerLocator("socket://localhost");
//ClassLoader clsLoader = Thread.currentThread().getContextClassLoader();
@@ -113,10 +147,26 @@
//server.registerMBean(invokerSvr, objName);
//invokerSvr.start();
- Connector connector = new Connector();
+ final Connector connector = new Connector();
connector.setInvokerLocator(locator.getLocatorURI());
- ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol());
- server.registerMBean(connector, obj);
+ final ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol());
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ finalServer.registerMBean(connector, obj);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+
//connector.create();
connector.start();
@@ -140,8 +190,26 @@
detector = jdet;
objName = new ObjectName("remoting:type=Detector,transport=jndi");
}
-
- server.registerMBean(detector, objName);
+
+ try
+ {
+ final Detector finalDetector = detector;
+ final ObjectName finalObjName = objName;
+
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ finalServer.registerMBean(finalDetector, finalObjName);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+
detector.start();
System.err.println("Starting Detector");
16 years, 8 months
JBoss Remoting SVN: r3830 - remoting2/branches/2.x/src/main/org/jboss/remoting/detection/multicast.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-01 23:41:43 -0400 (Tue, 01 Apr 2008)
New Revision: 3830
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/detection/multicast/MulticastDetector.java
Log:
JBREM-934: Put InetAddress.getByName(), InetAddress.getByName(), and new MulticastSocket() calls in AccessController.doPrivileged() calls.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/detection/multicast/MulticastDetector.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/detection/multicast/MulticastDetector.java 2008-04-02 03:39:18 UTC (rev 3829)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/detection/multicast/MulticastDetector.java 2008-04-02 03:41:43 UTC (rev 3830)
@@ -34,6 +34,9 @@
import java.net.InetSocketAddress;
import java.net.MulticastSocket;
import java.net.SocketAddress;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
/**
* MulticastDetector is a remoting detector that broadcasts detection messages using
@@ -142,19 +145,62 @@
{
if(addr == null)
{
- this.addr = InetAddress.getByName(defaultIP);
+ try
+ {
+ this.addr = (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws IOException
+ {
+ return InetAddress.getByName(defaultIP);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
}
// check to see if we're running on a machine with loopback and no NIC
- InetAddress localHost = InetAddress.getLocalHost();
+ InetAddress localHost = null;
+ try
+ {
+ localHost = (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws IOException
+ {
+ return InetAddress.getLocalHost();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+
if(bindAddr == null && localHost.getHostAddress().equals("127.0.0.1"))
{
// use this to bind so multicast will work w/o network
this.bindAddr = localHost;
}
- SocketAddress saddr = new InetSocketAddress(bindAddr, port);
- socket = new MulticastSocket(saddr);
- socket.joinGroup(addr);
+ try
+ {
+ final SocketAddress saddr = new InetSocketAddress(bindAddr, port);
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws IOException
+ {
+ socket = new MulticastSocket(saddr);
+ socket.joinGroup(addr);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+
super.start();
if(listener == null)
16 years, 8 months
JBoss Remoting SVN: r3829 - remoting2/branches/2.x/src/main/org/jboss/remoting/detection/jndi.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-01 23:39:18 -0400 (Tue, 01 Apr 2008)
New Revision: 3829
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/detection/jndi/JNDIDetector.java
Log:
JBREM-934: Put Class.getClassLoader() and InetAddress.getLocalHost() calls in AccessController.doPrivileged() calls.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/detection/jndi/JNDIDetector.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/detection/jndi/JNDIDetector.java 2008-04-02 03:36:08 UTC (rev 3828)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/detection/jndi/JNDIDetector.java 2008-04-02 03:39:18 UTC (rev 3829)
@@ -37,7 +37,13 @@
import javax.naming.NameAlreadyBoundException;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+
+import java.io.IOException;
import java.net.InetAddress;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Map;
import java.util.Properties;
@@ -291,7 +297,14 @@
}
// Need to actually detect if servers registered in JNDI server
// are actually there (since could die before unregistering)
- ClassLoader cl = JNDIDetector.this.getClass().getClassLoader();
+ ClassLoader cl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return JNDIDetector.class.getClassLoader();
+ }
+ });
+
if(!checkInvokerServer(regMsg, cl))
{
unregisterDetection(regMsg.getIdentity().getInstanceId());
@@ -428,7 +441,22 @@
try
{
log.info("JNDI Server configuration information not present so will create a local server.");
- host = InetAddress.getLocalHost().getHostName();
+
+ try
+ {
+ host = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws IOException
+ {
+ return InetAddress.getLocalHost().getHostName();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+
port = PortUtil.findFreePort(host);
log.info("Remoting JNDI detector starting JNDI server instance since none where specified via configuration.");
16 years, 8 months
JBoss Remoting SVN: r3828 - remoting2/branches/2.x/src/main/org/jboss/remoting/detection.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-01 23:36:08 -0400 (Tue, 01 Apr 2008)
New Revision: 3828
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/detection/AbstractDetector.java
Log:
JBREM-934: Put MBeanServer, MBean proxy, and Class.getClassLoader() calls in AccessController.doPrivileged() calls.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/detection/AbstractDetector.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/detection/AbstractDetector.java 2008-04-02 03:33:04 UTC (rev 3827)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/detection/AbstractDetector.java 2008-04-02 03:36:08 UTC (rev 3828)
@@ -208,7 +208,13 @@
}
else
{
- networkRegistry = (NetworkRegistryMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanserver, registryObjectName, NetworkRegistryMBean.class, false);
+ networkRegistry = (NetworkRegistryMBean)AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return MBeanServerInvocationHandler.newProxyInstance(mbeanserver, registryObjectName, NetworkRegistryMBean.class, false);
+ }
+ });
}
startPinger(getPingerDelay(), getPingerPeriod());
@@ -449,7 +455,7 @@
*
* @param detection
*/
- protected void detect(Detection detection)
+ protected void detect(final Detection detection)
{
if (detection != null)
{
@@ -486,7 +492,15 @@
if (networkRegistry != null)
{
log.debug("detected NEW server: " + detection);
- networkRegistry.addServer(detection.getIdentity(), detection.getServerInvokers());
+
+ AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ networkRegistry.addServer(detection.getIdentity(), detection.getServerInvokers());
+ return null;
+ }
+ });
}
}
else
@@ -501,7 +515,15 @@
{
log.trace("detected UPDATE for server: " + detection);
}
- networkRegistry.updateServer(detection.getIdentity(), detection.getServerInvokers());
+
+ AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ networkRegistry.updateServer(detection.getIdentity(), detection.getServerInvokers());
+ return null;
+ }
+ });
}
}
}
@@ -536,7 +558,7 @@
(acceptLocal ? true : (myself.isSameJVM(detection.getIdentity()) == false));
}
- protected boolean checkInvokerServer(Detection detection, ClassLoader cl)
+ protected boolean checkInvokerServer(final Detection detection, ClassLoader cl)
{
boolean ok = false;
ServerInvokerMetadata[] invokerMetadataArray = detection.getServerInvokers();
@@ -581,8 +603,16 @@
try
{
if(networkRegistry != null)
- {
- networkRegistry.removeServer(detection.getIdentity());
+ {
+ AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ networkRegistry.removeServer(detection.getIdentity());
+ return null;
+ }
+ });
+
log.debug("Removed detection " + detection);
}
}
@@ -635,7 +665,13 @@
{
return;
}
- ClassLoader cl = AbstractDetector.this.getClass().getClassLoader();
+ ClassLoader cl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return AbstractDetector.class.getClassLoader();
+ }
+ });
// walk through each detection and see if it needs checking up on ...
Collection serverCollection = servers.values();
Server[] serverArray = (Server[])serverCollection.toArray(new Server[serverCollection.size()]);
16 years, 8 months
JBoss Remoting SVN: r3827 - remoting2/branches/2.x/src/main/org/jboss/remoting/callback.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-01 23:33:04 -0400 (Tue, 01 Apr 2008)
New Revision: 3827
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java
Log:
JBREM-934: (1) Put MBeanServer calls in AccessController.doPrivileged() calls; (2) replace System.getProperty() with SystemUtility.getSystemProperty().
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java 2008-04-02 03:29:52 UTC (rev 3826)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java 2008-04-02 03:33:04 UTC (rev 3827)
@@ -34,6 +34,7 @@
import org.jboss.remoting.security.SSLSocketBuilder;
import org.jboss.remoting.security.SSLSocketBuilderMBean;
import org.jboss.remoting.security.SSLSocketFactoryService;
+import org.jboss.remoting.util.SystemUtility;
import javax.management.MBeanServer;
import javax.management.MBeanServerInvocationHandler;
@@ -284,17 +285,47 @@
String serverSocketFactoryString = (String) clientConfig.get(ServerInvoker.SERVER_SOCKET_FACTORY);
if (serverSocketFactoryString != null && serverSocketFactoryString.length() > 0)
{
- MBeanServer server = serverInvoker.getMBeanServer();
+ final MBeanServer server = serverInvoker.getMBeanServer();
try
{
- ObjectName serverSocketFactoryObjName = new ObjectName(serverSocketFactoryString);
+ final ObjectName serverSocketFactoryObjName = new ObjectName(serverSocketFactoryString);
if (server != null)
{
- boolean isCorrectType = server.isInstanceOf(serverSocketFactoryObjName, SSLServerSocketFactoryServiceMBean.class.getName());
+ boolean isCorrectType = false;
+ try
+ {
+ isCorrectType = ((Boolean)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ String className = SSLServerSocketFactoryServiceMBean.class.getName();
+ return new Boolean(server.isInstanceOf(serverSocketFactoryObjName, className));
+ }
+ })).booleanValue();
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+
if (isCorrectType)
{
- SSLSocketBuilderMBean sslSocketBuilder = (SSLSocketBuilderMBean)server.
- getAttribute(serverSocketFactoryObjName, "SSLSocketBuilder");
+ SSLSocketBuilderMBean sslSocketBuilder = null;
+ try
+ {
+ sslSocketBuilder = (SSLSocketBuilderMBean)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return server.getAttribute(serverSocketFactoryObjName, "SSLSocketBuilder");
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+
if (sslSocketBuilder != null)
{
SSLSocketBuilder clonedSSLSocketBuilder = (SSLSocketBuilder) sslSocketBuilder.clone();
@@ -438,24 +469,8 @@
}
}
- String separator = "/";
- try
- {
- separator = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return System.getProperty("file.separator");
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- log.debug("error", e.getCause());
- }
-
- newFilePath = newFilePath + separator + "remoting" +
- System.getProperty("file.separator") + sessionId;
+ String separator = SystemUtility.getSystemProperty("file.separator");
+ newFilePath = newFilePath + separator + "remoting" + separator + sessionId;
storeConfig.put(CallbackStore.FILE_PATH_KEY, newFilePath);
16 years, 8 months