Author: ron.sigal(a)jboss.com
Date: 2008-03-20 21:41:22 -0400 (Thu, 20 Mar 2008)
New Revision: 3710
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java
Log:
JBREM-934: Put PropertyEditors.mapJavaBeanProperties(), ServerSocket.accept() and
ServerSocket.bind() in AccessController.doPrivileged() calls.
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-03-21
01:40:16 UTC (rev 3709)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java 2008-03-21
01:41:22 UTC (rev 3710)
@@ -26,18 +26,25 @@
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.ServerInvoker;
import org.jboss.remoting.util.TimerUtil;
+import org.jboss.remoting.loading.ClassByteClassLoader;
import org.jboss.remoting.marshal.serializable.SerializableMarshaller;
import org.jboss.util.propertyeditor.PropertyEditors;
import org.jboss.logging.Logger;
import javax.net.ServerSocketFactory;
import javax.net.ssl.SSLException;
+
+import java.beans.IntrospectionException;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
@@ -175,7 +182,22 @@
protected void setup() throws Exception
{
props.putAll(getConfiguration());
- PropertyEditors.mapJavaBeanProperties(this, props, false);
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws IntrospectionException
+ {
+ PropertyEditors.mapJavaBeanProperties(this, props, false);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ log.debug(e.toString(), e);
+ throw e;
+ }
super.setup();
@@ -268,7 +290,7 @@
}
protected ServerSocket createServerSocket(int serverBindPort,
- int backlog,
+ final int backlog,
InetAddress bindAddress) throws IOException
{
ServerSocketFactory factory = getServerSocketFactory();
@@ -290,8 +312,26 @@
ss.setReuseAddress(getReuseAddress());
configureServerSocket(ss);
- InetSocketAddress address = new InetSocketAddress(bindAddress, serverBindPort);
- ss.bind(address, backlog);
+ final InetSocketAddress address = new InetSocketAddress(bindAddress,
serverBindPort);
+ final ServerSocket finalServerSocket = ss;
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ finalServerSocket.bind(address, backlog);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+
+
return ss;
}
@@ -974,7 +1014,21 @@
if(trace) { log.trace(this + " is going to wait on
serverSocket.accept()"); }
- Socket socket = serverSocket.accept();
+ 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();
+ }
if(trace) { log.trace(this + " accepted " + socket); }
Show replies by date