[jboss-remoting-commits] JBoss Remoting SVN: r4998 - remoting2/branches/2.x/src/main/org/jboss/remoting/callback.
jboss-remoting-commits at lists.jboss.org
jboss-remoting-commits at lists.jboss.org
Tue Apr 14 06:12:27 EDT 2009
Author: ron.sigal at jboss.com
Date: 2009-04-14 06:12:27 -0400 (Tue, 14 Apr 2009)
New Revision: 4998
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackStore.java
remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackStore.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackStore.java 2009-04-14 10:11:33 UTC (rev 4997)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackStore.java 2009-04-14 10:12:27 UTC (rev 4998)
@@ -123,7 +123,7 @@
{
try
{
- filePath = SecurityUtility.getSystemProperty("jboss.server.data.dir", "data");
+ filePath = getSystemProperty("jboss.server.data.dir", "data");
}
catch (Exception e)
{
@@ -134,7 +134,7 @@
File storeFile = new File(filePath);
if (!storeFile.exists())
{
- boolean madeDir = SecurityUtility.mkdirs(storeFile);
+ boolean madeDir = mkdirs(storeFile);
if (!madeDir)
{
throw new IOException("Can not create directory for store. Path given: " + filePath);
@@ -202,7 +202,7 @@
{
try
{
- String separator = SecurityUtility.getSystemProperty("file.separator");
+ String separator = getSystemProperty("file.separator");
fileToDelete = filePath + separator + fileList[x];
final File currentFile = new File(fileToDelete);
@@ -352,9 +352,9 @@
{
// only getting the first one, which will be first one entered since the getting
// of the list is automatically ordered by the OS and all file names are numeric by time.
- String separator = SecurityUtility.getSystemProperty("file.separator");
+ String separator = getSystemProperty("file.separator");
objectFilePath = filePath + separator + objectFileList[0];
- inFile = SecurityUtility.getFileInputStream(objectFilePath);
+ inFile = getFileInputStream(objectFilePath);
in = SerializationStreamFactory.getManagerInstance(serializationType).createRegularInput(inFile);
try
@@ -456,7 +456,7 @@
}
StringBuffer path = new StringBuffer(filePath);
- String separator = SecurityUtility.getSystemProperty("file.separator");
+ String separator = getSystemProperty("file.separator");
path.append(separator).append(String.valueOf(currentTimestamp));
path.append("-").append(timestampCounter).append(".").append(fileSuffix);
final File storeFile = new File(path.toString());
@@ -465,7 +465,7 @@
try
{
- outFile = SecurityUtility.getFileOutputStream(storeFile, false);
+ outFile = getFileOutputStream(storeFile, false);
if (serializationType.indexOf("jboss") > 0)
{
out = SerializationStreamFactory.getManagerInstance(serializationType).createOutput(outFile);
@@ -545,5 +545,115 @@
}
}
}
-
+
+ static private boolean mkdirs(final File dir)
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return dir.mkdirs();
+ }
+
+ return ((Boolean) AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return new Boolean(dir.mkdirs());
+ }
+ })).booleanValue();
+ }
+
+ static private FileInputStream getFileInputStream(final String path) throws FileNotFoundException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return new FileInputStream(path);
+ }
+
+ try
+ {
+ return (FileInputStream)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws FileNotFoundException
+ {
+ return new FileInputStream(path);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (FileNotFoundException) e.getCause();
+ }
+ }
+
+ static private FileOutputStream getFileOutputStream(final File file, final boolean append)
+ throws FileNotFoundException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return new FileOutputStream(file, append);
+ }
+
+ try
+ {
+ return (FileOutputStream)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws FileNotFoundException
+ {
+ return new FileOutputStream(file, append);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (FileNotFoundException) e.getCause();
+ }
+ }
+
+ static private String getSystemProperty(final String name, final String defaultValue)
+ {
+ if (SecurityUtility.skipAccessControl())
+ return System.getProperty(name, defaultValue);
+
+ String value = null;
+ try
+ {
+ value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return System.getProperty(name, defaultValue);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (RuntimeException) e.getCause();
+ }
+
+ return value;
+ }
+
+ 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;
+ }
}
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java 2009-04-14 10:11:33 UTC (rev 4997)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java 2009-04-14 10:12:27 UTC (rev 4998)
@@ -36,6 +36,7 @@
import org.jboss.remoting.security.SSLSocketFactoryService;
import org.jboss.remoting.util.SecurityUtility;
+import javax.management.InstanceNotFoundException;
import javax.management.MBeanServer;
import javax.management.MBeanServerInvocationHandler;
import javax.management.MalformedObjectNameException;
@@ -295,10 +296,10 @@
if (server != null)
{
String className = SSLServerSocketFactoryServiceMBean.class.getName();
- boolean isCorrectType = SecurityUtility.isInstanceOf(server, serverSocketFactoryObjName, className);
+ boolean isCorrectType = isInstanceOf(server, serverSocketFactoryObjName, className);
if (isCorrectType)
{
- Object o = SecurityUtility.getMBeanAttribute(server, serverSocketFactoryObjName, "SSLSocketBuilder");
+ Object o = getMBeanAttribute(server, serverSocketFactoryObjName, "SSLSocketBuilder");
SSLSocketBuilderMBean sslSocketBuilder = (SSLSocketBuilderMBean) o;
if (sslSocketBuilder != null)
@@ -428,10 +429,10 @@
String filePath = (String) storeConfig.get(CallbackStore.FILE_PATH_KEY);
if(filePath == null)
{
- filePath = SecurityUtility.getSystemProperty("jboss.server.data.dir", "data");
+ filePath = getSystemProperty("jboss.server.data.dir", "data");
}
- String separator = SecurityUtility.getSystemProperty("file.separator");
+ String separator = getSystemProperty("file.separator");
String newFilePath = filePath + separator + "remoting" + separator + sessionId;
storeConfig.put(CallbackStore.FILE_PATH_KEY, newFilePath);
callbackStore.setConfig(storeConfig);
@@ -1051,4 +1052,100 @@
{
this.shouldPersist = shouldPersist;
}
+
+ static private Object getMBeanAttribute(final MBeanServer server, final ObjectName objectName, final String attribute)
+ throws Exception
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return server.getAttribute(objectName, attribute);
+ }
+
+ try
+ {
+ return AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return server.getAttribute(objectName, attribute);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+ }
+
+ static private boolean isInstanceOf(final MBeanServer server, final ObjectName objectName, final String className)
+ throws InstanceNotFoundException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return server.isInstanceOf(objectName, className);
+ }
+
+ try
+ {
+ return ((Boolean)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return new Boolean(server.isInstanceOf(objectName, className));
+ }
+ })).booleanValue();
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (InstanceNotFoundException) e.getCause();
+ }
+ }
+
+ static private String getSystemProperty(final String name, final String defaultValue)
+ {
+ if (SecurityUtility.skipAccessControl())
+ return System.getProperty(name, defaultValue);
+
+ String value = null;
+ try
+ {
+ value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return System.getProperty(name, defaultValue);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (RuntimeException) e.getCause();
+ }
+
+ return value;
+ }
+
+ 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;
+ }
}
More information about the jboss-remoting-commits
mailing list