Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:11:33 -0400 (Tue, 14 Apr 2009)
New Revision: 4997
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/Version.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/Version.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/Version.java 2009-04-14 10:11:02
UTC (rev 4996)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/Version.java 2009-04-14 10:11:33
UTC (rev 4997)
@@ -22,6 +22,10 @@
package org.jboss.remoting;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
import org.jboss.remoting.util.SecurityUtility;
/**
@@ -50,7 +54,7 @@
static
{
boolean precompatibleFlag = false;
- String precompatible = SecurityUtility.getSystemProperty(PRE_2_0_COMPATIBLE);
+ String precompatible = getSystemProperty(PRE_2_0_COMPATIBLE);
if(precompatible != null && precompatible.length() > 0)
{
@@ -64,7 +68,7 @@
}
else
{
- String userDefinedVersion =
SecurityUtility.getSystemProperty(REMOTING_VERSION_TO_USE);
+ String userDefinedVersion = getSystemProperty(REMOTING_VERSION_TO_USE);
if(userDefinedVersion != null && userDefinedVersion.length() > 0)
{
@@ -85,7 +89,7 @@
}
else
{
- SecurityUtility.setSystemProperty(REMOTING_VERSION_TO_USE, new
Byte(defaultByteVersion).toString());
+ setSystemProperty(REMOTING_VERSION_TO_USE, new
Byte(defaultByteVersion).toString());
}
}
}
@@ -114,4 +118,52 @@
{
return version == VERSION_1 || version == VERSION_2 || version == VERSION_2_2;
}
+
+ static private String getSystemProperty(final String name)
+ {
+ if (SecurityUtility.skipAccessControl())
+ return System.getProperty(name);
+
+ String value = null;
+ try
+ {
+ value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return System.getProperty(name);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (RuntimeException) e.getCause();
+ }
+
+ return value;
+ }
+
+ 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