Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:22:29 -0400 (Tue, 14 Apr 2009)
New Revision: 5018
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java
===================================================================
---
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java 2009-04-14
10:22:01 UTC (rev 5017)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java 2009-04-14
10:22:29 UTC (rev 5018)
@@ -48,6 +48,10 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
@@ -199,7 +203,7 @@
}
String remoteAddressString = request.getRemoteAddr();
- InetAddress remoteAddress =
SecurityUtility.getAddressByName(remoteAddressString);
+ InetAddress remoteAddress = getAddressByName(remoteAddressString);
Map requestPayload = invocationRequest.getRequestPayload();
if (requestPayload == null)
@@ -366,7 +370,7 @@
}
String remoteAddressString = request.getRemoteAddr();
- InetAddress remoteAddress =
SecurityUtility.getAddressByName(remoteAddressString);
+ InetAddress remoteAddress = getAddressByName(remoteAddressString);
Map requestPayload = invocationRequest.getRequestPayload();
if (requestPayload == null)
@@ -502,4 +506,27 @@
return flag;
}
+
+ 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();
+ }
+ }
}
\ No newline at end of file
Show replies by date