Author: ron.sigal(a)jboss.com
Date: 2008-04-11 20:56:37 -0400 (Fri, 11 Apr 2008)
New Revision: 3934
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackStore.java
Log:
JBREM-934: (1) Replaced AccessController.doPrivileged() with SecurityUtility calls; (2)
renamed SystemUtility 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 2008-04-12
00:55:24 UTC (rev 3933)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackStore.java 2008-04-12
00:56:37 UTC (rev 3934)
@@ -24,7 +24,7 @@
import org.jboss.logging.Logger;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.serialization.SerializationStreamFactory;
-import org.jboss.remoting.util.SystemUtility;
+import org.jboss.remoting.util.SecurityUtility;
import java.io.File;
import java.io.FileInputStream;
@@ -123,24 +123,18 @@
{
try
{
- filePath = (String)AccessController.doPrivileged( new
PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return System.getProperty("jboss.server.data.dir",
"data");
- }
- });
+ filePath =
SecurityUtility.getSystemProperty("jboss.server.data.dir", "data");
}
- catch (PrivilegedActionException e)
+ catch (Exception e)
{
- log.debug("error", e.getCause());
+ log.debug("error", e);
filePath = "data";
}
}
File storeFile = new File(filePath);
if (!storeFile.exists())
{
- boolean madeDir = SystemUtility.mkdirs(storeFile);
+ boolean madeDir = SecurityUtility.mkdirs(storeFile);
if (!madeDir)
{
throw new IOException("Can not create directory for store. Path
given: " + filePath);
@@ -208,7 +202,7 @@
{
try
{
- String separator =
SystemUtility.getSystemProperty("file.separator");
+ String separator =
SecurityUtility.getSystemProperty("file.separator");
fileToDelete = filePath + separator + fileList[x];
final File currentFile = new File(fileToDelete);
@@ -358,25 +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 =
SystemUtility.getSystemProperty("file.separator");
+ String separator =
SecurityUtility.getSystemProperty("file.separator");
objectFilePath = filePath + separator + objectFileList[0];
-
- try
- {
- final String finalObjectFilePath = objectFilePath;
- inFile = (FileInputStream)AccessController.doPrivileged( new
PrivilegedExceptionAction()
- {
- public Object run() throws FileNotFoundException
- {
- return new FileInputStream(finalObjectFilePath);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (IOException) e.getCause();
- }
-
+ inFile = SecurityUtility.getFileInputStream(objectFilePath);
in =
SerializationStreamFactory.getManagerInstance(serializationType).createRegularInput(inFile);
try
@@ -478,7 +456,7 @@
}
StringBuffer path = new StringBuffer(filePath);
- String separator = SystemUtility.getSystemProperty("file.separator");
+ String separator =
SecurityUtility.getSystemProperty("file.separator");
path.append(separator).append(String.valueOf(currentTimestamp));
path.append("-").append(timestampCounter).append(".").append(fileSuffix);
final File storeFile = new File(path.toString());
@@ -487,21 +465,7 @@
try
{
- try
- {
- outFile = (FileOutputStream)AccessController.doPrivileged( new
PrivilegedExceptionAction()
- {
- public Object run() throws FileNotFoundException
- {
- return new FileOutputStream(storeFile, false);
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw (IOException) e.getCause();
- }
-
+ outFile = SecurityUtility.getFileOutputStream(storeFile, false);
if (serializationType.indexOf("jboss") > 0)
{
out =
SerializationStreamFactory.getManagerInstance(serializationType).createOutput(outFile);