Author: ron.sigal(a)jboss.com
Date: 2008-03-20 21:40:16 -0400 (Thu, 20 Mar 2008)
New Revision: 3709
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java
Log:
JBREM-934: Put Socket.connect() in AccessController.doPrivileged() call.
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java
===================================================================
---
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java 2008-03-21
01:39:44 UTC (rev 3708)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java 2008-03-21
01:40:16 UTC (rev 3709)
@@ -36,6 +36,9 @@
import java.net.SocketTimeoutException;
import java.net.InetSocketAddress;
import java.rmi.MarshalException;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Map;
/**
@@ -185,7 +188,7 @@
}
configureSocket(s);
- InetSocketAddress inetAddr = new InetSocketAddress(address, port);
+ final InetSocketAddress inetAddr = new InetSocketAddress(address, port);
if (timeout < 0)
{
@@ -194,7 +197,24 @@
timeout = 0;
}
- s.connect(inetAddr, timeout);
+ final Socket finalSocket = s;
+ final int finalTimeout = timeout;
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ finalSocket.connect(inetAddr, finalTimeout);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
return s;
}
Show replies by date