JBoss Remoting SVN: r3947 - remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:11:22 -0400 (Fri, 11 Apr 2008)
New Revision: 3947
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java
Log:
JBREM-934: Several methods check SecurityUtility.skipAccessControl().
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java 2008-04-12 01:10:24 UTC (rev 3946)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java 2008-04-12 01:11:22 UTC (rev 3947)
@@ -28,6 +28,7 @@
import org.jboss.remoting.serialization.IMarshalledValue;
import org.jboss.remoting.serialization.SerializationManager;
import org.jboss.remoting.serialization.SerializationStreamFactory;
+import org.jboss.remoting.util.SecurityUtility;
import org.jboss.serial.io.JBossObjectInputStream;
import org.jboss.serial.io.JBossObjectOutputStream;
import org.jboss.serial.util.StringUtilBuffer;
@@ -58,6 +59,11 @@
{
if (trace) { log.trace(this + " creating JBossObjectInputStream"); }
+ if (SecurityUtility.skipAccessControl())
+ {
+ return new JBossObjectInputStream(input, loader, new StringUtilBuffer(10024, 10024));
+ }
+
try
{
return (ObjectInputStream)AccessController.doPrivileged( new PrivilegedExceptionAction()
@@ -78,6 +84,11 @@
{
if (trace) { log.trace(this + " creating JBossObjectOutputStream"); }
+ if (SecurityUtility.skipAccessControl())
+ {
+ return new JBossObjectOutputStream(output, new StringUtilBuffer(10024, 10024));
+ }
+
try
{
return (ObjectOutputStream)AccessController.doPrivileged( new PrivilegedExceptionAction()
@@ -117,6 +128,12 @@
public void sendObject(final ObjectOutputStream oos, final Object dataObject, int version) throws IOException
{
+ if (SecurityUtility.skipAccessControl())
+ {
+ oos.writeObject(dataObject);
+ oos.flush();
+ }
+
try
{
AccessController.doPrivileged( new PrivilegedExceptionAction()
@@ -166,6 +183,11 @@
}
}
+ if (SecurityUtility.skipAccessControl())
+ {
+ return objInputStream.readObject();
+ }
+
try
{
final ObjectInputStream ois = objInputStream;
18 years
JBoss Remoting SVN: r3946 - remoting2/branches/2.x/src/main/org/jboss/remoting/serialization.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:10:24 -0400 (Fri, 11 Apr 2008)
New Revision: 3946
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/SerializationStreamFactory.java
Log:
JBREM-934: (1) Replaced AccessController.doPrivileged() calls with SecurityUtility calls; (2) renamed SystemUtility SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/SerializationStreamFactory.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/SerializationStreamFactory.java 2008-04-12 01:07:26 UTC (rev 3945)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/SerializationStreamFactory.java 2008-04-12 01:10:24 UTC (rev 3946)
@@ -26,6 +26,7 @@
import org.jboss.remoting.serialization.impl.java.JavaEncryptionSerializationManager;
import org.jboss.remoting.serialization.impl.java.JavaSerializationManager;
import org.jboss.remoting.serialization.impl.jboss.JBossEncryptionSerializationManager;
+import org.jboss.remoting.util.SecurityUtility;
import java.io.IOException;
import java.security.AccessController;
@@ -58,21 +59,8 @@
{
try
{
- String managerClassName = JavaSerializationManager.class.getName();
- try
- {
- managerClassName = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return System.getProperty("SERIALIZATION", JavaSerializationManager.class.getName());
- }
- });
- }
- catch (Exception e)
- {
- log.debug("error", e.getCause());
- }
+ String defaultValue = JavaSerializationManager.class.getName();
+ String managerClassName = SecurityUtility.getSystemProperty("SERIALIZATION", defaultValue);
setManagerClassName(DEFAULT, managerClassName);
}
catch(Exception e)
18 years
JBoss Remoting SVN: r3945 - remoting2/branches/2.x/src/main/org/jboss/remoting/security.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:07:26 -0400 (Fri, 11 Apr 2008)
New Revision: 3945
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/security/SSLSocketBuilder.java
Log:
JBREM-934: (1) Replaced AccessController.doPrivileged() calls with SecurityUtility calls; (2) renamed SystemUtility SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/security/SSLSocketBuilder.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/security/SSLSocketBuilder.java 2008-04-12 01:06:55 UTC (rev 3944)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/security/SSLSocketBuilder.java 2008-04-12 01:07:26 UTC (rev 3945)
@@ -23,7 +23,7 @@
import org.jboss.logging.Logger;
import org.jboss.remoting.serialization.ClassLoaderUtility;
-import org.jboss.remoting.util.SystemUtility;
+import org.jboss.remoting.util.SecurityUtility;
import org.jboss.remoting.util.socket.RemotingKeyManager;
import javax.net.ServerSocketFactory;
@@ -396,30 +396,15 @@
if (getUseSSLSocketFactory())
{
- String defaultFactoryName = SystemUtility.getSystemProperty(REMOTING_DEFAULT_SOCKET_FACTORY_CLASS);
+ String defaultFactoryName = SecurityUtility.getSystemProperty(REMOTING_DEFAULT_SOCKET_FACTORY_CLASS);
if (defaultFactoryName != null)
{
try
{
final Class sfClass = ClassLoaderUtility.loadClass(defaultFactoryName, SSLSocketBuilder.class);
- Method m =null;
+ Method m = SecurityUtility.getMethod(sfClass, "getDefault", null);
- try
- {
- m = (Method)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return sfClass.getMethod("getDefault", null);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (Exception) e.getCause();
- }
-
if (m == null)
{
throw new RuntimeException(
@@ -631,7 +616,7 @@
if(keyStoreFilePath == null)
{
- String path = SystemUtility.getSystemProperty(STANDARD_KEY_STORE_FILE_PATH);;
+ String path = SecurityUtility.getSystemProperty(STANDARD_KEY_STORE_FILE_PATH);;
if(path != null && path.length() > 0)
{
setKeyStoreURL( path );
@@ -685,7 +670,7 @@
if(keyStoreType == null)
{
- keyStoreType = SystemUtility.getSystemProperty(STANDARD_KEY_STORE_TYPE);
+ keyStoreType = SecurityUtility.getSystemProperty(STANDARD_KEY_STORE_TYPE);
if(keyStoreType == null)
{
keyStoreType = DEFAULT_KEY_STORE_TYPE;
@@ -761,7 +746,7 @@
if(keyStorePassword == null)
{
- keyStorePassword = SystemUtility.getSystemProperty(STANDARD_KEY_STORE_PASSWORD);
+ keyStorePassword = SecurityUtility.getSystemProperty(STANDARD_KEY_STORE_PASSWORD);
}
return keyStorePassword;
@@ -812,7 +797,7 @@
if(trustStoreFilePath == null)
{
- String path = SystemUtility.getSystemProperty(STANDARD_TRUST_STORE_FILE_PATH);
+ String path = SecurityUtility.getSystemProperty(STANDARD_TRUST_STORE_FILE_PATH);
if(path != null && path.length() > 0)
{
setTrustStoreURL( path );
@@ -866,7 +851,7 @@
if(trustStoreType == null)
{
- trustStoreType = SystemUtility.getSystemProperty(STANDARD_TRUST_STORE_TYPE);
+ trustStoreType = SecurityUtility.getSystemProperty(STANDARD_TRUST_STORE_TYPE);
if(trustStoreType == null)
{
trustStoreType = getKeyStoreType();
@@ -942,7 +927,7 @@
if(trustStorePassword == null)
{
- trustStorePassword = SystemUtility.getSystemProperty(STANDARD_TRUST_STORE_PASSWORD);
+ trustStorePassword = SecurityUtility.getSystemProperty(STANDARD_TRUST_STORE_PASSWORD);
if(trustStorePassword == null)
{
trustStorePassword = getKeyStorePassword();
18 years
JBoss Remoting SVN: r3944 - remoting2/branches/2.x/src/main/org/jboss/remoting/security.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:06:55 -0400 (Fri, 11 Apr 2008)
New Revision: 3944
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java
Log:
JBREM-934: Replaced AccessController.doPrivileged() call with SecurityUtility.createServerSocket().
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java 2008-04-12 01:06:08 UTC (rev 3943)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java 2008-04-12 01:06:55 UTC (rev 3944)
@@ -22,6 +22,9 @@
package org.jboss.remoting.security;
import javax.net.ServerSocketFactory;
+
+import org.jboss.remoting.util.SecurityUtility;
+
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
@@ -43,82 +46,22 @@
public ServerSocket createServerSocket(final int i) throws IOException
{
- ServerSocket ss = null;
- try
- {
- ss = (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return serverSocketFactory.createServerSocket(i);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (IOException) e.getCause();
- }
- return ss;
+ return SecurityUtility.createServerSocket(serverSocketFactory, i);
}
public ServerSocket createServerSocket(final int i, final int i1) throws IOException
{
- ServerSocket ss = null;
- try
- {
- ss = (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return serverSocketFactory.createServerSocket(i, i1);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (IOException) e.getCause();
- }
- return ss;
+ return SecurityUtility.createServerSocket(serverSocketFactory, i, i1);
}
public ServerSocket createServerSocket(final int i, final int i1, final InetAddress inetAddress) throws IOException
{
- ServerSocket ss = null;
- try
- {
- ss = (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return serverSocketFactory.createServerSocket(i, i1, inetAddress);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (IOException) e.getCause();
- }
- return ss;
+ return SecurityUtility.createServerSocket(serverSocketFactory, i, i1, inetAddress);
}
public ServerSocket createServerSocket() throws IOException
{
- ServerSocket ss = null;
- try
- {
- ss = (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return serverSocketFactory.createServerSocket();
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (IOException) e.getCause();
- }
- return ss;
+ return serverSocketFactory.createServerSocket();
}
public ServerSocketFactoryMBean getDelegate()
18 years
JBoss Remoting SVN: r3943 - remoting2/branches/2.x/src/main/org/jboss/remoting/network.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:06:08 -0400 (Fri, 11 Apr 2008)
New Revision: 3943
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/network/NetworkRegistryQuery.java
Log:
JBREM-934: Replaced AccessController.doPrivileged() call with SecurityUtility.isInstanceOf().
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 2008-04-12 01:05:41 UTC (rev 3942)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/network/NetworkRegistryQuery.java 2008-04-12 01:06:08 UTC (rev 3943)
@@ -29,11 +29,14 @@
import javax.management.BadAttributeValueExpException;
import javax.management.BadBinaryOpValueExpException;
import javax.management.BadStringOperationException;
+import javax.management.InstanceNotFoundException;
import javax.management.InvalidApplicationException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.QueryExp;
+import org.jboss.remoting.util.SecurityUtility;
+
/**
* NetworkRegistryQuery is a QueryExp that will filter on NetworkRegistryMBean mbeans.
*
@@ -49,15 +52,9 @@
{
try
{
- return ((Boolean)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return new Boolean(server.isInstanceOf(objectName, NetworkRegistryMBean.class.getName()));
- }
- })).booleanValue();
+ return SecurityUtility.isInstanceOf(server, objectName, NetworkRegistryMBean.class.getName());
}
- catch (PrivilegedActionException e)
+ catch (InstanceNotFoundException e)
{
}
18 years
JBoss Remoting SVN: r3942 - remoting2/branches/2.x/src/main/org/jboss/remoting/network.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:05:41 -0400 (Fri, 11 Apr 2008)
New Revision: 3942
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/network/NetworkRegistry.java
Log:
JBREM-934: Renamed SystemUtility to 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 2008-04-12 01:04:50 UTC (rev 3941)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/network/NetworkRegistry.java 2008-04-12 01:05:41 UTC (rev 3942)
@@ -37,7 +37,7 @@
import org.jboss.remoting.InvokerRegistry;
import org.jboss.remoting.detection.ServerInvokerMetadata;
import org.jboss.remoting.ident.Identity;
-import org.jboss.remoting.util.SystemUtility;
+import org.jboss.remoting.util.SecurityUtility;
/**
* NetworkRegistry is a concrete implemenation of the NetworkRegistryMBean
@@ -269,9 +269,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
- SystemUtility.setSystemProperty("jboss.remoting.jmxid", identity.getJMXId());
- SystemUtility.setSystemProperty("jboss.remoting.instanceid", identity.getInstanceId());
- SystemUtility.setSystemProperty("jboss.remoting.domain", identity.getDomain());
+ SecurityUtility.setSystemProperty("jboss.remoting.jmxid", identity.getJMXId());
+ SecurityUtility.setSystemProperty("jboss.remoting.instanceid", identity.getInstanceId());
+ SecurityUtility.setSystemProperty("jboss.remoting.domain", identity.getDomain());
return objectName;
}
@@ -282,7 +282,7 @@
*/
public synchronized void changeDomain(String newDomain)
{
- SystemUtility.setSystemProperty("jboss.remoting.domain", newDomain);
+ SecurityUtility.setSystemProperty("jboss.remoting.domain", newDomain);
NetworkInstance servers[] = getServers();
if(servers == null || servers.length <= 0)
{
18 years
JBoss Remoting SVN: r3941 - 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-11 21:04:50 -0400 (Fri, 11 Apr 2008)
New Revision: 3941
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ObjectInputStreamWithClassLoader.java
Log:
JBREM-934: Replaced AccessController.doPrivileged() call with SecurityUtility.getDeclaredMethod().
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ObjectInputStreamWithClassLoader.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ObjectInputStreamWithClassLoader.java 2008-04-12 01:03:37 UTC (rev 3940)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ObjectInputStreamWithClassLoader.java 2008-04-12 01:04:50 UTC (rev 3941)
@@ -22,18 +22,14 @@
package org.jboss.remoting.loading;
-import java.beans.IntrospectionException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.StreamCorruptedException;
import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import org.jboss.logging.Logger;
-import org.jboss.util.propertyeditor.PropertyEditors;
+import org.jboss.remoting.util.SecurityUtility;
/**
@@ -56,20 +52,7 @@
{
try
{
- try {
- clearMethod = (Method) AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws SecurityException, NoSuchMethodException
- {
- return ObjectInputStream.class.getDeclaredMethod("clear", new Class[]{});
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (NoSuchMethodException) e.getCause();
- }
-
+ clearMethod = SecurityUtility.getDeclaredMethod(ObjectInputStream.class, "clear", new Class[]{});
clearMethod.setAccessible(true);
} catch (SecurityException e) {
18 years
JBoss Remoting SVN: r3940 - 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-11 21:03:37 -0400 (Fri, 11 Apr 2008)
New Revision: 3940
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassByteClassLoader.java
Log:
JBREM-934: Replaced AccessController.doPrivileged() call with SecurityUtility.forName().
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-12 01:01:10 UTC (rev 3939)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassByteClassLoader.java 2008-04-12 01:03:37 UTC (rev 3940)
@@ -23,6 +23,8 @@
import org.jboss.logging.Logger;
import org.jboss.remoting.Client;
+import org.jboss.remoting.util.SecurityUtility;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -30,9 +32,6 @@
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;
@@ -181,20 +180,7 @@
{
return cl;
}
- 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();
- }
+ cl = Class.forName(className, false, SecurityUtility.getSystemClassLoader());
if(cl != null)
{
return cl;
18 years
JBoss Remoting SVN: r3939 - 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-11 21:01:10 -0400 (Fri, 11 Apr 2008)
New Revision: 3939
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/ident/Identity.java
Log:
JBREM-934: (1) Replaced AccessController.doPrivileged() calls with SecurityUtility calls; (2) renamed SystemUtility SecurityUtility.
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-12 01:00:20 UTC (rev 3938)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ident/Identity.java 2008-04-12 01:01:10 UTC (rev 3939)
@@ -22,7 +22,7 @@
package org.jboss.remoting.ident;
import org.jboss.remoting.network.NetworkRegistry;
-import org.jboss.remoting.util.SystemUtility;
+import org.jboss.remoting.util.SecurityUtility;
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -60,20 +60,7 @@
static
{
- try
- {
- _domain = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return System.getProperty("jboss.identity.domain", DEFAULT_DOMAIN);
- }
- });
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
+ _domain = SecurityUtility.getSystemProperty("jboss.identity.domain", DEFAULT_DOMAIN);
}
private static transient Map identities = new WeakHashMap(2);
@@ -113,7 +100,7 @@
}
ident.calcHashCode();
}
- SystemUtility.setSystemProperty("jboss.identity.domain", domain);
+ SecurityUtility.setSystemProperty("jboss.identity.domain", domain);
_domain = domain;
NetworkRegistry.getInstance().changeDomain(domain);
}
@@ -226,45 +213,9 @@
}
try
{
- InetAddress localHost = null;
- try
- {
- 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 (PrivilegedActionException e)
- {
- throw (IOException) e.getCause();
- }
-
- 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();
- }
-
+ InetAddress localHost = SecurityUtility.getLocalHost();
+ ObjectName objectName = new ObjectName("JMImplementation:type=MBeanServerDelegate");
+ String serverid = (String) SecurityUtility.getMBeanAttribute(server, objectName, "MBeanServerId");
Identity identity = new Identity(localHost, createId(server), serverid);
identities.put(server, identity);
return identity;
@@ -281,7 +232,7 @@
private static final synchronized String createId(final MBeanServer server)
{
// we can set as a system property
- String myid = SystemUtility.getSystemProperty("jboss.identity");
+ String myid = SecurityUtility.getSystemProperty("jboss.identity");
if(myid != null)
{
return myid;
@@ -292,28 +243,12 @@
{
// FIRST TRY THE JBOSS guy to determine our data directory
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();
- }
-
+ File dir = (File) SecurityUtility.getMBeanAttribute(server, obj, "ServerDataDir");
if(dir != null)
{
- if(fileExists(dir) == false)
+ if(SecurityUtility.fileExists(dir) == false)
{
- SystemUtility.mkdirs(dir);
+ SecurityUtility.mkdirs(dir);
}
file = new File(dir, "jboss.identity");
}
@@ -324,60 +259,23 @@
if(file == null)
{
// we may not have that mbean, which is OK
- String fl = ".";
- try
- {
- fl = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return System.getProperty("jboss.identity.dir", ".");
- }
- });
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
+ String fl = SecurityUtility.getSystemProperty("jboss.identity.dir", ".");
- final File dir = new File(fl);
- if(fileExists(dir) == false)
+ File dir = new File(fl);
+ if(SecurityUtility.fileExists(dir) == false)
{
- SystemUtility.mkdirs(dir);
+ SecurityUtility.mkdirs(dir);
}
file = new File(dir, "jboss.identity");
}
- final File finalFile = file;
- boolean canRead = ((Boolean)AccessController.doPrivileged( new PrivilegedAction()
+ boolean canRead = SecurityUtility.canRead(file);
+ if(SecurityUtility.fileExists(file) && canRead)
{
- public Object run()
- {
- return new Boolean(finalFile.canRead());
- }
- })).booleanValue();
-
-
- if(fileExists(file) && canRead)
- {
InputStream is = null;
try
{
- try
- {
- is = (FileInputStream) AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return new FileInputStream(finalFile);
- }
- });
- }
- catch (Exception e)
- {
- throw (Exception) e.getCause();
- }
-
+ is = SecurityUtility.getFileInputStream(file);
byte buf[] = new byte[800];
int c = is.read(buf);
id = new String(buf, 0, c);
@@ -406,39 +304,12 @@
try
{
id = createUniqueID();
- if(fileExists(file) == false)
+ if(SecurityUtility.fileExists(file) == false)
{
- try
- {
- AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- finalFile.createNewFile();
- return null;
- }
- });
- }
- catch (Exception e)
- {
- throw (Exception) e.getCause();
- }
+ SecurityUtility.createNewFile(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 = SecurityUtility.getFileOutputStream(file);
out.write(id.getBytes());
}
catch(Exception ex)
@@ -461,7 +332,7 @@
}
}
- SystemUtility.setSystemProperty("jboss.identity", id);
+ SecurityUtility.setSystemProperty("jboss.identity", id);
return id;
}
@@ -472,22 +343,4 @@
// 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;
- }
- }
}
18 years
JBoss Remoting SVN: r3938 - 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-11 21:00:20 -0400 (Fri, 11 Apr 2008)
New Revision: 3938
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/detection/util/DetectorUtil.java
Log:
JBREM-934: Replaced AccessController.doPrivileged() calls with SecurityUtility 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-12 00:59:32 UTC (rev 3937)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/detection/util/DetectorUtil.java 2008-04-12 01:00:20 UTC (rev 3938)
@@ -37,7 +37,7 @@
import org.jboss.remoting.network.NetworkInstance;
import org.jboss.remoting.network.NetworkRegistry;
import org.jboss.remoting.transport.Connector;
-import org.jboss.remoting.util.SystemUtility;
+import org.jboss.remoting.util.SecurityUtility;
/**
@@ -104,43 +104,12 @@
org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG);
Logger log = Logger.getLogger(getClass());
- SystemUtility.setSystemProperty("jboss.identity", String.valueOf(System.currentTimeMillis()));
+ SecurityUtility.setSystemProperty("jboss.identity", String.valueOf(System.currentTimeMillis()));
- 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();
- }
-
- 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();
- }
-
+ MBeanServer server = SecurityUtility.createMBeanServer();
+ NetworkRegistry registry = NetworkRegistry.getInstance();
+ SecurityUtility.registerMBean(server, registry, new ObjectName("remoting:type=NetworkRegistry"));
+
InvokerLocator locator = new InvokerLocator("socket://localhost");
//ClassLoader clsLoader = Thread.currentThread().getContextClassLoader();
//SocketServerInvoker invokerSvr = new SocketServerInvoker(clsLoader, locator);
@@ -148,26 +117,10 @@
//server.registerMBean(invokerSvr, objName);
//invokerSvr.start();
- final Connector connector = new Connector();
+ Connector connector = new Connector();
connector.setInvokerLocator(locator.getLocatorURI());
- 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();
- }
-
+ ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol());
+ SecurityUtility.registerMBean(server, connector, obj);
//connector.create();
connector.start();
@@ -192,25 +145,7 @@
objName = new ObjectName("remoting:type=Detector,transport=jndi");
}
- 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();
- }
-
+ SecurityUtility.registerMBean(server, detector, objName);
detector.start();
System.err.println("Starting Detector");
18 years