JBoss Remoting SVN: r3957 - 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 21:25:44 -0400 (Fri, 11 Apr 2008)
New Revision: 3957
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi/RemotingRMIClientSocketFactory.java
Log:
JBREM-934: Replaced AccessController.doPrivileged() call with SecurityUtility call.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi/RemotingRMIClientSocketFactory.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi/RemotingRMIClientSocketFactory.java 2008-04-12 01:23:22 UTC (rev 3956)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/rmi/RemotingRMIClientSocketFactory.java 2008-04-12 01:25:44 UTC (rev 3957)
@@ -42,6 +42,7 @@
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.Remoting;
import org.jboss.remoting.Version;
+import org.jboss.remoting.util.SecurityUtility;
/**
@@ -197,51 +198,20 @@
log.warn("unable to retrieve socket factory: returning plain socket");
}
- Socket socket = null;
- try
- {
- socket = (Socket)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return new Socket(effectiveHost, port);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (IOException) e.getCause();
- }
- return socket;
+ return SecurityUtility.createSocket(effectiveHost, port);
}
socketFactory = retrieveSocketFactory(holder);
}
Socket socket = null;
-
- try
+ if(socketFactory != null)
{
- socket = (Socket)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- Socket s = null;
- if(socketFactory != null)
- {
- s = socketFactory.createSocket(effectiveHost, port);
- }
- else
- {
- s = new Socket(effectiveHost, port);
- }
- return s;
- }
- });
+ socket = SecurityUtility.createSocket(socketFactory, effectiveHost, port);
}
- catch (PrivilegedActionException e)
+ else
{
- throw (IOException) e.getCause();
+ socket = SecurityUtility.createSocket(effectiveHost, port);
}
socket.setSoTimeout(timeout);
@@ -302,21 +272,8 @@
protocol = invokerLocator.getProtocol().toLowerCase();
try
- {
- try
- {
- host = (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws UnknownHostException
- {
- return InetAddress.getByName(invokerLocator.getHost());
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (UnknownHostException) e.getCause();
- }
+ {
+ host = SecurityUtility.getAddressByName(invokerLocator.getHost());
}
catch (UnknownHostException e)
{
18 years
JBoss Remoting SVN: r3956 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/local.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:23:22 -0400 (Fri, 11 Apr 2008)
New Revision: 3956
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/local/LocalClientInvoker.java
Log:
JBREM-934: Checks SecurityUtility.skipAccessControl().
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/local/LocalClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/local/LocalClientInvoker.java 2008-04-12 01:22:15 UTC (rev 3955)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/local/LocalClientInvoker.java 2008-04-12 01:23:22 UTC (rev 3956)
@@ -34,6 +34,7 @@
import org.jboss.remoting.serialization.SerializationManager;
import org.jboss.remoting.serialization.SerializationStreamFactory;
import org.jboss.remoting.transport.BidirectionalClientInvoker;
+import org.jboss.remoting.util.SecurityUtility;
import org.jboss.logging.Logger;
import java.io.IOException;
@@ -156,7 +157,7 @@
String serializationType = getSerializationType();
final SerializationManager manager = SerializationStreamFactory.getManagerInstance(serializationType);
- if (serializationType.indexOf("jboss") < 0)
+ if (serializationType.indexOf("jboss") < 0 || SecurityUtility.skipAccessControl())
{
newParam = manager.createMarshalledValueForClone(param).get();
}
18 years
JBoss Remoting SVN: r3955 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:22:15 -0400 (Fri, 11 Apr 2008)
New Revision: 3955
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.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/transport/http/HTTPClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java 2008-04-12 01:21:08 UTC (rev 3954)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java 2008-04-12 01:22:15 UTC (rev 3955)
@@ -43,7 +43,7 @@
import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller;
import org.jboss.remoting.serialization.ClassLoaderUtility;
import org.jboss.remoting.transport.web.WebUtil;
-import org.jboss.remoting.util.SystemUtility;
+import org.jboss.remoting.util.SecurityUtility;
import org.jboss.util.Base64;
import org.jboss.util.threadpool.BasicThreadPool;
import org.jboss.util.threadpool.BlockingMode;
@@ -515,23 +515,9 @@
*/
try
{
- Method setChunkedLengthMethod = null;
-
- try
- {
- setChunkedLengthMethod = (Method)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return conn.getClass().getMethod("setChunkedStreamingMode", new Class[]{int.class});
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (Exception) e.getCause();
- }
-
+ Class cl = conn.getClass();
+ Class[] paramTypes = new Class[] {int.class};
+ Method setChunkedLengthMethod = SecurityUtility.getMethod(cl, "setChunkedStreamingMode", paramTypes);
setChunkedLengthMethod.invoke(conn, new Object[]{new Integer(chunkedLength)});
}
catch (NoSuchMethodException e)
@@ -605,37 +591,11 @@
*/
try
{
- Method setTimeoutMethod = null;
- try
- {
- setTimeoutMethod = (Method)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return conn.getClass().getMethod("setConnectTimeout", new Class[]{int.class});
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (Exception) e.getCause();
- }
+ Class cl = conn.getClass();
+ Class[] paramTypes = new Class[] {int.class};
+ Method setTimeoutMethod = SecurityUtility.getMethod(cl, "setConnectTimeout", paramTypes);
setTimeoutMethod.invoke(conn, new Object[]{new Integer(timeout)});
-
- try
- {
- setTimeoutMethod = (Method)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return conn.getClass().getMethod("setReadTimeout", new Class[]{int.class});
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (Exception) e.getCause();
- }
+ setTimeoutMethod = SecurityUtility.getMethod(cl, "setReadTimeout", paramTypes);
setTimeoutMethod.invoke(conn, new Object[]{new Integer(timeout)});
return -1;
}
@@ -775,23 +735,7 @@
}
Constructor proxyConstructor = proxyClass.getConstructor(new Class[] {proxyTypeClass, SocketAddress.class});
Object proxy = proxyConstructor.newInstance(new Object[] {proxyType, proxyAddress});
- Method openConnection = null;
-
- try
- {
- openConnection = (Method)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return URL.class.getMethod("openConnection", new Class[] {proxyClass});
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (Exception) e.getCause();
- }
-
+ Method openConnection = SecurityUtility.getMethod(URL.class, "openConnection", new Class[] {proxyClass});
httpURLConn = (HttpURLConnection)openConnection.invoke(externalURL, new Object[] {proxy});
}
catch (Exception e)
@@ -829,7 +773,7 @@
}
if (username == null || username.length() == 0)
{
- username = SystemUtility.getSystemProperty("http.proxy.username");
+ username = SecurityUtility.getSystemProperty("http.proxy.username");
}
if (metadata != null)
{
@@ -837,7 +781,7 @@
}
if (password == null)
{
- password = SystemUtility.getSystemProperty("http.proxy.password");
+ password = SecurityUtility.getSystemProperty("http.proxy.password");
}
if (username != null && password != null)
@@ -868,7 +812,7 @@
}
if (username == null || username.length() == 0)
{
- username = SystemUtility.getSystemProperty("http.basic.username");
+ username = SecurityUtility.getSystemProperty("http.basic.username");
}
if (metadata != null)
{
@@ -876,7 +820,7 @@
}
if (password == null)
{
- password = SystemUtility.getSystemProperty("http.basic.password");
+ password = SecurityUtility.getSystemProperty("http.basic.password");
}
if (username != null && password != null)
18 years
JBoss Remoting SVN: r3954 - 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: 2008-04-11 21:21:08 -0400 (Fri, 11 Apr 2008)
New Revision: 3954
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/ssl/RemotingServerSocketFactory.java
Log:
JBREM-934: Replaced AccessController.doPrivileged() call with SecurityUtility call.
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 2008-04-12 01:20:29 UTC (rev 3953)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/ssl/RemotingServerSocketFactory.java 2008-04-12 01:21:08 UTC (rev 3954)
@@ -26,6 +26,7 @@
import org.jboss.logging.Logger;
import org.jboss.remoting.security.ServerSocketFactoryMBean;
import org.jboss.remoting.security.ServerSocketFactoryWrapper;
+import org.jboss.remoting.util.SecurityUtility;
import javax.management.MBeanServer;
import javax.management.MBeanServerInvocationHandler;
@@ -183,25 +184,9 @@
*
* @throws java.io.IOException;
*/
- public Socket acceptSocket(final ServerSocket serverSocket) throws IOException
+ public Socket acceptSocket(ServerSocket serverSocket) throws IOException
{
- Socket socket = null;
- try
- {
- socket = (Socket)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return serverSocket.accept();
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (IOException) e.getCause();
- }
-
- return socket;
+ return SecurityUtility.accept(serverSocket);
}
/**
18 years
JBoss Remoting SVN: r3953 - 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: 2008-04-11 21:20:29 -0400 (Fri, 11 Apr 2008)
New Revision: 3953
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/OutputBuffer.java
Log:
JBREM-934: Replaced System.getSecurityManager() with SecurityUtility.skipAccessControl().
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/OutputBuffer.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/OutputBuffer.java 2008-04-12 01:19:44 UTC (rev 3952)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/OutputBuffer.java 2008-04-12 01:20:29 UTC (rev 3953)
@@ -29,6 +29,7 @@
import org.apache.tomcat.util.buf.ByteChunk;
import org.apache.tomcat.util.buf.C2BConverter;
import org.apache.tomcat.util.buf.CharChunk;
+import org.jboss.remoting.util.SecurityUtility;
/**
@@ -640,7 +641,7 @@
if(conv == null)
{
- if(System.getSecurityManager() != null)
+ if(!SecurityUtility.skipAccessControl())
{
try
{
18 years
JBoss Remoting SVN: r3952 - 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: 2008-04-11 21:19:44 -0400 (Fri, 11 Apr 2008)
New Revision: 3952
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java
Log:
JBREM-934: Replaced AccessController.doPrivileged() calls with SecurityUtility calls..
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 2008-04-12 01:18:41 UTC (rev 3951)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java 2008-04-12 01:19:44 UTC (rev 3952)
@@ -45,6 +45,7 @@
import org.jboss.remoting.transport.http.HTTPMetadataConstants;
import org.jboss.remoting.transport.web.WebServerInvoker;
import org.jboss.remoting.transport.web.WebUtil;
+import org.jboss.remoting.util.SecurityUtility;
import org.jboss.logging.Logger;
import javax.net.ServerSocketFactory;
@@ -162,19 +163,11 @@
Class clazz = null;
try
{
- // The class initialization refers to a System property for logging.
- final String finalClassName = protocolHandlerClassName;
- clazz = (Class) AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return Class.forName(finalClassName);
- }
- });
+ clazz = (Class) SecurityUtility.forName(protocolHandlerClassName);
}
- catch (PrivilegedActionException e)
+ catch (ClassNotFoundException e)
{
- log.error("Protocol handler class instatiation failed: protocolHandlerClassName", e.getCause());
+ log.error("Protocol handler class instatiation failed: protocolHandlerClassName", e);
return;
}
@@ -355,22 +348,8 @@
MessageBytes remoteAddressMB = req.remoteAddr();
if (remoteAddressMB != null)
{
- final String remoteAddressString = remoteAddressMB.toString();
- InetAddress remoteAddress = null;
- try
- {
- remoteAddress = (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws UnknownHostException
- {
- return InetAddress.getByName(remoteAddressString);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (UnknownHostException) e.getCause();
- }
+ String remoteAddressString = remoteAddressMB.toString();
+ InetAddress remoteAddress = SecurityUtility.getAddressByName(remoteAddressString);
invocationRequest.getRequestPayload().put(Remoting.CLIENT_ADDRESS, remoteAddress);
}
else
@@ -1061,25 +1040,11 @@
// Try a setFoo ( InetAddress )
}
- else if("java.net.InetAddress".equals(paramType
- .getName()))
+ else if("java.net.InetAddress".equals(paramType.getName()))
{
try
{
- try
- {
- params[0] = AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws UnknownHostException
- {
- return InetAddress.getByName(value);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (UnknownHostException) e.getCause();
- }
+ params[0] = SecurityUtility.getAddressByName(value);
}
catch(UnknownHostException exc)
{
18 years
JBoss Remoting SVN: r3951 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:18:41 -0400 (Fri, 11 Apr 2008)
New Revision: 3951
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java
Log:
JBREM-934: Replaced AccessController.doPrivileged() calls with SecurityUtility calls..
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 2008-04-12 01:14:44 UTC (rev 3950)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java 2008-04-12 01:18:41 UTC (rev 3951)
@@ -32,6 +32,7 @@
import org.jboss.remoting.marshal.MarshalFactory;
import org.jboss.remoting.marshal.MarshallLoaderFactory;
import org.jboss.remoting.serialization.ClassLoaderUtility;
+import org.jboss.remoting.util.SecurityUtility;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -565,22 +566,7 @@
String serverBindPort = (String) invokerConfig.get("serverBindPort");
String path = (String) invokerConfig.get("path");
- String localHostAddress = null;
- try
- {
- localHostAddress = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws UnknownHostException
- {
- return InetAddress.getLocalHost().getHostAddress();
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (UnknownHostException) e.getCause();
- }
-
+ String localHostAddress = SecurityUtility.getLocalHost().getHostAddress();
String host = clientConnectAddress != null ? clientConnectAddress : serverBindAddress != null ? serverBindAddress : localHostAddress;
int port = clientConnectPort != null ? Integer.parseInt(clientConnectPort) : serverBindPort != null ? Integer.parseInt(serverBindPort) : PortUtil.findFreePort(serverBindAddress != null ? serverBindAddress : localHostAddress);
@@ -706,21 +692,7 @@
boolean parametersStarted = false;
if (connectHomes == null && homes == null)
{
- String localHostAddress = null;
- try
- {
- localHostAddress = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws UnknownHostException
- {
- return InetAddress.getLocalHost().getHostAddress();
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (UnknownHostException) e.getCause();
- }
+ String localHostAddress = SecurityUtility.getLocalHost().getHostAddress();
// A single home configuration.
String host = clientConnectAddress != null
@@ -1021,22 +993,8 @@
{
try
{
- final ObjectName objName = new ObjectName(invoker.getMBeanObjectName());
- try
- {
- AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- server.unregisterMBean(objName);
- return null;
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (Exception) e.getCause();
- }
+ ObjectName objName = new ObjectName(invoker.getMBeanObjectName());
+ SecurityUtility.unregisterMBean(server, objName);
}
catch (Exception e)
{
18 years
JBoss Remoting SVN: r3950 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:14:44 -0400 (Fri, 11 Apr 2008)
New Revision: 3950
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/AddressUtil.java
Log:
JBREM-934: Replaced AccessController.doPrivileged() call with SecurityUtility.getAddressByName().
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 2008-04-12 01:14:00 UTC (rev 3949)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/AddressUtil.java 2008-04-12 01:14:44 UTC (rev 3950)
@@ -25,12 +25,12 @@
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;
import org.jboss.logging.Logger;
+import org.jboss.remoting.util.SecurityUtility;
@@ -58,23 +58,7 @@
{
log.trace("checking host: " + host);
int port = PortUtil.findFreePort(host);
-
- InetAddress addr = null;
- try
- {
- addr = (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws UnknownHostException
- {
- return InetAddress.getByName(host);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (UnknownHostException) e.getCause();
- }
-
+ InetAddress addr = SecurityUtility.getAddressByName(host);
ServerTestThread t1 = new ServerTestThread(addr, port);
t1.setDaemon(true);
t1.start();
18 years
JBoss Remoting SVN: r3949 - remoting2/branches/2.x/src/main/org/jboss/remoting/stream.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:14:00 -0400 (Fri, 11 Apr 2008)
New Revision: 3949
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/stream/StreamServer.java
Log:
JBREM-934: Replaced AccessController.doPrivileged() calls with SecurityUtility calls..
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 2008-04-12 01:12:49 UTC (rev 3948)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/stream/StreamServer.java 2008-04-12 01:14:00 UTC (rev 3949)
@@ -30,6 +30,7 @@
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.util.SecurityUtility;
import javax.management.MBeanServer;
import java.io.IOException;
@@ -116,96 +117,28 @@
private String getLocatorURI() throws IOException
{
// check for system properties for locator values
+ transport = SecurityUtility.getSystemProperty(STREAM_TRANSPORT_KEY, transport);
try
{
- transport = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return System.getProperty(STREAM_TRANSPORT_KEY, transport);
- }
- });
+ host = SecurityUtility.getLocalHostName();
}
- catch (Exception e)
- {
- log.debug("error", e.getCause());
- }
-
- try
- {
- try
- {
- host = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws UnknownHostException
- {
- return InetAddress.getLocalHost().getHostName();
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (UnknownHostException) e.getCause();
- }
- }
catch(UnknownHostException e)
{
try
{
- try
- {
- host = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws UnknownHostException
- {
- return InetAddress.getLocalHost().getHostAddress();
- }
- });
- }
- catch (PrivilegedActionException e2)
- {
- throw (UnknownHostException) e2.getCause();
- }
+ InetAddress localAddress = SecurityUtility.getLocalHost();
+ host = localAddress.getHostAddress();
}
catch(UnknownHostException e1)
{
log.error("Stream server could not determine local host or address.");
}
}
-
- try
- {
- host = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return System.getProperty(STREAM_HOST_KEY, host);
- }
- });
- }
- catch (Exception e)
- {
- log.debug("error", e.getCause());
- }
-
- String sPort = null;
- try
- {
- sPort = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return System.getProperty(STREAM_PORT_KEY, "" + PortUtil.findFreePort(host));
- }
- });
- }
- catch (Exception e)
- {
- log.debug("error", e.getCause());
- }
+ host = SecurityUtility.getSystemProperty(STREAM_HOST_KEY, host);
+ String defaultPort = "" + PortUtil.findFreePort(host);
+ String sPort = SecurityUtility.getSystemProperty(STREAM_PORT_KEY, defaultPort);
-
try
{
port = Integer.parseInt(sPort);
18 years
JBoss Remoting SVN: r3948 - remoting2/branches/2.x/src/main/org/jboss/remoting/socketfactory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-11 21:12:49 -0400 (Fri, 11 Apr 2008)
New Revision: 3948
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/socketfactory/CreationListenerServerSocket.java
Log:
JBREM-934: (1) Creates reusable PriviligedExceptionAction; (2) renamed SystemUtility 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 2008-04-12 01:11:22 UTC (rev 3947)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/socketfactory/CreationListenerServerSocket.java 2008-04-12 01:12:49 UTC (rev 3948)
@@ -32,6 +32,8 @@
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import org.jboss.remoting.util.SecurityUtility;
+
/**
* A CreationListenerServerSocket wraps a ServerSocket to which it delegates
* calls to accept(), and when the wrapped ServerSocket creates a Socket in
@@ -47,6 +49,7 @@
{
private ServerSocket serverSocket;
private SocketCreationListener listener;
+ private PrivilegedExceptionAction action;
public CreationListenerServerSocket(ServerSocket serverSocket, SocketCreationListener listener)
@@ -54,6 +57,14 @@
{
this.serverSocket = serverSocket;
this.listener = listener;
+
+ action = new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return CreationListenerServerSocket.this.serverSocket.accept();
+ }
+ };
}
@@ -83,34 +94,36 @@
public void bind(SocketAddress endpoint) throws IOException
{
- serverSocket.bind(endpoint);
+ SecurityUtility.bind(serverSocket, endpoint);
}
public void bind(SocketAddress endpoint, int backlog) throws IOException
{
- serverSocket.bind(endpoint, backlog);
+ SecurityUtility.bind(serverSocket, endpoint, backlog);
}
public Socket accept() throws IOException
{
Socket socket = null;
- try
+
+ if (SecurityUtility.skipAccessControl())
{
- socket = (Socket)AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return serverSocket.accept();
- }
- });
+ socket = serverSocket.accept();
}
- catch (PrivilegedActionException e)
+ else
{
- throw (IOException) e.getCause();
+ try
+ {
+ socket = (Socket)AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
}
-
+
listener.socketCreated(socket, serverSocket);
return socket;
}
18 years