org/objectweb/proactive/core/body/rmi/RmiRemoteBodyForwarderImpl.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.core.body.rmi;
00032 
00033 import java.io.IOException;
00034 import java.rmi.RemoteException;
00035 import java.rmi.server.RMIClientSocketFactory;
00036 import java.rmi.server.RMIServerSocketFactory;
00037 import java.security.PublicKey;
00038 import java.security.cert.X509Certificate;
00039 import java.util.ArrayList;
00040 
00041 import org.objectweb.proactive.Body;
00042 import org.objectweb.proactive.core.UniqueID;
00043 import org.objectweb.proactive.core.body.BodyAdapter;
00044 import org.objectweb.proactive.core.body.UniversalBody;
00045 import org.objectweb.proactive.core.body.UniversalBodyForwarder;
00046 import org.objectweb.proactive.core.body.ft.internalmsg.FTMessage;
00047 import org.objectweb.proactive.core.body.reply.Reply;
00048 import org.objectweb.proactive.core.body.request.Request;
00049 import org.objectweb.proactive.core.exceptions.NonFunctionalException;
00050 import org.objectweb.proactive.core.exceptions.manager.NFEListener;
00051 import org.objectweb.proactive.ext.security.Communication;
00052 import org.objectweb.proactive.ext.security.SecurityContext;
00053 import org.objectweb.proactive.ext.security.crypto.KeyExchangeException;
00054 import org.objectweb.proactive.ext.security.exceptions.RenegotiateSessionException;
00055 import org.objectweb.proactive.ext.security.exceptions.SecurityNotAvailableException;
00056 
00057 
00063 public class RmiRemoteBodyForwarderImpl extends java.rmi.server.UnicastRemoteObject
00064     implements RmiRemoteBodyForwarder {
00065 
00070     //    protected static RandomPortSocketFactory factory = new RandomPortSocketFactory(37002,
00071     //            5000);
00072     //  protected static BenchSocketFactory factory = new BenchSocketFactory();
00073     protected transient UniversalBodyForwarder body;
00074 
00075     //
00076     // -- CONSTRUCTORS -----------------------------------------------
00077     //
00078     public RmiRemoteBodyForwarderImpl() throws RemoteException {
00079     }
00080 
00081     public RmiRemoteBodyForwarderImpl(UniversalBodyForwarder body)
00082         throws RemoteException {
00083         //      super(0, factory, factory);
00084         this.body = body;
00085     }
00086 
00087     public RmiRemoteBodyForwarderImpl(UniversalBodyForwarder body,
00088         RMIServerSocketFactory sf, RMIClientSocketFactory cf)
00089         throws RemoteException {
00090         super(0, cf, sf);
00091         this.body = body;
00092     }
00093 
00094     //
00095     // -- PUBLIC METHODS -----------------------------------------------
00096     //
00097     //
00098     // -- implements RmiRemoteBodyForwarder -----------------------------------------
00099     //
00100     public int receiveRequest(UniqueID id, Request r)
00101         throws java.io.IOException, RenegotiateSessionException {
00102         return body.receiveRequest(id, r);
00103     }
00104 
00105     public int receiveReply(UniqueID id, Reply r) throws java.io.IOException {
00106         return body.receiveReply(id, r);
00107     }
00108 
00112     public void terminate(UniqueID id) throws IOException {
00113         body.terminate(id);
00114     }
00115 
00116     public String getNodeURL(UniqueID id) {
00117         return body.getNodeURL(id);
00118     }
00119 
00120     public UniqueID getID(UniqueID id) {
00121         return body.getID(id);
00122     }
00123 
00124     public void updateLocation(UniqueID id, UniqueID uid,
00125         UniversalBody remoteBody) throws java.io.IOException {
00126         body.updateLocation(id, uid, remoteBody);
00127     }
00128 
00129     public void unreferenced(UniqueID id) {
00130         // System.out.println("RmiRemoteBodyImpl: unreferenced()");      
00131         // System.gc();
00132     }
00133 
00134     public void enableAC(UniqueID id) throws java.io.IOException {
00135         body.enableAC(id);
00136     }
00137 
00138     public void disableAC(UniqueID id) throws java.io.IOException {
00139         body.disableAC(id);
00140     }
00141 
00142     public void setImmediateService(UniqueID id, String methodName)
00143         throws java.io.IOException {
00144         body.setImmediateService(id, methodName);
00145     }
00146 
00147     public void removeImmediateService(UniqueID id, String methodName,
00148         Class[] parametersTypes) throws IOException {
00149         body.removeImmediateService(id, methodName, parametersTypes);
00150     }
00151 
00152     public void setImmediateService(UniqueID id, String methodName,
00153         Class[] parametersTypes) throws IOException {
00154         body.setImmediateService(id, methodName, parametersTypes);
00155     }
00156 
00157     // SECURITY
00158     public void terminateSession(UniqueID id, long sessionID)
00159         throws IOException, SecurityNotAvailableException {
00160         body.terminateSession(id, sessionID);
00161     }
00162 
00163     public X509Certificate getCertificate(UniqueID id)
00164         throws SecurityNotAvailableException, IOException {
00165         X509Certificate cert = body.getCertificate(id);
00166         return cert;
00167     }
00168 
00169     public long startNewSession(UniqueID id, Communication policy)
00170         throws SecurityNotAvailableException, IOException, 
00171             RenegotiateSessionException {
00172         return body.startNewSession(id, policy);
00173     }
00174 
00175     public PublicKey getPublicKey(UniqueID id)
00176         throws SecurityNotAvailableException, IOException {
00177         return body.getPublicKey(id);
00178     }
00179 
00180     public byte[] randomValue(UniqueID id, long sessionID, byte[] cl_rand)
00181         throws RenegotiateSessionException, IOException, 
00182             SecurityNotAvailableException {
00183         return body.randomValue(id, sessionID, cl_rand);
00184     }
00185 
00186     public byte[][] publicKeyExchange(UniqueID id, long sessionID,
00187         byte[] my_pub, byte[] my_cert, byte[] sig_code)
00188         throws IOException, RenegotiateSessionException, 
00189             SecurityNotAvailableException, KeyExchangeException {
00190         return body.publicKeyExchange(id, sessionID, my_pub, my_cert, sig_code);
00191     }
00192 
00193     /* (non-Javadoc)
00194      * @see org.objectweb.proactive.core.body.rmi.RmiRemoteBody#getCertificateEncoded()
00195      */
00196     public byte[] getCertificateEncoded(UniqueID id)
00197         throws IOException, SecurityNotAvailableException {
00198         return body.getCertificateEncoded(id);
00199     }
00200 
00201     /* (non-Javadoc)
00202      * @see org.objectweb.proactive.core.body.rmi.RmiRemoteBody#getPolicy(org.objectweb.proactive.ext.security.SecurityContext)
00203      */
00204     public SecurityContext getPolicy(UniqueID id,
00205         SecurityContext securityContext)
00206         throws IOException, SecurityNotAvailableException {
00207         return body.getPolicy(id, securityContext);
00208     }
00209 
00210     public ArrayList getEntities(UniqueID id)
00211         throws SecurityNotAvailableException, IOException {
00212         return body.getEntities(id);
00213     }
00214 
00215     /* (non-Javadoc)
00216      * @see org.objectweb.proactive.core.body.rmi.RmiRemoteBody#receiveFTEvent(org.objectweb.proactive.core.body.ft.events.FTEvent)
00217      */
00218     public Object receiveFTMessage(UniqueID id, FTMessage fte)
00219         throws IOException {
00220         return this.body.receiveFTMessage(id, fte);
00221     }
00222 
00223     public void changeProxiedBody(UniqueID id, Body newBody)
00224         throws IOException {
00225         body.changeProxiedBody(id, newBody);
00226     }
00227 
00228     //-------------------------------
00229     //  NFEProducer implementation
00230     //-------------------------------
00231     public void addNFEListener(UniqueID id, NFEListener listener)
00232         throws IOException {
00233         body.addNFEListener(id, listener);
00234     }
00235 
00236     public void removeNFEListener(UniqueID id, NFEListener listener)
00237         throws IOException {
00238         body.removeNFEListener(id, listener);
00239     }
00240 
00241     public int fireNFE(UniqueID id, NonFunctionalException e)
00242         throws IOException {
00243         return body.fireNFE(id, e);
00244     }
00245 
00246     //
00247     // -- PRIVATE METHODS -----------------------------------------------
00248     //
00249     //
00250     // -- SERIALIZATION -----------------------------------------------
00251     //
00252     private void writeObject(java.io.ObjectOutputStream out)
00253         throws java.io.IOException {
00254         // long startTime=System.currentTimeMillis();
00255         //System.out.println("i am in serialization");
00256         out.defaultWriteObject();
00257         //System.out.println("i am in serialization");
00258         //long endTime=System.currentTimeMillis();
00259         //System.out.println(" SERIALIZATION OF REMOTEBODYIMPL lasted " + (endTime - startTime));
00260     }
00261 
00262     public String getJobID(UniqueID id) throws IOException {
00263         return body.getJobID(id);
00264     }
00265 
00266     public UniversalBody lookup(UniqueID id, String url)
00267         throws IOException {
00268         return body.lookup(id, url);
00269     }
00270 
00271     public void register(UniqueID id, String url) throws IOException {
00272         body.register(id, url);
00273     }
00274 
00275     public void unregister(UniqueID id, String url) throws IOException {
00276         body.unregister(id, url);
00277     }
00278 
00279     public BodyAdapter getRemoteAdapter(UniqueID id) {
00280         return body.getRemoteAdapter(id);
00281     }
00282 
00283     public byte[][] secretKeyExchange(UniqueID id, long sessionID,
00284         byte[] encodedAESKey, byte[] encodedIVParameters,
00285         byte[] encodedClientMacKey, byte[] encodedLockData,
00286         byte[] parametersSignature)
00287         throws SecurityNotAvailableException, RenegotiateSessionException, 
00288             IOException {
00289         return body.secretKeyExchange(id, sessionID, encodedAESKey,
00290             encodedIVParameters, encodedClientMacKey, encodedLockData,
00291             parametersSignature);
00292     }
00293 }

Generated on Mon Jan 22 15:16:06 2007 for ProActive by  doxygen 1.5.1