JBoss Remoting SVN: r5015 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/ssl.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:20:18 -0400 (Tue, 14 Apr 2009)
New Revision: 5015
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/ssl/RemotingServerSocketFactory.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/ssl/RemotingServerSocketFactory.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/ssl/RemotingServerSocketFactory.java 2009-04-14 10:19:59 UTC (rev 5014)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/ssl/RemotingServerSocketFactory.java 2009-04-14 10:20:18 UTC (rev 5015)
@@ -36,6 +36,9 @@
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import java.util.Map;
@@ -183,7 +186,7 @@
*/
public Socket acceptSocket(ServerSocket serverSocket) throws IOException
{
- return SecurityUtility.accept(serverSocket);
+ return accept(serverSocket);
}
/**
@@ -204,4 +207,27 @@
{
serverSocketFactories.put(locatorURI, svrSocketFactory);
}
+
+ static private Socket accept(final ServerSocket ss) throws IOException
+ {
+ if (SecurityUtility.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();
+ }
+ }
}
\ No newline at end of file
15 years, 10 months
JBoss Remoting SVN: r5014 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:19:59 -0400 (Tue, 14 Apr 2009)
New Revision: 5014
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java 2009-04-14 10:19:39 UTC (rev 5013)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java 2009-04-14 10:19:59 UTC (rev 5014)
@@ -163,7 +163,7 @@
Class clazz = null;
try
{
- clazz = (Class) SecurityUtility.forName(protocolHandlerClassName);
+ clazz = (Class) forName(protocolHandlerClassName);
}
catch (ClassNotFoundException e)
{
@@ -363,7 +363,7 @@
if (remoteAddressMB != null)
{
String remoteAddressString = remoteAddressMB.toString();
- InetAddress remoteAddress = SecurityUtility.getAddressByName(remoteAddressString);
+ InetAddress remoteAddress = getAddressByName(remoteAddressString);
invocationRequest.getRequestPayload().put(Remoting.CLIENT_ADDRESS, remoteAddress);
}
else
@@ -1079,7 +1079,7 @@
{
try
{
- params[0] = SecurityUtility.getAddressByName(value);
+ params[0] = getAddressByName(value);
}
catch(UnknownHostException exc)
{
@@ -1144,5 +1144,50 @@
{
return true;
}
-
+
+ static private Object forName(final String className) throws ClassNotFoundException
+ {
+ if (SecurityUtility.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 private InetAddress getAddressByName(final String host) throws UnknownHostException
+ {
+ if (SecurityUtility.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();
+ }
+ }
}
15 years, 10 months
JBoss Remoting SVN: r5013 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:19:39 -0400 (Tue, 14 Apr 2009)
New Revision: 5013
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java 2009-04-14 10:19:06 UTC (rev 5012)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java 2009-04-14 10:19:39 UTC (rev 5013)
@@ -26,6 +26,9 @@
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.Socket;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -630,7 +633,7 @@
try
{
- Method purge = SecurityUtility.getDeclaredMethod(Timer.class, "purge", new Class[]{});
+ Method purge = getDeclaredMethod(Timer.class, "purge", new Class[]{});
purge.invoke(timer, new Object[]{});
}
catch (Exception e)
@@ -685,4 +688,32 @@
this.flag = flag;
}
}
+
+ static private Method getDeclaredMethod(final Class c, final String name, final Class[] parameterTypes)
+ throws NoSuchMethodException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ Method m = c.getDeclaredMethod(name, parameterTypes);
+ m.setAccessible(true);
+ return m;
+ }
+
+ try
+ {
+ return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws NoSuchMethodException
+ {
+ Method m = c.getDeclaredMethod(name, parameterTypes);
+ m.setAccessible(true);
+ return m;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (NoSuchMethodException) e.getCause();
+ }
+ }
}
\ No newline at end of file
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2009-04-14 10:19:06 UTC (rev 5012)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2009-04-14 10:19:39 UTC (rev 5013)
@@ -1205,7 +1205,7 @@
try
{
- Method purge = SecurityUtility.getDeclaredMethod(Timer.class, "purge", new Class[]{});
+ Method purge = getDeclaredMethod(Timer.class, "purge", new Class[]{});
purge.invoke(timer, new Object[]{});
}
catch (Exception e)
@@ -1308,4 +1308,32 @@
{
private static final long serialVersionUID = 2846502029152028732L;
}
+
+ static private Method getDeclaredMethod(final Class c, final String name, final Class[] parameterTypes)
+ throws NoSuchMethodException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ Method m = c.getDeclaredMethod(name, parameterTypes);
+ m.setAccessible(true);
+ return m;
+ }
+
+ try
+ {
+ return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws NoSuchMethodException
+ {
+ Method m = c.getDeclaredMethod(name, parameterTypes);
+ m.setAccessible(true);
+ return m;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (NoSuchMethodException) e.getCause();
+ }
+ }
}
\ No newline at end of file
15 years, 10 months
JBoss Remoting SVN: r5012 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:19:06 -0400 (Tue, 14 Apr 2009)
New Revision: 5012
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/AddressUtil.java
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/AddressUtil.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/AddressUtil.java 2009-04-14 10:18:34 UTC (rev 5011)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/AddressUtil.java 2009-04-14 10:19:06 UTC (rev 5012)
@@ -22,9 +22,11 @@
*/
package org.jboss.remoting.transport;
+import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.UnknownHostException;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
@@ -58,7 +60,7 @@
{
log.trace("checking host: " + host);
int port = PortUtil.findFreePort(host);
- InetAddress addr = SecurityUtility.getAddressByName(host);
+ InetAddress addr = getAddressByName(host);
ServerTestThread t1 = new ServerTestThread(addr, port);
t1.setDaemon(true);
t1.start();
@@ -137,5 +139,28 @@
}
}
}
+
+ static private InetAddress getAddressByName(final String host) throws UnknownHostException
+ {
+ if (SecurityUtility.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();
+ }
+ }
}
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java 2009-04-14 10:18:34 UTC (rev 5011)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java 2009-04-14 10:19:06 UTC (rev 5012)
@@ -47,6 +47,10 @@
import javax.management.ObjectName;
import javax.net.ServerSocketFactory;
import javax.net.SocketFactory;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
@@ -601,7 +605,7 @@
String clientConnectPort = (String) invokerConfig.get("clientConnectPort");
String serverBindAddress = (String) invokerConfig.get("serverBindAddress");
String serverBindPort = (String) invokerConfig.get("serverBindPort");
- String localHostAddress = SecurityUtility.getLocalHost().getHostAddress();
+ String localHostAddress = getLocalHost().getHostAddress();
String tempURI = null;
String path = (String) invokerConfig.get("path");
@@ -801,7 +805,7 @@
boolean parametersStarted = false;
if (connectHomes == null && homes == null)
{
- String localHostAddress = SecurityUtility.getLocalHost().getHostAddress();
+ String localHostAddress = getLocalHost().getHostAddress();
// A single home configuration.
String host = clientConnectAddress != null
@@ -1100,7 +1104,7 @@
try
{
ObjectName objName = new ObjectName(invoker.getMBeanObjectName());
- SecurityUtility.unregisterMBean(server, objName);
+ unregisterMBean(server, objName);
}
catch (Exception e)
{
@@ -1450,4 +1454,67 @@
}
this.remoteClassLoaders = classLoaders;
}
+
+ static private void unregisterMBean(final MBeanServer server, final ObjectName name)
+ throws Exception
+ {
+ if (SecurityUtility.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();
+ }
+ }
+
+ static private InetAddress getLocalHost() throws UnknownHostException
+ {
+ if (SecurityUtility.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();
+ }
+ }
}
15 years, 10 months
JBoss Remoting SVN: r5011 - remoting2/branches/2.x/src/main/org/jboss/remoting/stream.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:18:34 -0400 (Tue, 14 Apr 2009)
New Revision: 5011
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/stream/StreamServer.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/stream/StreamServer.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/stream/StreamServer.java 2009-04-14 10:18:15 UTC (rev 5010)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/stream/StreamServer.java 2009-04-14 10:18:34 UTC (rev 5011)
@@ -117,16 +117,16 @@
private String getLocatorURI() throws IOException
{
// check for system properties for locator values
- transport = SecurityUtility.getSystemProperty(STREAM_TRANSPORT_KEY, transport);
+ transport = getSystemProperty(STREAM_TRANSPORT_KEY, transport);
try
{
- host = SecurityUtility.getLocalHostName();
+ host = getLocalHostName();
}
catch(UnknownHostException e)
{
try
{
- InetAddress localAddress = SecurityUtility.getLocalHost();
+ InetAddress localAddress = getLocalHost();
host = localAddress.getHostAddress();
}
catch(UnknownHostException e1)
@@ -135,9 +135,9 @@
}
}
- host = SecurityUtility.getSystemProperty(STREAM_HOST_KEY, host);
+ host = getSystemProperty(STREAM_HOST_KEY, host);
String defaultPort = "" + PortUtil.findFreePort(host);
- String sPort = SecurityUtility.getSystemProperty(STREAM_PORT_KEY, defaultPort);
+ String sPort = getSystemProperty(STREAM_PORT_KEY, defaultPort);
try
{
@@ -314,4 +314,97 @@
}
}
+ static private String getSystemProperty(final String name, final String defaultValue)
+ {
+ if (SecurityUtility.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 private InetAddress getLocalHost() throws UnknownHostException
+ {
+ if (SecurityUtility.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 private String getLocalHostName() throws UnknownHostException
+ {
+ if (SecurityUtility.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();
+ }
+ }
}
\ No newline at end of file
15 years, 10 months
JBoss Remoting SVN: r5010 - remoting2/branches/2.x/src/main/org/jboss/remoting/socketfactory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:18:15 -0400 (Tue, 14 Apr 2009)
New Revision: 5010
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/socketfactory/CreationListenerServerSocket.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/socketfactory/CreationListenerServerSocket.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/socketfactory/CreationListenerServerSocket.java 2009-04-14 10:17:57 UTC (rev 5009)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/socketfactory/CreationListenerServerSocket.java 2009-04-14 10:18:15 UTC (rev 5010)
@@ -94,13 +94,13 @@
public void bind(SocketAddress endpoint) throws IOException
{
- SecurityUtility.bind(serverSocket, endpoint);
+ bind(serverSocket, endpoint);
}
public void bind(SocketAddress endpoint, int backlog) throws IOException
{
- SecurityUtility.bind(serverSocket, endpoint, backlog);
+ bind(serverSocket, endpoint, backlog);
}
@@ -223,4 +223,56 @@
{
return serverSocket.toString();
}
+
+ static private void bind(final ServerSocket ss, final SocketAddress address)
+ throws IOException
+ {
+ if (SecurityUtility.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 private void bind(final ServerSocket ss, final SocketAddress address,
+ final int backlog) throws IOException
+ {
+ if (SecurityUtility.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();
+ }
+ }
}
15 years, 10 months
JBoss Remoting SVN: r5009 - remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/java.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:17:57 -0400 (Tue, 14 Apr 2009)
New Revision: 5009
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/java/ClearableObjectOutputStream.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/java/ClearableObjectOutputStream.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/java/ClearableObjectOutputStream.java 2009-04-14 10:17:38 UTC (rev 5008)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/java/ClearableObjectOutputStream.java 2009-04-14 10:17:57 UTC (rev 5009)
@@ -26,6 +26,9 @@
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import org.jboss.logging.Logger;
import org.jboss.remoting.util.SecurityUtility;
@@ -47,7 +50,7 @@
{
try
{
- clearMethod = SecurityUtility.getDeclaredMethod(ObjectOutputStream.class, "clear", new Class[]{});
+ clearMethod = getDeclaredMethod(ObjectOutputStream.class, "clear", new Class[]{});
}
catch (SecurityException e)
{
@@ -75,5 +78,33 @@
log.error(e.getMessage(), e);
}
}
+
+ static private Method getDeclaredMethod(final Class c, final String name, final Class[] parameterTypes)
+ throws NoSuchMethodException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ Method m = c.getDeclaredMethod(name, parameterTypes);
+ m.setAccessible(true);
+ return m;
+ }
+
+ try
+ {
+ return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws NoSuchMethodException
+ {
+ Method m = c.getDeclaredMethod(name, parameterTypes);
+ m.setAccessible(true);
+ return m;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (NoSuchMethodException) e.getCause();
+ }
+ }
}
15 years, 10 months
JBoss Remoting SVN: r5008 - remoting2/branches/2.x/src/main/org/jboss/remoting/serialization.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:17:38 -0400 (Tue, 14 Apr 2009)
New Revision: 5008
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/SerializationStreamFactory.java
Log:
JBREM-1116: Eliminated dependence on 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 2009-04-14 10:17:17 UTC (rev 5007)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/SerializationStreamFactory.java 2009-04-14 10:17:38 UTC (rev 5008)
@@ -30,6 +30,7 @@
import java.io.IOException;
import java.security.AccessController;
+import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import java.util.Map;
@@ -60,7 +61,7 @@
try
{
String defaultValue = JavaSerializationManager.class.getName();
- String managerClassName = SecurityUtility.getSystemProperty("SERIALIZATION", defaultValue);
+ String managerClassName = getSystemProperty("SERIALIZATION", defaultValue);
setManagerClassName(DEFAULT, managerClassName);
}
catch(Exception e)
@@ -196,4 +197,27 @@
return getManagerInstance(DEFAULT);
}
+ static private String getSystemProperty(final String name, final String defaultValue)
+ {
+ if (SecurityUtility.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;
+ }
}
\ No newline at end of file
15 years, 10 months
JBoss Remoting SVN: r5007 - remoting2/branches/2.x/src/main/org/jboss/remoting/security.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:17:17 -0400 (Tue, 14 Apr 2009)
New Revision: 5007
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/security/SSLSocketBuilder.java
remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java
Log:
JBREM-1116: Eliminated dependence on 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 2009-04-14 10:16:38 UTC (rev 5006)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/security/SSLSocketBuilder.java 2009-04-14 10:17:17 UTC (rev 5007)
@@ -396,14 +396,14 @@
if (getUseSSLSocketFactory())
{
- String defaultFactoryName = SecurityUtility.getSystemProperty(REMOTING_DEFAULT_SOCKET_FACTORY_CLASS);
+ String defaultFactoryName = getSystemProperty(REMOTING_DEFAULT_SOCKET_FACTORY_CLASS);
if (defaultFactoryName != null)
{
try
{
final Class sfClass = ClassLoaderUtility.loadClass(defaultFactoryName, SSLSocketBuilder.class);
- Method m = SecurityUtility.getMethod(sfClass, "getDefault", null);
+ Method m = getMethod(sfClass, "getDefault", null);
if (m == null)
{
@@ -616,7 +616,7 @@
if(keyStoreFilePath == null)
{
- String path = SecurityUtility.getSystemProperty(STANDARD_KEY_STORE_FILE_PATH);;
+ String path = getSystemProperty(STANDARD_KEY_STORE_FILE_PATH);;
if(path != null && path.length() > 0)
{
setKeyStoreURL( path );
@@ -670,7 +670,7 @@
if(keyStoreType == null)
{
- keyStoreType = SecurityUtility.getSystemProperty(STANDARD_KEY_STORE_TYPE);
+ keyStoreType = getSystemProperty(STANDARD_KEY_STORE_TYPE);
if(keyStoreType == null)
{
keyStoreType = DEFAULT_KEY_STORE_TYPE;
@@ -746,7 +746,7 @@
if(keyStorePassword == null)
{
- keyStorePassword = SecurityUtility.getSystemProperty(STANDARD_KEY_STORE_PASSWORD);
+ keyStorePassword = getSystemProperty(STANDARD_KEY_STORE_PASSWORD);
}
return keyStorePassword;
@@ -797,7 +797,7 @@
if(trustStoreFilePath == null)
{
- String path = SecurityUtility.getSystemProperty(STANDARD_TRUST_STORE_FILE_PATH);
+ String path = getSystemProperty(STANDARD_TRUST_STORE_FILE_PATH);
if(path != null && path.length() > 0)
{
setTrustStoreURL( path );
@@ -851,7 +851,7 @@
if(trustStoreType == null)
{
- trustStoreType = SecurityUtility.getSystemProperty(STANDARD_TRUST_STORE_TYPE);
+ trustStoreType = getSystemProperty(STANDARD_TRUST_STORE_TYPE);
if(trustStoreType == null)
{
trustStoreType = getKeyStoreType();
@@ -927,7 +927,7 @@
if(trustStorePassword == null)
{
- trustStorePassword = SecurityUtility.getSystemProperty(STANDARD_TRUST_STORE_PASSWORD);
+ trustStorePassword = getSystemProperty(STANDARD_TRUST_STORE_PASSWORD);
if(trustStorePassword == null)
{
trustStorePassword = getKeyStorePassword();
@@ -1716,4 +1716,52 @@
super(message);
}
}
+
+ static private String getSystemProperty(final String name)
+ {
+ if (SecurityUtility.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 private Method getMethod(final Class c, final String name, final Class[] parameterTypes)
+ throws NoSuchMethodException
+ {
+ if (SecurityUtility.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();
+ }
+ }
}
\ No newline at end of file
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 2009-04-14 10:16:38 UTC (rev 5006)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java 2009-04-14 10:17:17 UTC (rev 5007)
@@ -24,6 +24,9 @@
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import javax.net.ServerSocketFactory;
@@ -43,27 +46,124 @@
public ServerSocket createServerSocket(final int i) throws IOException
{
- return SecurityUtility.createServerSocket(serverSocketFactory, i);
+ return createServerSocket(serverSocketFactory, i);
}
public ServerSocket createServerSocket(final int i, final int i1) throws IOException
{
- return SecurityUtility.createServerSocket(serverSocketFactory, i, i1);
+ return createServerSocket(serverSocketFactory, i, i1);
}
public ServerSocket createServerSocket(final int i, final int i1, final InetAddress inetAddress) throws IOException
{
- return SecurityUtility.createServerSocket(serverSocketFactory, i, i1, inetAddress);
+ return createServerSocket(serverSocketFactory, i, i1, inetAddress);
}
public ServerSocket createServerSocket() throws IOException
{
- return SecurityUtility.createServerSocket(serverSocketFactory);
+ return createServerSocket(serverSocketFactory);
}
public ServerSocketFactoryMBean getDelegate()
{
return serverSocketFactory;
}
+
+ static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf) throws IOException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return ssf.createServerSocket();
+ }
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws IOException
+ {
+ return ssf.createServerSocket();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+ static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
+ final int port) throws IOException
+ {
+ if (SecurityUtility.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 private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
+ final int port, final int backlog)
+ throws IOException
+ {
+ if (SecurityUtility.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 private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
+ final int port, final int backlog,
+ final InetAddress inetAddress)
+ throws IOException
+ {
+ if (SecurityUtility.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();
+ }
+ }
}
\ No newline at end of file
15 years, 10 months
JBoss Remoting SVN: r5006 - remoting2/branches/2.x/src/main/org/jboss/remoting/samples/transporter/custom/server.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:16:38 -0400 (Tue, 14 Apr 2009)
New Revision: 5006
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/samples/transporter/custom/server/JNDIServer.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/samples/transporter/custom/server/JNDIServer.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/samples/transporter/custom/server/JNDIServer.java 2009-04-14 10:16:19 UTC (rev 5005)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/samples/transporter/custom/server/JNDIServer.java 2009-04-14 10:16:38 UTC (rev 5006)
@@ -27,6 +27,9 @@
import java.lang.reflect.Method;
import java.net.InetAddress;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
/**
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
@@ -46,7 +49,7 @@
namingBeanImplClass = Class.forName("org.jnp.server.NamingBeanImpl");
namingBean = namingBeanImplClass.newInstance();
Method startMethod = namingBeanImplClass.getMethod("start", new Class[] {});
- SecurityUtility.setSystemProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
+ setSystemProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
startMethod.invoke(namingBean, new Object[] {});
}
catch (Exception e)
@@ -81,4 +84,28 @@
}
}
+
+ static private void setSystemProperty(final String name, final String value)
+ {
+ if (SecurityUtility.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();
+ }
+ }
}
\ No newline at end of file
15 years, 10 months