[jboss-remoting-commits] JBoss Remoting SVN: r4992 - remoting2/branches/2.x/src/main/org/jboss/remoting.
jboss-remoting-commits at lists.jboss.org
jboss-remoting-commits at lists.jboss.org
Tue Apr 14 06:09:06 EDT 2009
Author: ron.sigal at jboss.com
Date: 2009-04-14 06:09:05 -0400 (Tue, 14 Apr 2009)
New Revision: 4992
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java 2009-04-14 06:29:01 UTC (rev 4991)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java 2009-04-14 10:09:05 UTC (rev 4992)
@@ -54,9 +54,12 @@
import java.lang.ref.WeakReference;
import java.net.InetAddress;
import java.net.SocketTimeoutException;
+import java.net.UnknownHostException;
import java.rmi.MarshalException;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -952,7 +955,7 @@
}
if (host == null)
{
- host = SecurityUtility.getLocalHost().getHostAddress();
+ host = getLocalHost().getHostAddress();
metadata.put(CALLBACK_SERVER_HOST, host);
}
if (port == -1)
@@ -1860,4 +1863,41 @@
ref = null;
}
}
+
+ 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