KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > body > ibis > IbisRemoteBodyImpl


1 /*
2  * ################################################################
3  *
4  * ProActive: The Java(TM) library for Parallel, Distributed,
5  * Concurrent computing with Security and Mobility
6  *
7  * Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
8  * Contact: proactive-support@inria.fr
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23  * USA
24  *
25  * Initial developer(s): The ProActive Team
26  * http://www.inria.fr/oasis/ProActive/contacts.html
27  * Contributor(s):
28  *
29  * ################################################################
30  */

31 package org.objectweb.proactive.core.body.ibis;
32
33 import ibis.rmi.RemoteException;
34
35 import java.io.IOException JavaDoc;
36 import java.security.PublicKey JavaDoc;
37 import java.security.cert.X509Certificate JavaDoc;
38 import java.util.ArrayList JavaDoc;
39
40 import org.apache.log4j.Logger;
41 import org.objectweb.proactive.core.UniqueID;
42 import org.objectweb.proactive.core.body.UniversalBody;
43 import org.objectweb.proactive.core.body.reply.Reply;
44 import org.objectweb.proactive.core.body.request.Request;
45 import org.objectweb.proactive.core.rmi.RandomPortSocketFactory;
46 import org.objectweb.proactive.ext.security.Communication;
47 import org.objectweb.proactive.ext.security.CommunicationForbiddenException;
48 import org.objectweb.proactive.ext.security.Policy;
49 import org.objectweb.proactive.ext.security.ProActiveSecurityManager;
50 import org.objectweb.proactive.ext.security.RenegotiateSessionException;
51 import org.objectweb.proactive.ext.security.SecurityContext;
52 import org.objectweb.proactive.ext.security.SecurityNotAvailableException;
53 import org.objectweb.proactive.ext.security.crypto.AuthenticationException;
54 import org.objectweb.proactive.ext.security.crypto.ConfidentialityTicket;
55 import org.objectweb.proactive.ext.security.crypto.KeyExchangeException;
56
57
58 public class IbisRemoteBodyImpl extends ibis.rmi.server.UnicastRemoteObject
59     implements IbisRemoteBody, java.rmi.server.Unreferenced JavaDoc {
60     protected static Logger logger = Logger.getLogger(IbisRemoteBodyImpl.class.getName());
61
62     /**
63      * A custom socket Factory
64      */

65     protected static RandomPortSocketFactory factory = new RandomPortSocketFactory(37002,
66             5000);
67
68     /**
69      * The encapsulated local body
70      * transient to deal with custom serialization of requests.
71      */

72     protected transient UniversalBody body;
73
74     //
75
// -- CONSTRUCTORS -----------------------------------------------
76
//
77
public IbisRemoteBodyImpl() throws RemoteException {
78     }
79
80     public IbisRemoteBodyImpl(UniversalBody body) throws RemoteException {
81         // super(0, factory, factory);
82
if (logger.isDebugEnabled()) {
83             logger.debug(" IbisRemoteBodyImpl<init> ");
84         }
85         this.body = body;
86     }
87
88     //
89
// -- PUBLIC METHODS -----------------------------------------------
90
//
91
//
92
// -- implements IbisRemoteBody -----------------------------------------------
93
//
94
public void receiveRequest(Request r) throws java.io.IOException JavaDoc, RenegotiateSessionException {
95         if (logger.isDebugEnabled()) {
96             logger.debug("body = " + body);
97             logger.debug("request = " + r.getMethodName());
98         }
99         body.receiveRequest(r);
100     }
101
102     public void receiveReply(Reply r) throws java.io.IOException JavaDoc {
103         body.receiveReply(r);
104     }
105
106     public String JavaDoc getNodeURL() {
107         return body.getNodeURL();
108     }
109
110     public UniqueID getID() {
111         return body.getID();
112     }
113
114     public void updateLocation(UniqueID id, UniversalBody remoteBody)
115         throws java.io.IOException JavaDoc {
116         body.updateLocation(id, remoteBody);
117     }
118
119     public void unreferenced() {
120         if (logger.isDebugEnabled()) {
121             // logger.debug("IbisRemoteBodyImpl: unreferenced()");
122
}
123         System.gc();
124     }
125
126     public void enableAC() throws java.io.IOException JavaDoc {
127         body.enableAC();
128     }
129
130     public void disableAC() throws java.io.IOException JavaDoc {
131         body.disableAC();
132     }
133
134     public void setImmediateService(String JavaDoc methodName)
135         throws java.io.IOException JavaDoc {
136         body.setImmediateService(methodName);
137     }
138
139     // SECURITY
140
public void initiateSession(int type,UniversalBody rbody)
141           throws IOException JavaDoc, CommunicationForbiddenException,
142               AuthenticationException, RenegotiateSessionException,
143               SecurityNotAvailableException {
144           body.initiateSession(type,rbody);
145       }
146
147       public void terminateSession(long sessionID)
148           throws IOException JavaDoc, SecurityNotAvailableException {
149           body.terminateSession(sessionID);
150       }
151
152       public X509Certificate JavaDoc getCertificate()
153           throws SecurityNotAvailableException, IOException JavaDoc {
154           X509Certificate JavaDoc cert = body.getCertificate();
155           return cert;
156       }
157
158       public ProActiveSecurityManager getProActiveSecurityManager()
159           throws SecurityNotAvailableException, IOException JavaDoc {
160           return body.getProActiveSecurityManager();
161       }
162
163       public Policy getPolicyFrom(X509Certificate JavaDoc certificate)
164           throws SecurityNotAvailableException, IOException JavaDoc {
165           return body.getPolicyFrom(certificate);
166       }
167
168       public long startNewSession(Communication policy)
169           throws SecurityNotAvailableException, IOException JavaDoc,
170               RenegotiateSessionException {
171           return body.startNewSession(policy);
172       }
173
174       public ConfidentialityTicket negociateKeyReceiverSide(
175           ConfidentialityTicket confidentialityTicket, long sessionID)
176           throws SecurityNotAvailableException, KeyExchangeException, IOException JavaDoc {
177           return body.negociateKeyReceiverSide(confidentialityTicket, sessionID);
178       }
179
180       public PublicKey JavaDoc getPublicKey()
181           throws SecurityNotAvailableException, IOException JavaDoc {
182           return body.getPublicKey();
183       }
184
185       public byte[] randomValue(long sessionID, byte[] cl_rand)
186           throws Exception JavaDoc {
187           return body.randomValue(sessionID, cl_rand);
188       }
189
190       public byte[][] publicKeyExchange(long sessionID,
191           UniversalBody distantBody, byte[] my_pub, byte[] my_cert,
192           byte[] sig_code) throws Exception JavaDoc {
193           return body.publicKeyExchange(sessionID, distantBody, my_pub, my_cert,
194               sig_code);
195       }
196
197       public byte[][] secretKeyExchange(long sessionID, byte[] tmp, byte[] tmp1,
198           byte[] tmp2, byte[] tmp3, byte[] tmp4) throws Exception JavaDoc {
199           return body.secretKeyExchange(sessionID, tmp, tmp1, tmp2, tmp3, tmp4);
200       }
201
202       public Communication getPolicyTo(String JavaDoc type, String JavaDoc from, String JavaDoc to)
203           throws java.io.IOException JavaDoc, SecurityNotAvailableException {
204           return body.getPolicyTo(type, from, to);
205       }
206
207       /* (non-Javadoc)
208        * @see org.objectweb.proactive.core.body.rmi.RemoteBody#getVNName()
209        */

210       public String JavaDoc getVNName() throws IOException JavaDoc, SecurityNotAvailableException {
211           return body.getVNName();
212       }
213
214       /* (non-Javadoc)
215        * @see org.objectweb.proactive.core.body.rmi.RemoteBody#getCertificateEncoded()
216        */

217       public byte[] getCertificateEncoded()
218           throws IOException JavaDoc, SecurityNotAvailableException {
219           return body.getCertificateEncoded();
220       }
221
222       /* (non-Javadoc)
223        * @see org.objectweb.proactive.core.body.rmi.RemoteBody#getPolicy(org.objectweb.proactive.ext.security.SecurityContext)
224        */

225       public SecurityContext getPolicy(SecurityContext securityContext)
226           throws IOException JavaDoc, SecurityNotAvailableException {
227           return body.getPolicy(securityContext);
228       }
229
230     /* (non-Javadoc)
231      * @see org.objectweb.proactive.core.body.ibis.IbisRemoteBody#getEntities()
232      */

233      public ArrayList JavaDoc getEntities() throws SecurityNotAvailableException, IOException JavaDoc {
234              return body.getEntities();
235          }
236
237     //
238
// -- PRIVATE METHODS -----------------------------------------------
239
//
240
//
241
// -- SERIALIZATION -----------------------------------------------
242
//
243

244     
245     private void readObject(java.io.ObjectInputStream JavaDoc in)
246     throws java.io.IOException JavaDoc, ClassNotFoundException JavaDoc {
247         System.out.println("----- IbisRemoteBodyImpl.readObject() ");
248         in.defaultReadObject();
249         
250     }
251     
252     /*
253        private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
254        long startTime=System.currentTimeMillis();
255        out.defaultWriteObject();
256        long endTime=System.currentTimeMillis();
257        if (logger.isDebugEnabled()) {
258        logger.debug(" SERIALIZATION OF REMOTEBODYIMPL lasted " + (endTime - startTime));
259        }
260        }
261        private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
262        in.defaultReadObject();
263        }
264      */

265 }
266
Popular Tags