Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:34:23 -0400 (Tue, 14 Apr 2009)
New Revision: 5031
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/proxy/ProxyAuthenticationTestCase.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/proxy/ProxyAuthenticationTestCase.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/proxy/ProxyAuthenticationTestCase.java 2009-04-14
10:33:39 UTC (rev 5030)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/proxy/ProxyAuthenticationTestCase.java 2009-04-14
10:34:23 UTC (rev 5031)
@@ -27,6 +27,9 @@
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import java.util.Map;
@@ -119,11 +122,11 @@
setupServer();
// Set system properties.
- SecurityUtility.setSystemProperty("http.proxyHost", server.host);
- SecurityUtility.setSystemProperty("http.proxyPort",
Integer.toString(server.port));
- SecurityUtility.setSystemProperty("proxySet", "true");
- SecurityUtility.setSystemProperty("http.proxy.username",
"sysprop");
- SecurityUtility.setSystemProperty("http.proxy.password",
"abc");
+ setSystemProperty("http.proxyHost", server.host);
+ setSystemProperty("http.proxyPort", Integer.toString(server.port));
+ setSystemProperty("proxySet", "true");
+ setSystemProperty("http.proxy.username", "sysprop");
+ setSystemProperty("http.proxy.password", "abc");
// Create invocation metadata map.
HashMap metadata = new HashMap();
@@ -149,8 +152,8 @@
setupServer();
// Set system properties.
- SecurityUtility.setSystemProperty("http.proxy.username",
"sysprop");
- SecurityUtility.setSystemProperty("http.proxy.password",
"abc");
+ setSystemProperty("http.proxy.username", "sysprop");
+ setSystemProperty("http.proxy.password", "abc");
// Create invocation metadata map.
HashMap metadata = new HashMap();
@@ -177,8 +180,8 @@
setupServer();
// Set system properties.
- SecurityUtility.setSystemProperty("http.proxy.username",
"sysprop");
- SecurityUtility.setSystemProperty("http.proxy.password",
"abc");
+ setSystemProperty("http.proxy.username", "sysprop");
+ setSystemProperty("http.proxy.password", "abc");
// Create invocation metadata map.
HashMap metadata = new HashMap();
@@ -305,4 +308,28 @@
return auth;
}
}
+
+ static private void setSystemProperty(final String name, final String value)
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ System.setProperty(name, value);
+ return;
+ }
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return System.setProperty(name, value);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (RuntimeException) e.getCause();
+ }
+ }
}
\ No newline at end of file
Show replies by date