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.mixedlocation;
00032
00033 import java.io.IOException;
00034 import java.security.PublicKey;
00035 import java.security.cert.X509Certificate;
00036 import java.util.ArrayList;
00037
00038 import org.objectweb.proactive.core.ProActiveRuntimeException;
00039 import org.objectweb.proactive.core.UniqueID;
00040 import org.objectweb.proactive.core.body.BodyAdapter;
00041 import org.objectweb.proactive.core.body.UniversalBody;
00042 import org.objectweb.proactive.core.body.ft.internalmsg.FTMessage;
00043 import org.objectweb.proactive.core.body.reply.Reply;
00044 import org.objectweb.proactive.core.body.request.Request;
00045 import org.objectweb.proactive.core.component.request.Shortcut;
00046 import org.objectweb.proactive.core.exceptions.NonFunctionalException;
00047 import org.objectweb.proactive.core.exceptions.manager.NFEListener;
00048 import org.objectweb.proactive.ext.security.Communication;
00049 import org.objectweb.proactive.ext.security.SecurityContext;
00050 import org.objectweb.proactive.ext.security.crypto.KeyExchangeException;
00051 import org.objectweb.proactive.ext.security.exceptions.RenegotiateSessionException;
00052 import org.objectweb.proactive.ext.security.exceptions.SecurityNotAvailableException;
00053 import org.objectweb.proactive.ext.security.securityentity.Entity;
00054
00055
00056 public class UniversalBodyWrapper implements UniversalBody, Runnable {
00057 protected UniversalBody wrappedBody;
00058 protected long time;
00059 protected UniqueID id;
00060 protected boolean stop;
00061 protected long creationTime;
00062 protected String jobID;
00063
00064
00065
00071 public UniversalBodyWrapper(UniversalBody body, long time) {
00072 this.wrappedBody = body;
00073 this.time = time;
00074 this.creationTime = System.currentTimeMillis();
00075
00076 this.id = this.wrappedBody.getID();
00077
00078
00079 }
00080
00081 public int receiveRequest(Request request)
00082 throws IOException, RenegotiateSessionException {
00083
00084 if (this.wrappedBody == null) {
00085 throw new IOException();
00086 }
00087
00088
00089 if (System.currentTimeMillis() > (this.creationTime + this.time)) {
00090
00091
00092
00093
00094 throw new IOException();
00095 } else {
00096 try {
00097 return this.wrappedBody.receiveRequest(request);
00098 } catch (IOException e) {
00099 e.printStackTrace();
00100 throw e;
00101 }
00102 }
00103
00104
00105 }
00106
00107 public int receiveReply(Reply r) throws IOException {
00108 return this.wrappedBody.receiveReply(r);
00109 }
00110
00114 public void terminate() throws IOException {
00115 this.wrappedBody.terminate();
00116 }
00117
00118 public String getNodeURL() {
00119 return this.wrappedBody.getNodeURL();
00120 }
00121
00122 public UniqueID getID() {
00123 return this.id;
00124 }
00125
00126 public String getJobID() {
00127 if (jobID == null) {
00128 jobID = wrappedBody.getJobID();
00129 }
00130
00131 return jobID;
00132 }
00133
00134 public void updateLocation(UniqueID id, UniversalBody body)
00135 throws IOException {
00136 this.wrappedBody.updateLocation(id, body);
00137 }
00138
00139 public BodyAdapter getRemoteAdapter() {
00140 return this.wrappedBody.getRemoteAdapter();
00141 }
00142
00143 public void enableAC() throws java.io.IOException {
00144 this.wrappedBody.enableAC();
00145 }
00146
00147 public void disableAC() throws java.io.IOException {
00148 this.wrappedBody.disableAC();
00149 }
00150
00151 public void setImmediateService(String methodName)
00152 throws java.io.IOException {
00153 this.wrappedBody.setImmediateService(methodName);
00154 }
00155
00156 public void removeImmediateService(String methodName,
00157 Class[] parametersTypes) throws IOException {
00158 this.wrappedBody.removeImmediateService(methodName, parametersTypes);
00159 }
00160
00161 public void setImmediateService(String methodName, Class[] parametersTypes)
00162 throws IOException {
00163 this.wrappedBody.setImmediateService(methodName, parametersTypes);
00164 }
00165
00166 protected void updateServer() {
00167
00168
00169
00170
00171
00172
00173
00174
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 public void run() {
00193
00194 try {
00195
00196
00197 } catch (Exception e) {
00198 e.printStackTrace();
00199 }
00200
00201
00202 this.updateServer();
00203 this.wrappedBody = null;
00204
00205 }
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 public void addNFEListener(NFEListener listener) {
00248 wrappedBody.addNFEListener(listener);
00249 }
00250
00251 public void removeNFEListener(NFEListener listener) {
00252 wrappedBody.removeNFEListener(listener);
00253 }
00254
00255 public int fireNFE(NonFunctionalException e) {
00256 return wrappedBody.fireNFE(e);
00257 }
00258
00259
00260 public void terminateSession(long sessionID)
00261 throws java.io.IOException, SecurityNotAvailableException {
00262 wrappedBody.terminateSession(sessionID);
00263 }
00264
00265 public X509Certificate getCertificate()
00266 throws java.io.IOException, SecurityNotAvailableException {
00267 return wrappedBody.getCertificate();
00268 }
00269
00270 public long startNewSession(Communication policy)
00271 throws java.io.IOException, RenegotiateSessionException,
00272 SecurityNotAvailableException {
00273 return wrappedBody.startNewSession(policy);
00274 }
00275
00276 public PublicKey getPublicKey()
00277 throws java.io.IOException, SecurityNotAvailableException {
00278 return wrappedBody.getPublicKey();
00279 }
00280
00281 public byte[] randomValue(long sessionID, byte[] cl_rand)
00282 throws IOException, SecurityNotAvailableException,
00283 RenegotiateSessionException {
00284 return wrappedBody.randomValue(sessionID, cl_rand);
00285 }
00286
00287 public byte[][] publicKeyExchange(long sessionID, byte[] my_pub,
00288 byte[] my_cert, byte[] sig_code)
00289 throws IOException, SecurityNotAvailableException,
00290 RenegotiateSessionException, KeyExchangeException {
00291 return wrappedBody.publicKeyExchange(sessionID, my_pub, my_cert,
00292 sig_code);
00293 }
00294
00295 public byte[][] secretKeyExchange(long sessionID, byte[] tmp, byte[] tmp1,
00296 byte[] tmp2, byte[] tmp3, byte[] tmp4)
00297 throws IOException, SecurityNotAvailableException,
00298 RenegotiateSessionException {
00299 return wrappedBody.secretKeyExchange(sessionID, tmp, tmp1, tmp2, tmp3,
00300 tmp4);
00301 }
00302
00303
00304
00305
00306 public byte[] getCertificateEncoded()
00307 throws IOException, SecurityNotAvailableException {
00308 return wrappedBody.getCertificateEncoded();
00309 }
00310
00311
00312
00313
00314 public SecurityContext getPolicy(SecurityContext securityContext)
00315 throws SecurityNotAvailableException, IOException {
00316 return wrappedBody.getPolicy(securityContext);
00317 }
00318
00319 public ArrayList<Entity> getEntities()
00320 throws SecurityNotAvailableException, IOException {
00321 return wrappedBody.getEntities();
00322 }
00323
00327 public Object receiveFTMessage(FTMessage ev) throws IOException {
00328 return this.wrappedBody.receiveFTMessage(ev);
00329 }
00330
00331 public void createShortcut(Shortcut shortcut) throws IOException {
00332
00333 throw new ProActiveRuntimeException(
00334 "create shortcut method not implemented yet");
00335 }
00336 }