JBoss Remoting SVN: r3977 - remoting2/branches/2.x/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-12 02:20:00 -0400 (Sat, 12 Apr 2008)
New Revision: 3977
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java
Log:
JBREM-951: Eliminated replaced "listeners" lock use of "lock" lock throughout.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java 2008-04-12 04:32:06 UTC (rev 3976)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java 2008-04-12 06:20:00 UTC (rev 3977)
@@ -320,7 +320,7 @@
{
if (listener != null)
{
- synchronized (listeners)
+ synchronized (lock)
{
if (listeners.size() == 0)
{
@@ -336,7 +336,7 @@
boolean isRemoved = false;
if (listener != null)
{
- synchronized (listeners)
+ synchronized (lock)
{
isRemoved = listeners.remove(listener);
if (listeners.size() == 0)
@@ -548,7 +548,7 @@
private void notifyListeners(Throwable thr)
{
final Throwable t = thr;
- synchronized (listeners)
+ synchronized (lock)
{
ListIterator itr = listeners.listIterator();
while (itr.hasNext())
17 years, 7 months
JBoss Remoting SVN: r3976 - 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-12 00:32:06 -0400 (Sat, 12 Apr 2008)
New Revision: 3976
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java
Log:
JBREM-934: In sendObject(), return after oos.flush() if SecurityUtility.skipAccessControl() == true.
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 03:38:46 UTC (rev 3975)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java 2008-04-12 04:32:06 UTC (rev 3976)
@@ -132,6 +132,7 @@
{
oos.writeObject(dataObject);
oos.flush();
+ return;
}
try
17 years, 7 months
JBoss Remoting SVN: r3975 - remoting2/branches/2.x/src/etc.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 23:38:46 -0400 (Fri, 11 Apr 2008)
New Revision: 3975
Modified:
remoting2/branches/2.x/src/etc/remoting.security.policy.core
Log:
JBREM-934: Added PropertyPermission for "skipControlAccess".
Modified: remoting2/branches/2.x/src/etc/remoting.security.policy.core
===================================================================
--- remoting2/branches/2.x/src/etc/remoting.security.policy.core 2008-04-12 02:46:41 UTC (rev 3974)
+++ remoting2/branches/2.x/src/etc/remoting.security.policy.core 2008-04-12 03:38:46 UTC (rev 3975)
@@ -205,6 +205,10 @@
// Used by org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker
permission java.util.PropertyPermission "org.jboss.security.ignoreHttpsHost" , "read";
+
+ // Used by org.jboss.remoting.util.SecurityUtility
+// permission java.util.PropertyPermission "java.security.manager", "read";
+ permission java.util.PropertyPermission "skipAccessControl", "read";
// Used by org.jboss.remoting.Version
permission java.util.PropertyPermission "jboss.remoting.pre_2_0_compatible", "read";
17 years, 7 months
JBoss Remoting SVN: r3974 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 22:46:41 -0400 (Fri, 11 Apr 2008)
New Revision: 3974
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java
Log:
JBREM-934: (1) Took PropertyEditors.mapJavaBeanProperties() out of AccessController.doPrivileged() call.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java 2008-04-12 02:46:26 UTC (rev 3973)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java 2008-04-12 02:46:41 UTC (rev 3974)
@@ -182,25 +182,8 @@
protected void setup() throws Exception
{
props.putAll(getConfiguration());
- try
- {
- AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws IntrospectionException
- {
- PropertyEditors.mapJavaBeanProperties(SocketServerInvoker.this, props, false);
- return null;
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- log.debug(e.toString(), e);
- throw e;
- }
-
+ PropertyEditors.mapJavaBeanProperties(SocketServerInvoker.this, props, false);
super.setup();
-
String ssclass = props.getProperty(SERVER_SOCKET_CLASS_FLAG);
if(ssclass != null)
{
17 years, 7 months
JBoss Remoting SVN: r3973 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 22:46:26 -0400 (Fri, 11 Apr 2008)
New Revision: 3973
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
Log:
JBREM-934: (1) Took PropertyEditors.mapJavaBeanProperties() out of AccessController.doPrivileged() call.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java 2008-04-12 02:45:48 UTC (rev 3972)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java 2008-04-12 02:46:26 UTC (rev 3973)
@@ -482,26 +482,9 @@
protected void setup() throws Exception
{
- final Properties props = new Properties();
+ Properties props = new Properties();
props.putAll(configuration);
-
- try
- {
- AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws IntrospectionException
- {
- PropertyEditors.mapJavaBeanProperties(MicroSocketClientInvoker.this, props, false);
- return null;
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- log.debug(e.toString(), e);
- throw e;
- }
-
+ PropertyEditors.mapJavaBeanProperties(MicroSocketClientInvoker.this, props, false);
configureParameters();
if (!InvokerLocator.MULTIHOME.equals(locator.getHost()))
17 years, 7 months
JBoss Remoting SVN: r3972 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 22:45:48 -0400 (Fri, 11 Apr 2008)
New Revision: 3972
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi/RMIServerInvoker.java
Log:
JBREM-934: (1) Took Registry.rebind() and PropertyEditors.mapJavaBeanProperties() out of AccessController.doPrivileged() calls; (2) replaced AccessController.doPrivileged() call with SecurityUtility call.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi/RMIServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi/RMIServerInvoker.java 2008-04-12 02:06:06 UTC (rev 3971)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi/RMIServerInvoker.java 2008-04-12 02:45:48 UTC (rev 3972)
@@ -39,33 +39,26 @@
import org.jboss.remoting.marshal.serializable.SerializableMarshaller;
import org.jboss.remoting.serialization.SerializationManager;
import org.jboss.remoting.serialization.SerializationStreamFactory;
+import org.jboss.remoting.util.SecurityUtility;
import org.jboss.util.propertyeditor.PropertyEditors;
import org.jboss.logging.Logger;
import javax.net.SocketFactory;
-import java.beans.IntrospectionException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.rmi.AccessException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.ExportException;
-import java.rmi.server.RMIClientSocketFactory;
import java.rmi.server.RMIServerSocketFactory;
import java.rmi.server.RemoteServer;
import java.rmi.server.ServerNotActiveException;
import java.rmi.server.UnicastRemoteObject;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -147,26 +140,9 @@
protected void setup() throws Exception
{
- final Properties props = new Properties();
+ Properties props = new Properties();
props.putAll(getConfiguration());
-
- try
- {
- AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws IntrospectionException
- {
- PropertyEditors.mapJavaBeanProperties(RMIServerInvoker.this, props, false);
- return null;
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- log.debug(e.toString(), e);
- throw e;
- }
-
+ PropertyEditors.mapJavaBeanProperties(RMIServerInvoker.this, props, false);
super.setup();
}
@@ -203,9 +179,8 @@
throw new IOException(e.getMessage());
}
- final Registry finalRegistry = registry;
String bindHost = bindHome.host;
- final int bindPort = bindHome.port;
+ int bindPort = bindHome.port;
String clientConnectHost = connectHome.host;
if(clientConnectHost == null)
@@ -219,32 +194,8 @@
stub = UnicastRemoteObject.exportObject(this, bindPort, csf, ssf);
log.debug("Binding server to \"remoting/RMIServerInvoker/" + bindPort + "\" in registry");
-
- try
- {
- AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws AccessException, RemoteException
- {
- finalRegistry.rebind("remoting/RMIServerInvoker/" + bindPort, RMIServerInvoker.this);
- return null;
- }
- });
- }
- catch (Exception e)
- {
- log.debug(e.toString(), e);
- throw (IOException) e.getCause();
- }
-
- ClassLoader classLoader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
- {
- public Object run()
- {
- return RMIServerInvoker.class.getClassLoader();
- }
- });
-
+ registry.rebind("remoting/RMIServerInvoker/" + bindPort, RMIServerInvoker.this);
+ ClassLoader classLoader = SecurityUtility.getClassLoader(RMIServerInvoker.class);
unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), classLoader);
marshaller = MarshalFactory.getMarshaller(getLocator(), classLoader);
}
@@ -460,22 +411,8 @@
}
try
{
- final String clientHost = RemoteServer.getClientHost();
- InetAddress clientAddress = null;
- try
- {
- clientAddress = (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws UnknownHostException
- {
- return InetAddress.getByName(clientHost);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (UnknownHostException) e.getCause();
- }
+ String clientHost = RemoteServer.getClientHost();
+ InetAddress clientAddress = SecurityUtility.getAddressByName(clientHost);
metadata.put(Remoting.CLIENT_ADDRESS, clientAddress);
}
catch (ServerNotActiveException e)
17 years, 7 months
JBoss Remoting SVN: r3971 - remoting2/branches/2.x.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 22:06:06 -0400 (Fri, 11 Apr 2008)
New Revision: 3971
Modified:
remoting2/branches/2.x/build.sh
Log:
JBREM-876: Increased ant space to 700M.
Modified: remoting2/branches/2.x/build.sh
===================================================================
--- remoting2/branches/2.x/build.sh 2008-04-12 01:51:27 UTC (rev 3970)
+++ remoting2/branches/2.x/build.sh 2008-04-12 02:06:06 UTC (rev 3971)
@@ -145,7 +145,7 @@
fi
# Set the max memory to 256m
- ANT_OPTS=-Xmx256m
+ ANT_OPTS=-Xmx700m
# setup some build properties
ANT_OPTS="$ANT_OPTS -Dbuild.script=$0"
17 years, 7 months
JBoss Remoting SVN: r3970 - remoting2/branches/2.x/src/tests/org/jboss/ant/taskdefs.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:51:27 -0400 (Fri, 11 Apr 2008)
New Revision: 3970
Modified:
remoting2/branches/2.x/src/tests/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.java
Log:
JBREM-934: Renamed SystemUtility SecurityUtility.
Modified: remoting2/branches/2.x/src/tests/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.java 2008-04-12 01:46:27 UTC (rev 3969)
+++ remoting2/branches/2.x/src/tests/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.java 2008-04-12 01:51:27 UTC (rev 3970)
@@ -28,7 +28,7 @@
import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
import org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter;
-import org.jboss.remoting.util.SystemUtility;
+import org.jboss.remoting.util.SecurityUtility;
/**
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
@@ -38,7 +38,7 @@
public void startTestSuite(final JUnitTest test)
{
- String configuration = SystemUtility.getSystemProperty("jboss-junit-configuration");
+ String configuration = SecurityUtility.getSystemProperty("jboss-junit-configuration");
// if sys prop is not null, empty, or contain default variable alias
if(configuration != null && !configuration.trim().equals("") &&
17 years, 7 months
JBoss Remoting SVN: r3969 - remoting2/branches/2.x/src/main/org/jboss/remoting/util.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:46:27 -0400 (Fri, 11 Apr 2008)
New Revision: 3969
Added:
remoting2/branches/2.x/src/main/org/jboss/remoting/util/SecurityUtility.java
Removed:
remoting2/branches/2.x/src/main/org/jboss/remoting/util/SystemUtility.java
Log:
JBREM-934: (1) Added many methods; (2) renamed SystemUtility SecurityUtility.
Copied: remoting2/branches/2.x/src/main/org/jboss/remoting/util/SecurityUtility.java (from rev 3905, remoting2/branches/2.x/src/main/org/jboss/remoting/util/SystemUtility.java)
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/util/SecurityUtility.java (rev 0)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/util/SecurityUtility.java 2008-04-12 01:46:27 UTC (rev 3969)
@@ -0,0 +1,1117 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.remoting.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.UnknownHostException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+
+import org.jboss.remoting.Remoting;
+import org.jboss.remoting.security.ServerSocketFactoryMBean;
+
+/**
+ * SecurityUtility provides a central point for making security sensitive calls.
+ *
+ * It is divided into five sections:
+ *
+ * 1. calls requiring FilePermissions
+ * 2. calls requiring MBeanPermissions
+ * 3. calls requiring PropertyPermissions
+ * 4. calls requiring RuntimePermissions
+ * 5. calls requiring SocketPermissions
+ *
+ * When the SecurityUtility class is loaded, it checks for two conditions:
+ *
+ * 1. there is no security manager
+ * 2. the system property Remoting.SKIP_ACCESS_CONTROL ("skipAccessControl") is
+ * set to true.
+ *
+ * If either condition is true, then every method in SecurityUtility will
+ * bypass its call to AccessController.doPrivileged().
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Mar 31, 2008
+ * </p>
+ */
+public class SecurityUtility
+{
+ static boolean skipAccessControl;
+
+ static
+ {
+ try
+ {
+ skipAccessControl = ((Boolean)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ boolean b1 = System.getSecurityManager() == null;
+ boolean b2 = Boolean.getBoolean(Remoting.SKIP_ACCESS_CONTROL);
+ return new Boolean(b1 || b2);
+ }
+ })).booleanValue();
+ }
+ catch (PrivilegedActionException e)
+ {
+ e.getCause().printStackTrace();
+ }
+ }
+
+
+ static public boolean skipAccessControl()
+ {
+ return skipAccessControl;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////
+ // FilePermission methods
+ ///////////////////////////////////////////////////////////////////////////////////////
+
+ static public boolean fileExists(final File file)
+ {
+ if (skipAccessControl)
+ {
+ return file.exists();
+ }
+
+ return ((Boolean)AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return new Boolean(file.exists());
+ }
+ })).booleanValue();
+ }
+
+
+ static public boolean mkdirs(final File dir)
+ {
+ if (skipAccessControl)
+ {
+ return dir.mkdirs();
+ }
+
+ return ((Boolean) AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return new Boolean(dir.mkdirs());
+ }
+ })).booleanValue();
+ }
+
+
+ static public FileInputStream getFileInputStream(final File file) throws FileNotFoundException
+ {
+ if (skipAccessControl)
+ {
+ return new FileInputStream(file);
+ }
+
+ try
+ {
+ return (FileInputStream)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws FileNotFoundException
+ {
+ return new FileInputStream(file);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (FileNotFoundException) e.getCause();
+ }
+ }
+
+
+ static public FileInputStream getFileInputStream(final String path) throws FileNotFoundException
+ {
+ if (skipAccessControl)
+ {
+ return new FileInputStream(path);
+ }
+
+ try
+ {
+ return (FileInputStream)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws FileNotFoundException
+ {
+ return new FileInputStream(path);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (FileNotFoundException) e.getCause();
+ }
+ }
+
+
+ static public FileOutputStream getFileOutputStream(final File file)
+ throws FileNotFoundException
+ {
+ if (skipAccessControl)
+ {
+ return new FileOutputStream(file);
+ }
+
+ try
+ {
+ return (FileOutputStream)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws FileNotFoundException
+ {
+ return new FileOutputStream(file);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (FileNotFoundException) e.getCause();
+ }
+ }
+
+
+ static public FileOutputStream getFileOutputStream(final File file, final boolean append)
+ throws FileNotFoundException
+ {
+ if (skipAccessControl)
+ {
+ return new FileOutputStream(file, append);
+ }
+
+ try
+ {
+ return (FileOutputStream)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws FileNotFoundException
+ {
+ return new FileOutputStream(file, append);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (FileNotFoundException) e.getCause();
+ }
+ }
+
+
+ static public boolean canRead(final File file)
+ {
+ if (skipAccessControl)
+ {
+ return file.canRead();
+ }
+
+ return ((Boolean)AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return new Boolean(file.canRead());
+ }
+ })).booleanValue();
+ }
+
+
+ static public boolean createNewFile(final File file) throws IOException
+ {
+ if (skipAccessControl)
+ {
+ return file.createNewFile();
+ }
+
+ try
+ {
+ return ((Boolean)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return new Boolean(file.createNewFile());
+ }
+ })).booleanValue();
+ }
+ catch (Exception e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////////////////
+ // MBeanPermission methods
+ ///////////////////////////////////////////////////////////////////////////////////////
+
+ static public void connect(final Socket socket, final InetSocketAddress address)
+ throws IOException
+ {
+ if (skipAccessControl)
+ {
+ socket.connect(address);
+ return;
+ }
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ socket.connect(address);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public void connect(final Socket socket, final InetSocketAddress address, final int timeout)
+ throws IOException
+ {
+ if (skipAccessControl)
+ {
+ socket.connect(address, timeout);
+ return;
+ }
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ socket.connect(address, timeout);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public MBeanServer createMBeanServer() throws Exception
+ {
+ if (skipAccessControl)
+ {
+ return MBeanServerFactory.createMBeanServer();
+ }
+
+ try
+ {
+ return (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return MBeanServerFactory.createMBeanServer();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+ }
+
+
+ static public boolean isInstanceOf(final MBeanServer server, final ObjectName objectName, final String className)
+ throws InstanceNotFoundException
+ {
+ if (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();
+ }
+ }
+
+
+ static public Object getMBeanAttribute(final MBeanServer server, final ObjectName objectName, final String attribute)
+ throws Exception
+ {
+ if (skipAccessControl)
+ {
+ return server.getAttribute(objectName, attribute);
+ }
+
+ try
+ {
+ return AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return server.getAttribute(objectName, attribute);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+ }
+
+
+ static public void registerMBean(final MBeanServer server, final Object o, final ObjectName name)
+ throws Exception
+ {
+ if (skipAccessControl)
+ {
+ server.registerMBean(o, name);
+ return;
+ }
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ server.registerMBean(o, name);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+ }
+
+
+ static public void unregisterMBean(final MBeanServer server, final ObjectName name)
+ throws Exception
+ {
+ if (skipAccessControl)
+ {
+ server.unregisterMBean(name);
+ return;
+ }
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ server.unregisterMBean(name);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////////////////
+ // PropertyPermission methods
+ ///////////////////////////////////////////////////////////////////////////////////////
+
+ static public String getSystemProperty(final String name, final String defaultValue)
+ {
+ if (skipAccessControl)
+ return System.getProperty(name, defaultValue);
+
+ String value = null;
+ try
+ {
+ value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return System.getProperty(name, defaultValue);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (RuntimeException) e.getCause();
+ }
+
+ return value;
+ }
+
+
+ static public String getSystemProperty(final String name)
+ {
+ if (skipAccessControl)
+ return System.getProperty(name);
+
+ String value = null;
+ try
+ {
+ value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return System.getProperty(name);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (RuntimeException) e.getCause();
+ }
+
+ return value;
+ }
+
+
+ static public void setSystemProperty(final String name, final String value)
+ {
+ if (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();
+ }
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////////////////
+ // RuntimePermission methods
+ ///////////////////////////////////////////////////////////////////////////////////////
+
+ static public Object forName(final String className) throws ClassNotFoundException
+ {
+ if (skipAccessControl)
+ {
+ return Class.forName(className);
+ }
+
+ try
+ {
+ return AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return Class.forName(className);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (ClassNotFoundException) e.getCause();
+ }
+ }
+
+
+ static public ClassLoader getClassLoader(final Class c)
+ {
+ if (skipAccessControl)
+ {
+ return c.getClassLoader();
+ }
+
+ return (ClassLoader)AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return c.getClassLoader();
+ }
+ });
+ }
+
+
+ static public ClassLoader getSystemClassLoader()
+ {
+ if (skipAccessControl)
+ {
+ return ClassLoader.getSystemClassLoader();
+ }
+
+ return (ClassLoader)AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return ClassLoader.getSystemClassLoader();
+ }
+ });
+ }
+
+
+ static public Method getMethod(final Class c, final String name, final Class[] parameterTypes)
+ throws NoSuchMethodException
+ {
+ if (skipAccessControl)
+ {
+ return c.getMethod(name, parameterTypes);
+ }
+
+ try
+ {
+ return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws NoSuchMethodException
+ {
+ return c.getMethod(name, parameterTypes);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (NoSuchMethodException) e.getCause();
+ }
+ }
+
+
+ static public Method getDeclaredMethod(final Class c, final String name, final Class[] parameterTypes)
+ throws NoSuchMethodException
+ {
+ if (skipAccessControl)
+ {
+ return c.getDeclaredMethod(name, parameterTypes);
+ }
+
+ try
+ {
+ return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws NoSuchMethodException
+ {
+ return c.getDeclaredMethod(name, parameterTypes);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (NoSuchMethodException) e.getCause();
+ }
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////////////////
+ // SocketPermission methods
+ ///////////////////////////////////////////////////////////////////////////////////////
+
+ static public Socket accept(final ServerSocket ss) throws IOException
+ {
+ if (skipAccessControl)
+ {
+ return ss.accept();
+ }
+
+ try
+ {
+ return (Socket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return ss.accept();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public void bind(final ServerSocket ss, final SocketAddress address)
+ throws IOException
+ {
+ if (skipAccessControl)
+ {
+ ss.bind(address);
+ return;
+ }
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ ss.bind(address);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public void bind(final ServerSocket ss, final SocketAddress address,
+ final int backlog) throws IOException
+ {
+ if (skipAccessControl)
+ {
+ ss.bind(address, backlog);
+ return;
+ }
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ ss.bind(address, backlog);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
+ final int port) throws IOException
+ {
+ if (skipAccessControl)
+ {
+ return ssf.createServerSocket(port);
+ }
+
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return ssf.createServerSocket(port);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
+ final int port, final int backlog)
+ throws IOException
+ {
+ if (skipAccessControl)
+ {
+ return ssf.createServerSocket(port, backlog);
+ }
+
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return ssf.createServerSocket(port, backlog);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
+ final int port, final int backlog,
+ final InetAddress inetAddress)
+ throws IOException
+ {
+ if (skipAccessControl)
+ {
+ return ssf.createServerSocket(port, backlog, inetAddress);
+ }
+
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return ssf.createServerSocket(port, backlog, inetAddress);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public ServerSocket createServerSocket(final ServerSocketFactory ssf,
+ final int port) throws IOException
+ {
+ if (skipAccessControl)
+ {
+ return ssf.createServerSocket(port);
+ }
+
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return ssf.createServerSocket(port);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public ServerSocket createServerSocket(final ServerSocketFactory ssf,
+ final int port, final int backlog)
+ throws IOException
+ {
+ if (skipAccessControl)
+ {
+ return ssf.createServerSocket(port, backlog);
+ }
+
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return ssf.createServerSocket(port, backlog);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public ServerSocket createServerSocket(final ServerSocketFactory ssf,
+ final int port, final int backlog,
+ final InetAddress inetAddress)
+ throws IOException
+ {
+ if (skipAccessControl)
+ {
+ return ssf.createServerSocket(port, backlog, inetAddress);
+ }
+
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return ssf.createServerSocket(port, backlog, inetAddress);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public ServerSocket createServerSocket(final int port) throws IOException
+ {
+ if (skipAccessControl)
+ {
+ return new ServerSocket(port);
+ }
+
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return new ServerSocket(port);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public ServerSocket createServerSocket(final int port, final int backlog)
+ throws IOException
+ {
+ if (skipAccessControl)
+ {
+ return new ServerSocket(port, backlog);
+ }
+
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return new ServerSocket(port, backlog);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public ServerSocket createServerSocket(final int port, final int backlog,
+ final InetAddress inetAddress)
+ throws IOException
+ {
+ if (skipAccessControl)
+ {
+ return new ServerSocket(port, backlog, inetAddress);
+ }
+
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return new ServerSocket(port, backlog, inetAddress);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public Socket createSocket(final String host, final int port) throws IOException
+ {
+ if (skipAccessControl)
+ {
+ return new Socket(host, port);
+ }
+
+ try
+ {
+ return (Socket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return new Socket(host, port);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public Socket createSocket(final SocketFactory sf, final String host, final int port)
+ throws IOException
+ {
+ if (skipAccessControl)
+ {
+ return sf.createSocket(host, port);
+ }
+
+ try
+ {
+ return (Socket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return sf.createSocket(host, port);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+
+ static public InetAddress getLocalHost() throws UnknownHostException
+ {
+ if (skipAccessControl)
+ {
+ try
+ {
+ return InetAddress.getLocalHost();
+ }
+ catch (IOException e)
+ {
+ return InetAddress.getByName("127.0.0.1");
+ }
+ }
+
+ try
+ {
+ return (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 (UnknownHostException) e.getCause();
+ }
+ }
+
+
+ static public String getLocalHostName() throws UnknownHostException
+ {
+ if (skipAccessControl)
+ {
+ return getLocalHost().getHostName();
+ }
+
+ try
+ {
+ return (String) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws IOException
+ {
+ InetAddress address = null;
+ try
+ {
+ address = InetAddress.getLocalHost();
+ }
+ catch (IOException e)
+ {
+ address = InetAddress.getByName("127.0.0.1");
+ }
+
+ return address.getHostName();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (UnknownHostException) e.getCause();
+ }
+ }
+
+
+ static public InetAddress getAddressByName(final String host) throws UnknownHostException
+ {
+ if (skipAccessControl)
+ {
+ return InetAddress.getByName(host);
+ }
+
+ try
+ {
+ return (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws IOException
+ {
+ return InetAddress.getByName(host);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (UnknownHostException) e.getCause();
+ }
+ }
+}
\ No newline at end of file
Deleted: remoting2/branches/2.x/src/main/org/jboss/remoting/util/SystemUtility.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/util/SystemUtility.java 2008-04-12 01:45:57 UTC (rev 3968)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/util/SystemUtility.java 2008-04-12 01:46:27 UTC (rev 3969)
@@ -1,109 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.remoting.util;
-
-import java.io.File;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Mar 31, 2008
- * </p>
- */
-public class SystemUtility
-{
- static public String getSystemProperty(final String name, final String defaultValue)
- {
- String value = null;
- try
- {
- value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return System.getProperty(name, defaultValue);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (RuntimeException) e.getCause();
- }
-
- return value;
- }
-
- static public String getSystemProperty(final String name)
- {
- String value = null;
- try
- {
- value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return System.getProperty(name);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (RuntimeException) e.getCause();
- }
-
- return value;
- }
-
- static public void setSystemProperty(final String name, final String value)
- {
- try
- {
- AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return System.setProperty(name, value);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (RuntimeException) e.getCause();
- }
- }
-
- static public boolean mkdirs(final File dir)
- {
- return ((Boolean) AccessController.doPrivileged( new PrivilegedAction()
- {
- public Object run()
- {
- return new Boolean(dir.mkdirs());
- }
- })).booleanValue();
- }
-}
\ No newline at end of file
17 years, 7 months
JBoss Remoting SVN: r3968 - remoting2/branches/2.x/src/main/org/jboss/remoting/transporter.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:45:57 -0400 (Fri, 11 Apr 2008)
New Revision: 3968
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterServer.java
Log:
JBREM-934: Replaced AccessController.doPrivileged() call with SecurityUtility.createMBeanServer() call.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterServer.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterServer.java 2008-04-12 01:45:35 UTC (rev 3967)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transporter/TransporterServer.java 2008-04-12 01:45:57 UTC (rev 3968)
@@ -26,6 +26,7 @@
import org.jboss.remoting.ServerInvocationHandler;
import org.jboss.remoting.detection.multicast.MulticastDetector;
import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.util.SecurityUtility;
import org.w3c.dom.Element;
import javax.management.MBeanServer;
@@ -220,21 +221,7 @@
if (!services.isSetup())
{
// we need an MBeanServer to store our network registry and multicast detector services
- 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();
- }
+ MBeanServer server = SecurityUtility.createMBeanServer();
// multicast detector will detect new network registries that come online
MulticastDetector detector = new MulticastDetector();
17 years, 7 months