00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.ext.security;
00032
00033 import java.io.IOException;
00034 import java.io.ObjectOutputStream;
00035 import java.io.OutputStream;
00036 import java.rmi.Remote;
00037 import java.rmi.server.RemoteObject;
00038 import java.rmi.server.RemoteStub;
00039
00040
00047 public class SecurityOutputStream extends ObjectOutputStream {
00048
00053 public SecurityOutputStream(OutputStream out) throws IOException {
00054 super(out);
00055 System.out.println(
00056 "-*-**-*--*-*-*-**--**-*--*-**- instanciating securtityoutpoutstream");
00057 java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<Object>() {
00058 public Object run() {
00059 enableReplaceObject(true);
00060 return null;
00061 }
00062 });
00063 }
00064
00069 public SecurityOutputStream() throws IOException, SecurityException {
00070 super();
00071 }
00072
00078 protected Object replaceObject(Object obj) throws IOException {
00079 System.out.println(
00080 " */*/*/*/*/*/*/* /*/*/**//**/ Inside replaceObject /*/**/*//*/**//*/*/**//*/*");
00081 if ((obj instanceof Remote) && !(obj instanceof RemoteStub)) {
00082 System.out.println(
00083 " */*/*/*/*/*/*/* /*/*/**//**/ found a Remote object " + obj +
00084 " /*/**/*//*/**//*/*/**//*/*");
00085 Remote target = RemoteObject.toStub((Remote) obj);
00086 if (target != null) {
00087 return target;
00088 }
00089 }
00090 System.out.println(" */*/*/*/*/*/*/* /*/*/**//**/ Normal obj : " + obj +
00091 "/*/**/*//*/**//*/*/**//*/*");
00092 return obj;
00093 }
00094 }