[jboss-remoting-commits] JBoss Remoting SVN: r5012 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport.
jboss-remoting-commits at lists.jboss.org
jboss-remoting-commits at lists.jboss.org
Tue Apr 14 06:19:07 EDT 2009
Author: ron.sigal at 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();
+ }
+ }
}
More information about the jboss-remoting-commits
mailing list