[jboss-remoting-commits] JBoss Remoting SVN: r3891 - remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Fri Apr 4 18:24:36 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-04-04 18:24:35 -0400 (Fri, 04 Apr 2008)
New Revision: 3891

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java
Log:
JBREM-934: Put JBossSerialization operations in AccessController.doPrivileged() calls.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java	2008-04-04 07:48:19 UTC (rev 3890)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java	2008-04-04 22:24:35 UTC (rev 3891)
@@ -37,6 +37,9 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.OutputStream;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 
 /**
  * Instantiates the Streamings according to JbossObjectOutputStream and JBossObjectInputStream.
@@ -51,16 +54,44 @@
 
    private static boolean trace = log.isTraceEnabled();
 
-   public ObjectInputStream createInput(InputStream input, ClassLoader loader) throws IOException
+   public ObjectInputStream createInput(final InputStream input, final ClassLoader loader) throws IOException
    {
       if (trace) { log.trace(this + " creating JBossObjectInputStream"); }
-      return new JBossObjectInputStream(input, loader, new StringUtilBuffer(10024, 10024));
+      
+      try
+      {
+         return (ObjectInputStream)AccessController.doPrivileged( new PrivilegedExceptionAction()
+         {
+            public Object run() throws Exception
+            {
+               return new JBossObjectInputStream(input, loader, new StringUtilBuffer(10024, 10024));
+            }
+         });
+      }
+      catch (PrivilegedActionException e)
+      {
+         throw (IOException) e.getCause();
+      }
    }
 
-   public ObjectOutputStream createOutput(OutputStream output) throws IOException
+   public ObjectOutputStream createOutput(final OutputStream output) throws IOException
    {
       if (trace) { log.trace(this + " creating JBossObjectOutputStream"); }
-      return new JBossObjectOutputStream(output, new StringUtilBuffer(10024, 10024));
+
+      try
+      {
+         return (ObjectOutputStream)AccessController.doPrivileged( new PrivilegedExceptionAction()
+         {
+            public Object run() throws Exception
+            {
+               return new JBossObjectOutputStream(output, new StringUtilBuffer(10024, 10024));
+            }
+         });
+      }
+      catch (PrivilegedActionException e)
+      {
+         throw (IOException) e.getCause();
+      }
    }
 
    /**
@@ -84,10 +115,24 @@
    }
 
 
-   public void sendObject(ObjectOutputStream oos, Object dataObject, int version) throws IOException
+   public void sendObject(final ObjectOutputStream oos, final Object dataObject, int version) throws IOException
    {
-      oos.writeObject(dataObject);
-      oos.flush();
+      try
+      {
+         AccessController.doPrivileged( new PrivilegedExceptionAction()
+         {
+            public Object run() throws Exception
+            {
+               oos.writeObject(dataObject);
+               oos.flush();
+               return null;
+            }
+         });
+      }
+      catch (PrivilegedActionException e)
+      {
+         throw (IOException) e.getCause();
+      }
    }
 
    public Object receiveObject(InputStream inputStream, ClassLoader customClassLoader, int version)
@@ -121,7 +166,22 @@
          }
       }
 
-      obj = objInputStream.readObject();
+      try
+      {
+         final ObjectInputStream ois = objInputStream;
+         obj = AccessController.doPrivileged( new PrivilegedExceptionAction()
+         {
+            public Object run() throws Exception
+            {
+               return ois.readObject();
+            }
+         });
+      }
+      catch (PrivilegedActionException e)
+      {
+         throw (IOException) e.getCause();
+      }
+
       return obj;
    }
 




More information about the jboss-remoting-commits mailing list