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.core.runtime.http;
00032 
00033 import java.io.IOException;
00034 import java.lang.reflect.InvocationTargetException;
00035 import java.net.MalformedURLException;
00036 import java.net.URL;
00037 import java.net.UnknownHostException;
00038 import java.rmi.AlreadyBoundException;
00039 import java.security.PublicKey;
00040 import java.security.cert.X509Certificate;
00041 import java.util.ArrayList;
00042 
00043 import org.objectweb.proactive.Body;
00044 import org.objectweb.proactive.core.ProActiveException;
00045 import org.objectweb.proactive.core.body.UniversalBody;
00046 import org.objectweb.proactive.core.body.ft.checkpointing.Checkpoint;
00047 import org.objectweb.proactive.core.body.http.util.exceptions.HTTPRemoteException;
00048 import org.objectweb.proactive.core.config.ProActiveConfiguration;
00049 import org.objectweb.proactive.core.descriptor.data.ProActiveDescriptor;
00050 import org.objectweb.proactive.core.descriptor.data.VirtualNode;
00051 import org.objectweb.proactive.core.mop.ConstructorCall;
00052 import org.objectweb.proactive.core.mop.ConstructorCallExecutionFailedException;
00053 import org.objectweb.proactive.core.node.NodeException;
00054 import org.objectweb.proactive.core.process.ExternalProcess;
00055 import org.objectweb.proactive.core.process.UniversalProcess;
00056 import org.objectweb.proactive.core.rmi.ClassServer;
00057 import org.objectweb.proactive.core.rmi.ClassServerServlet;
00058 import org.objectweb.proactive.core.runtime.ProActiveRuntime;
00059 import org.objectweb.proactive.core.runtime.ProActiveRuntimeImpl;
00060 import org.objectweb.proactive.core.runtime.RemoteProActiveRuntime;
00061 import org.objectweb.proactive.core.runtime.VMInformation;
00062 import org.objectweb.proactive.core.runtime.http.messages.RuntimeRequest;
00063 import org.objectweb.proactive.core.util.UrlBuilder;
00064 import org.objectweb.proactive.ext.security.Communication;
00065 import org.objectweb.proactive.ext.security.ProActiveSecurityManager;
00066 import org.objectweb.proactive.ext.security.SecurityContext;
00067 import org.objectweb.proactive.ext.security.crypto.KeyExchangeException;
00068 import org.objectweb.proactive.ext.security.exceptions.RenegotiateSessionException;
00069 import org.objectweb.proactive.ext.security.exceptions.SecurityNotAvailableException;
00070 import org.objectweb.proactive.ext.security.securityentity.Entity;
00071 
00072 
00081 public class HttpProActiveRuntime implements RemoteProActiveRuntime {
00082     private transient ProActiveRuntime localruntime;
00083     private boolean isLocal;
00084     private String url;
00085     protected VMInformation vmInformation;
00086 
00087     
00088     
00089     
00090     protected boolean alreadykilled = false;
00091 
00092     public HttpProActiveRuntime() {
00093         isLocal = true;
00094         this.localruntime = ProActiveRuntimeImpl.getProActiveRuntime();
00095 
00096         if (ProActiveConfiguration.osgiServletEnabled()) {
00097             this.url = ClassServerServlet.getUrl();
00098         } else {
00099             this.url = ClassServer.getUrl();
00100         }
00101 
00102         
00103         
00104         this.vmInformation = localruntime.getVMInformation();
00105     }
00106 
00110     public HttpProActiveRuntime(String newurl) {
00111         runtimeLogger.debug("Adapter URL = " + newurl);
00112 
00113         try {
00114             this.url = UrlBuilder.checkUrl(newurl);
00115             isLocal = false;
00116             runtimeLogger.debug("New Remote XML Adapter : " + url);
00117         } catch (UnknownHostException e) {
00118             
00119             e.printStackTrace();
00120         }
00121     }
00122 
00123     
00124     
00125     
00126     public ExternalProcess getProcessToDeploy(
00127         ProActiveRuntime proActiveRuntimeDist, String creatorID, String vmName,
00128         String padURL) throws ProActiveException {
00129         ArrayList<Object> params = new ArrayList<Object>();
00130         params.add(proActiveRuntimeDist);
00131         params.add(creatorID);
00132         params.add(vmName);
00133         params.add(padURL);
00134 
00135         try {
00136             new RuntimeRequest("getProcessToDeploy", params, this.url).send();
00137         } catch (Exception e) {
00138             e.printStackTrace();
00139         }
00140 
00141         return null;
00142     }
00143 
00144     public String createLocalNode(String nodeName,
00145         boolean replacePreviousBinding,
00146         ProActiveSecurityManager securityManager, String vname, String jobId)
00147         throws NodeException, HTTPRemoteException, AlreadyBoundException {
00148         String nodeURL = null;
00149         try {
00150             nodeURL = buildNodeURL(nodeName);
00151         } catch (UnknownHostException e1) {
00152             e1.printStackTrace();
00153         }
00154 
00155         
00156         String name = UrlBuilder.getNameFromUrl(nodeURL);
00157         if (isLocal) {
00158             localruntime.createLocalNode(name, replacePreviousBinding,
00159                 securityManager, vname, jobId);
00160         } else {
00161             ArrayList<Object> paramsList = new ArrayList<Object>();
00162             paramsList.add(name);
00163             paramsList.add(new Boolean(replacePreviousBinding));
00164             paramsList.add(securityManager);
00165             paramsList.add(vname);
00166             paramsList.add(jobId);
00167 
00168             RuntimeRequest req = new RuntimeRequest("createLocalNode",
00169                     paramsList, this.url);
00170             req.send();
00171         }
00172 
00173         runtimeLogger.info(nodeURL + " successfully registered ");
00174 
00175         return nodeURL;
00176     }
00177 
00178     public void killAllNodes() throws HTTPRemoteException, ProActiveException {
00179         if (isLocal) {
00180             localruntime.killAllNodes();
00181 
00182             return;
00183         }
00184 
00185         new RuntimeRequest("killAllNodes", this.url).send();
00186     }
00187 
00188     public void killNode(String nodeName)
00189         throws ProActiveException, HTTPRemoteException {
00190         String name = UrlBuilder.getNameFromUrl(nodeName);
00191 
00192         if (isLocal) {
00193             localruntime.killNode(name);
00194 
00195             return;
00196         }
00197 
00198         ArrayList<Object> params = new ArrayList<Object>();
00199         params.add(name);
00200         new RuntimeRequest("killNode", params, this.url).send();
00201     }
00202 
00203     public void createVM(UniversalProcess remoteProcess)
00204         throws IOException, ProActiveException {
00205         if (isLocal) {
00206             localruntime.createVM(remoteProcess);
00207 
00208             return;
00209         }
00210 
00211         ArrayList<Object> params = new ArrayList<Object>();
00212         params.add(remoteProcess);
00213         new RuntimeRequest("createVM", params, this.url).send();
00214     }
00215 
00216     public String[] getLocalNodeNames()
00217         throws ProActiveException, HTTPRemoteException {
00218         if (isLocal) {
00219             return localruntime.getLocalNodeNames();
00220         }
00221 
00222         RuntimeRequest req = new RuntimeRequest("getLocalNodeNames", this.url);
00223         req.send();
00224 
00225         try {
00226             return (String[]) req.getReturnedObject();
00227         } catch (Exception e) {
00228             throw new ProActiveException(e);
00229         }
00230     }
00231 
00232     public VMInformation getVMInformation() throws HTTPRemoteException {
00233         if (this.vmInformation == null) {
00234             if (isLocal) {
00235                 this.vmInformation = localruntime.getVMInformation();
00236             }
00237 
00238             RuntimeRequest req = new RuntimeRequest("getVMInformation", this.url);
00239             req.send();
00240 
00241             try {
00242                 this.vmInformation = (VMInformation) req.getReturnedObject();
00243             } catch (Exception e) {
00244                 e.printStackTrace();
00245             }
00246         }
00247 
00248         return this.vmInformation;
00249     }
00250 
00251     public void register(ProActiveRuntime proActiveRuntimeDist,
00252         String proActiveRuntimeName, String creatorID, String creationProtocol,
00253         String vmName) throws ProActiveException, HTTPRemoteException {
00254         if (isLocal) {
00255             localruntime.register(proActiveRuntimeDist, proActiveRuntimeName,
00256                 creatorID, creationProtocol, vmName);
00257 
00258             return;
00259         }
00260 
00261         ArrayList<Object> params = new ArrayList<Object>();
00262         ArrayList<Class> paramsTypes = new ArrayList<Class>();
00263 
00264         params.add(proActiveRuntimeDist);
00265         paramsTypes.add(ProActiveRuntime.class);
00266         params.add(proActiveRuntimeName);
00267         paramsTypes.add(String.class);
00268         params.add(creatorID);
00269         paramsTypes.add(String.class);
00270         params.add(creationProtocol);
00271         paramsTypes.add(String.class);
00272         params.add(vmName);
00273         paramsTypes.add(String.class);
00274 
00275         new RuntimeRequest("register", params, paramsTypes, this.url).send();
00276     }
00277 
00283     public void unregister(ProActiveRuntime proActiveRuntimeDist,
00284         String proActiveRuntimeUrl, String creatorID, String creationProtocol,
00285         String vmName) throws ProActiveException, HTTPRemoteException {
00286         if (isLocal) {
00287             localruntime.unregister(proActiveRuntimeDist, proActiveRuntimeUrl,
00288                 creatorID, creationProtocol, vmName);
00289 
00290             return;
00291         }
00292 
00293         ArrayList<Object> params = new ArrayList<Object>();
00294         ArrayList<Class> paramsTypes = new ArrayList<Class>();
00295 
00296         params.add(proActiveRuntimeDist);
00297         paramsTypes.add(ProActiveRuntime.class);
00298         params.add(proActiveRuntimeUrl);
00299         paramsTypes.add(String.class);
00300         params.add(creatorID);
00301         paramsTypes.add(String.class);
00302         params.add(creationProtocol);
00303         paramsTypes.add(String.class);
00304         params.add(vmName);
00305         paramsTypes.add(String.class);
00306 
00307         new RuntimeRequest("unregister", params, paramsTypes, this.url).send();
00308     }
00309 
00310     public ProActiveRuntime[] getProActiveRuntimes()
00311         throws ProActiveException, HTTPRemoteException {
00312         RuntimeRequest req = new RuntimeRequest("getProActiveRuntimes", this.url);
00313 
00314         if (isLocal) {
00315             return localruntime.getProActiveRuntimes();
00316         }
00317 
00318         req.send();
00319 
00320         try {
00321             return (ProActiveRuntime[]) req.getReturnedObject();
00322         } catch (Exception e) {
00323             throw new ProActiveException(e);
00324         }
00325     }
00326 
00327     public ProActiveRuntime getProActiveRuntime(String proActiveRuntimeName)
00328         throws ProActiveException, HTTPRemoteException {
00329         if (isLocal) {
00330             return localruntime.getProActiveRuntime(proActiveRuntimeName);
00331         }
00332 
00333         ArrayList<Object> params = new ArrayList<Object>();
00334         params.add(proActiveRuntimeName);
00335 
00336         RuntimeRequest req = new RuntimeRequest("getProActiveRuntime", params,
00337                 this.url);
00338         req.send();
00339 
00340         try {
00341             return (ProActiveRuntime) req.getReturnedObject();
00342         } catch (Exception e) {
00343             throw new ProActiveException(e);
00344         }
00345     }
00346 
00347     public void killRT(boolean softly) throws Exception {
00348         if (!alreadykilled) {
00349             if (isLocal) {
00350                 localruntime.killRT(softly);
00351             } else {
00352                 ArrayList<Object> params = new ArrayList<Object>();
00353                 params.add(new Boolean(softly));
00354 
00355                 new RuntimeRequest("killRT", params, this.url).send();
00356             }
00357         }
00358 
00359         alreadykilled = true;
00360     }
00361 
00362     public String getURL() throws ProActiveException {
00363         return this.url;
00364     }
00365 
00366     public ArrayList getActiveObjects(String nodeName)
00367         throws ProActiveException, HTTPRemoteException {
00368         if (isLocal) {
00369             return localruntime.getActiveObjects(nodeName);
00370         }
00371 
00372         ArrayList<Object> params = new ArrayList<Object>();
00373         params.add(nodeName);
00374 
00375         RuntimeRequest req = new RuntimeRequest("getActiveObjects", params,
00376                 this.url);
00377         req.send();
00378 
00379         try {
00380             return (ArrayList) req.getReturnedObject();
00381         } catch (Exception e) {
00382             throw new ProActiveException(e);
00383         }
00384     }
00385 
00386     public ArrayList getActiveObjects(String nodeName, String objectName)
00387         throws ProActiveException, HTTPRemoteException {
00388         if (isLocal) {
00389             return localruntime.getActiveObjects(nodeName, objectName);
00390         }
00391 
00392         ArrayList<Object> params = new ArrayList<Object>();
00393         params.add(nodeName);
00394         params.add(objectName);
00395 
00396         RuntimeRequest req = new RuntimeRequest("getActiveObjects", params,
00397                 this.url);
00398         req.send();
00399 
00400         try {
00401             return (ArrayList) req.getReturnedObject();
00402         } catch (Exception e) {
00403             throw new ProActiveException(e);
00404         }
00405     }
00406 
00407     public VirtualNode getVirtualNode(String virtualNodeName)
00408         throws ProActiveException, HTTPRemoteException {
00409         if (isLocal) {
00410             return localruntime.getVirtualNode(virtualNodeName);
00411         }
00412 
00413         ArrayList<Object> params = new ArrayList<Object>();
00414         params.add(virtualNodeName);
00415 
00416         RuntimeRequest req = new RuntimeRequest("getVirtualNode", params,
00417                 this.url);
00418         req.send();
00419 
00420         try {
00421             return (VirtualNode) req.getReturnedObject();
00422         } catch (Exception e) {
00423             throw new ProActiveException(e);
00424         }
00425     }
00426 
00427     public void registerVirtualNode(String virtualNodeName,
00428         boolean replacePreviousBinding)
00429         throws ProActiveException, HTTPRemoteException {
00430         
00431         
00432         
00433         String vn_url;
00434 
00435         try {
00436             vn_url = buildNodeURL(virtualNodeName);
00437         } catch (UnknownHostException e) {
00438             throw new ProActiveException(e);
00439         }
00440 
00441         runtimeLogger.info(virtualNodeName + " successfully registered at " +
00442             vn_url);
00443     }
00444 
00445     public void unregisterVirtualNode(String virtualNodeName)
00446         throws ProActiveException, HTTPRemoteException {
00447         if (isLocal) {
00448             localruntime.unregisterVirtualNode(virtualNodeName);
00449 
00450             return;
00451         }
00452 
00453         ArrayList<Object> params = new ArrayList<Object>();
00454         params.add(virtualNodeName);
00455 
00456         new RuntimeRequest("unregisterVirtualNode", params, this.url).send();
00457     }
00458 
00459     public void unregisterAllVirtualNodes() throws ProActiveException {
00460         if (isLocal) {
00461             localruntime.unregisterAllVirtualNodes();
00462 
00463             return;
00464         }
00465 
00466         try {
00467             new RuntimeRequest("unregisterAllVirtualNodes", this.url).send();
00468         } catch (HTTPRemoteException e) {
00469             
00470             e.printStackTrace();
00471         }
00472     }
00473 
00474     public UniversalBody createBody(String nodeName,
00475         ConstructorCall bodyConstructorCall, boolean isNodeLocal)
00476         throws ProActiveException, ConstructorCallExecutionFailedException,
00477             InvocationTargetException, HTTPRemoteException {
00478         if (isLocal) {
00479             return localruntime.createBody(nodeName, bodyConstructorCall,
00480                 isNodeLocal);
00481         }
00482 
00483         ArrayList<Object> params = new ArrayList<Object>();
00484         params.add(nodeName);
00485         params.add(bodyConstructorCall);
00486         params.add(new Boolean(isNodeLocal));
00487 
00488         RuntimeRequest req = new RuntimeRequest("createBody", params, this.url);
00489         req.send();
00490 
00491         try {
00492             return (UniversalBody) req.getReturnedObject();
00493         } catch (ConstructorCallExecutionFailedException e) {
00494             throw e;
00495         } catch (InvocationTargetException e) {
00496             throw e;
00497         } catch (Exception e) {
00498             throw new ProActiveException(e);
00499         }
00500     }
00501 
00502     public UniversalBody receiveBody(String nodeName, Body body)
00503         throws ProActiveException, HTTPRemoteException {
00504         if (isLocal) {
00505             return localruntime.receiveBody(nodeName, body);
00506         }
00507 
00508         ArrayList<Object> params = new ArrayList<Object>();
00509         params.add(nodeName);
00510         params.add(body);
00511 
00512         RuntimeRequest req = new RuntimeRequest("receiveBody", params, this.url);
00513         req.send();
00514 
00515         try {
00516             return (UniversalBody) req.getReturnedObject();
00517         } catch (Exception e) {
00518             throw new ProActiveException(e);
00519         }
00520     }
00521 
00526     public String getJobID(String nodeUrl)
00527         throws ProActiveException, HTTPRemoteException {
00528         if (isLocal) {
00529             return localruntime.getJobID(nodeUrl);
00530         }
00531 
00532         ArrayList<Object> params = new ArrayList<Object>();
00533         params.add(nodeUrl);
00534 
00535         RuntimeRequest req = new RuntimeRequest("getJobID", params, this.url);
00536         req.send();
00537 
00538         try {
00539             return (String) req.getReturnedObject();
00540         } catch (Exception e) {
00541             throw new ProActiveException(e);
00542         }
00543     }
00544 
00545     public void addAcquaintance(String proActiveRuntimeName)
00546         throws ProActiveException, HTTPRemoteException {
00547         if (isLocal) {
00548             localruntime.addAcquaintance(proActiveRuntimeName);
00549 
00550             return;
00551         }
00552 
00553         ArrayList<Object> params = new ArrayList<Object>();
00554         params.add(proActiveRuntimeName);
00555 
00556         new RuntimeRequest("addAcquaintance", params, this.url).send();
00557     }
00558 
00559     public String[] getAcquaintances()
00560         throws ProActiveException, HTTPRemoteException {
00561         if (isLocal) {
00562             return localruntime.getAcquaintances();
00563         }
00564 
00565         RuntimeRequest req = new RuntimeRequest("getAcquaintances", this.url);
00566         req.send();
00567 
00568         try {
00569             return (String[]) req.getReturnedObject();
00570         } catch (Exception e) {
00571             throw new ProActiveException(e);
00572         }
00573     }
00574 
00580     public void rmAcquaintance(String proActiveRuntimeName)
00581         throws ProActiveException, HTTPRemoteException {
00582         if (isLocal) {
00583             localruntime.rmAcquaintance(proActiveRuntimeName);
00584 
00585             return;
00586         }
00587 
00588         ArrayList<Object> params = new ArrayList<Object>();
00589         params.add(proActiveRuntimeName);
00590 
00591         new RuntimeRequest("rmAcquaintance", params, this.url).send();
00592     }
00593 
00594     public byte[] getClassDataFromParentRuntime(String className)
00595         throws ProActiveException, HTTPRemoteException {
00596         if (isLocal) {
00597             return localruntime.getClassDataFromParentRuntime(className);
00598         }
00599 
00600         ArrayList<Object> params = new ArrayList<Object>();
00601         params.add(className);
00602 
00603         RuntimeRequest req = new RuntimeRequest("getClassDataFromParentRuntime",
00604                 params, this.url);
00605         req.send();
00606 
00607         try {
00608             return (byte[]) req.getReturnedObject();
00609         } catch (Exception e) {
00610             throw new ProActiveException(e);
00611         }
00612     }
00613 
00614     public byte[] getClassDataFromThisRuntime(String className)
00615         throws ProActiveException, HTTPRemoteException {
00616         if (isLocal) {
00617             return localruntime.getClassDataFromThisRuntime(className);
00618         }
00619 
00620         ArrayList<Object> params = new ArrayList<Object>();
00621         params.add(className);
00622 
00623         RuntimeRequest req = new RuntimeRequest("getClassDataFromThisRuntime",
00624                 params, this.url);
00625         req.send();
00626 
00627         try {
00628             return (byte[]) req.getReturnedObject();
00629         } catch (Exception e) {
00630             e.printStackTrace();
00631 
00632             return null;
00633         }
00634     }
00635 
00636     
00637 
00638 
00639     public UniversalBody receiveCheckpoint(String nodeURL, Checkpoint ckpt,
00640         int inc) throws ProActiveException, HTTPRemoteException {
00641         if (isLocal) {
00642             return localruntime.receiveCheckpoint(nodeURL, ckpt, inc);
00643         }
00644 
00645         ArrayList<Object> params = new ArrayList<Object>();
00646         params.add(nodeURL);
00647         params.add(ckpt);
00648         params.add(new Integer(inc));
00649 
00650         RuntimeRequest req = new RuntimeRequest("receiveCheckpoint", params,
00651                 this.url);
00652         req.send();
00653 
00654         try {
00655             return (UniversalBody) req.getReturnedObject();
00656         } catch (Exception e) {
00657             throw new ProActiveException(e);
00658         }
00659     }
00660 
00661     public ProActiveDescriptor getDescriptor(String url,
00662         boolean isHierarchicalSearch) throws IOException, ProActiveException {
00663         if (isLocal) {
00664             return localruntime.getDescriptor(url, isHierarchicalSearch);
00665         }
00666 
00667         ArrayList<Object> params = new ArrayList<Object>();
00668         params.add(url);
00669         params.add(new Boolean(isHierarchicalSearch));
00670 
00671         RuntimeRequest req = new RuntimeRequest("getDescriptor", params,
00672                 this.url);
00673         req.send();
00674 
00675         try {
00676             return (ProActiveDescriptor) req.getReturnedObject();
00677         } catch (Exception e) {
00678             throw new ProActiveException(e);
00679         }
00680     }
00681 
00682     public void launchMain(String className, String[] parameters)
00683         throws IOException, ClassNotFoundException, NoSuchMethodException,
00684             ProActiveException {
00685         if (isLocal) {
00686             localruntime.launchMain(className, parameters);
00687 
00688             return;
00689         }
00690 
00691         ArrayList<Object> params = new ArrayList<Object>();
00692         params.add(className);
00693         params.add(parameters);
00694 
00695         RuntimeRequest req = new RuntimeRequest("launchMain", params, this.url);
00696         req.send();
00697     }
00698 
00699     public void newRemote(String className)
00700         throws IOException, ClassNotFoundException, ProActiveException {
00701         if (isLocal) {
00702             localruntime.newRemote(className);
00703 
00704             return;
00705         }
00706 
00707         ArrayList<Object> params = new ArrayList<Object>();
00708         params.add(className);
00709 
00710         RuntimeRequest req = new RuntimeRequest("newRemote", params, this.url);
00711         req.send();
00712     }
00713 
00714     protected String buildNodeURL(String url)
00715         throws java.net.UnknownHostException {
00716         int i = url.indexOf('/');
00717 
00718         if (i != -1) {
00719             URL u_ = null;
00720             int port = 0;
00721             try {
00722                 u_ = new URL(url);
00723                 port = u_.getPort();
00724                 if ((port == 0) || (port == -1)) {
00725                     port = ClassServer.getServerSocketPort();
00726                     url = u_.getProtocol() + "://" + u_.getHost() + ":" + port +
00727                         u_.getPath();
00728                 }
00729             } catch (MalformedURLException e) {
00730             }
00731         } else {
00732             String host = null;
00733             try {
00734                 host = UrlBuilder.getHostNameorIP(getVMInformation()
00735                                                       .getInetAddress());
00736             } catch (HTTPRemoteException e) {
00737                 e.printStackTrace();
00738             }
00739             
00740             url = "http://" + host + ":" + ClassServer.getServerSocketPort() +
00741                 "/" + url;
00742             
00743             
00744             
00745             
00746             
00747             
00748             
00749             
00750             
00751         }
00752 
00753         
00754         
00755         
00756         
00757         
00758         
00759         
00760         
00761         
00762         
00763         url = UrlBuilder.checkUrl(url);
00764         return url;
00765     }
00766 
00767     private void readObject(java.io.ObjectInputStream in)
00768         throws IOException, ClassNotFoundException {
00769         in.defaultReadObject();
00770         this.isLocal = false;
00771     }
00772 
00773     public String getVNName(String nodename)
00774         throws ProActiveException, HTTPRemoteException {
00775         if (isLocal) {
00776             return localruntime.getVNName(nodename);
00777         }
00778 
00779         ArrayList<Object> params = new ArrayList<Object>();
00780         params.add(nodename);
00781 
00782         RuntimeRequest req = new RuntimeRequest("getVNName", params, this.url);
00783         req.send();
00784 
00785         try {
00786             return (String) req.getReturnedObject();
00787         } catch (Exception e) {
00788             throw new ProActiveException(e);
00789         }
00790     }
00791 
00792     public X509Certificate getCertificate()
00793         throws SecurityNotAvailableException, IOException {
00794         if (isLocal) {
00795             return localruntime.getCertificate();
00796         }
00797 
00798         ArrayList<Object> params = new ArrayList<Object>();
00799 
00800         RuntimeRequest req = new RuntimeRequest("getCertificate", params,
00801                 this.url);
00802         req.send();
00803 
00804         try {
00805             return (X509Certificate) req.getReturnedObject();
00806         } catch (SecurityException e) {
00807             throw e;
00808         } catch (IOException e) {
00809             throw e;
00810         } catch (Exception e) {
00811             e.printStackTrace();
00812 
00813             return null;
00814         }
00815     }
00816 
00817     public long startNewSession(Communication policy)
00818         throws SecurityNotAvailableException, RenegotiateSessionException,
00819             IOException {
00820         if (isLocal) {
00821             return localruntime.startNewSession(policy);
00822         }
00823 
00824         ArrayList<Object> params = new ArrayList<Object>();
00825         params.add(policy);
00826 
00827         RuntimeRequest req = new RuntimeRequest("startNewSession", params,
00828                 this.url);
00829 
00830         req.send();
00831 
00832         try {
00833             return ((Long) req.getReturnedObject()).longValue();
00834         } catch (SecurityException e) {
00835             throw e;
00836         } catch (IOException e) {
00837             throw e;
00838         } catch (Exception e) {
00839             e.printStackTrace();
00840 
00841             return 0;
00842         }
00843     }
00844 
00845     public PublicKey getPublicKey()
00846         throws SecurityNotAvailableException, IOException {
00847         if (isLocal) {
00848             return localruntime.getPublicKey();
00849         }
00850 
00851         ArrayList<Object> params = new ArrayList<Object>();
00852 
00853         RuntimeRequest req = new RuntimeRequest("getPublicKey", params, this.url);
00854 
00855         req.send();
00856 
00857         try {
00858             return (PublicKey) req.getReturnedObject();
00859         } catch (SecurityException e) {
00860             throw e;
00861         } catch (IOException e) {
00862             throw e;
00863         } catch (Exception e) {
00864             e.printStackTrace();
00865 
00866             return null;
00867         }
00868     }
00869 
00870     public byte[] randomValue(long sessionID, byte[] clientRandomValue)
00871         throws SecurityNotAvailableException, RenegotiateSessionException,
00872             IOException {
00873         if (isLocal) {
00874             return localruntime.randomValue(sessionID, clientRandomValue);
00875         }
00876 
00877         ArrayList<Object> params = new ArrayList<Object>();
00878         params.add(new Long(sessionID));
00879         params.add(clientRandomValue);
00880 
00881         RuntimeRequest req = new RuntimeRequest("randomValue", params, this.url);
00882 
00883         req.send();
00884 
00885         try {
00886             return (byte[]) req.getReturnedObject();
00887         } catch (SecurityException e) {
00888             throw e;
00889         } catch (IOException e) {
00890             throw e;
00891         } catch (Exception e) {
00892             e.printStackTrace();
00893 
00894             return null;
00895         }
00896     }
00897 
00898     public byte[][] publicKeyExchange(long sessionID, byte[] myPublicKey,
00899         byte[] myCertificate, byte[] signature)
00900         throws SecurityNotAvailableException, RenegotiateSessionException,
00901             KeyExchangeException, IOException {
00902         if (isLocal) {
00903             return localruntime.publicKeyExchange(sessionID, myPublicKey,
00904                 myCertificate, signature);
00905         }
00906 
00907         ArrayList<Object> params = new ArrayList<Object>();
00908         params.add(new Long(sessionID));
00909         params.add(myPublicKey);
00910         params.add(myCertificate);
00911         params.add(signature);
00912 
00913         RuntimeRequest req = new RuntimeRequest("publicKeyExchange", params,
00914                 this.url);
00915 
00916         req.send();
00917 
00918         try {
00919             return (byte[][]) req.getReturnedObject();
00920         } catch (SecurityException e) {
00921             throw e;
00922         } catch (IOException e) {
00923             throw e;
00924         } catch (Exception e) {
00925             e.printStackTrace();
00926 
00927             return null;
00928         }
00929     }
00930 
00931     public byte[][] secretKeyExchange(long sessionID, byte[] encodedAESKey,
00932         byte[] encodedIVParameters, byte[] encodedClientMacKey,
00933         byte[] encodedLockData, byte[] parametersSignature)
00934         throws SecurityNotAvailableException, RenegotiateSessionException,
00935             IOException {
00936         if (isLocal) {
00937             return localruntime.secretKeyExchange(sessionID, encodedAESKey,
00938                 encodedIVParameters, encodedClientMacKey, encodedLockData,
00939                 parametersSignature);
00940         }
00941 
00942         ArrayList<Object> params = new ArrayList<Object>();
00943         params.add(new Long(sessionID));
00944         params.add(encodedAESKey);
00945         params.add(encodedIVParameters);
00946         params.add(encodedClientMacKey);
00947         params.add(encodedLockData);
00948         params.add(parametersSignature);
00949 
00950         RuntimeRequest req = new RuntimeRequest("secretKeyExchange", params,
00951                 this.url);
00952 
00953         req.send();
00954 
00955         try {
00956             return (byte[][]) req.getReturnedObject();
00957         } catch (SecurityException e) {
00958             throw e;
00959         } catch (RenegotiateSessionException e) {
00960             throw e;
00961         } catch (IOException e) {
00962             throw e;
00963         } catch (Exception e) {
00964             e.printStackTrace();
00965 
00966             return null;
00967         }
00968     }
00969 
00970     public SecurityContext getPolicy(SecurityContext securityContext)
00971         throws SecurityNotAvailableException, IOException {
00972         if (isLocal) {
00973             return localruntime.getPolicy(securityContext);
00974         }
00975 
00976         ArrayList<Object> params = new ArrayList<Object>();
00977         params.add(securityContext);
00978 
00979         RuntimeRequest req = new RuntimeRequest("getPolicy", params, this.url);
00980 
00981         req.send();
00982 
00983         try {
00984             return (SecurityContext) req.getReturnedObject();
00985         } catch (SecurityNotAvailableException e) {
00986             throw e;
00987         } catch (IOException e) {
00988             throw e;
00989         } catch (Exception e) {
00990             e.printStackTrace();
00991 
00992             return null;
00993         }
00994     }
00995 
00996     public byte[] getCertificateEncoded()
00997         throws SecurityNotAvailableException, IOException {
00998         if (isLocal) {
00999             return localruntime.getCertificateEncoded();
01000         }
01001 
01002         ArrayList<Object> params = new ArrayList<Object>();
01003 
01004         RuntimeRequest req = new RuntimeRequest("getCertificateEncoded",
01005                 params, this.url);
01006 
01007         req.send();
01008 
01009         try {
01010             return (byte[]) req.getReturnedObject();
01011         } catch (SecurityException e) {
01012             throw e;
01013         } catch (IOException e) {
01014             throw e;
01015         } catch (Exception e) {
01016             e.printStackTrace();
01017 
01018             return null;
01019         }
01020     }
01021 
01022     public ArrayList<Entity> getEntities()
01023         throws SecurityNotAvailableException, IOException {
01024         if (isLocal) {
01025             return localruntime.getEntities();
01026         }
01027 
01028         ArrayList<Object> params = new ArrayList<Object>();
01029 
01030         RuntimeRequest req = new RuntimeRequest("getEntities", params, this.url);
01031 
01032         req.send();
01033 
01034         try {
01035             return (ArrayList<Entity>) req.getReturnedObject();
01036         } catch (SecurityException e) {
01037             throw e;
01038         } catch (IOException e) {
01039             throw e;
01040         } catch (Exception e) {
01041             e.printStackTrace();
01042 
01043             return null;
01044         }
01045     }
01046 
01047     public void terminateSession(long sessionID)
01048         throws IOException, SecurityNotAvailableException {
01049         if (isLocal) {
01050             localruntime.terminateSession(sessionID);
01051         }
01052 
01053         ArrayList<Object> params = new ArrayList<Object>();
01054         params.add(new Long(sessionID));
01055 
01056         RuntimeRequest req = new RuntimeRequest("terminateSession", params,
01057                 this.url);
01058 
01059         req.send();
01060 
01061         try {
01062             req.getReturnedObject();
01063         } catch (SecurityException e) {
01064             throw e;
01065         } catch (IOException e) {
01066             throw e;
01067         } catch (Exception e) {
01068             e.printStackTrace();
01069         }
01070     }
01071 
01072     public Object setLocalNodeProperty(String nodeName, String key, String value)
01073         throws IOException, ProActiveException {
01074         if (isLocal) {
01075             return localruntime.setLocalNodeProperty(nodeName, key, value);
01076         }
01077 
01078         ArrayList<Object> params = new ArrayList<Object>();
01079         params.add(nodeName);
01080         params.add(key);
01081         params.add(value);
01082 
01083         RuntimeRequest req = new RuntimeRequest("setLocalNodeProperty", params,
01084                 this.url);
01085 
01086         req.send();
01087 
01088         try {
01089             return (Object) req.getReturnedObject();
01090         } catch (SecurityException e) {
01091             throw e;
01092         } catch (IOException e) {
01093             throw e;
01094         } catch (Exception e) {
01095             e.printStackTrace();
01096 
01097             return null;
01098         }
01099     }
01100 
01101     public String getLocalNodeProperty(String nodeName, String key)
01102         throws IOException, ProActiveException {
01103         if (isLocal) {
01104             return localruntime.getLocalNodeProperty(nodeName, key);
01105         }
01106 
01107         ArrayList<Object> params = new ArrayList<Object>();
01108         params.add(nodeName);
01109         params.add(key);
01110 
01111         RuntimeRequest req = new RuntimeRequest("getLocalNodeProperty", params,
01112                 this.url);
01113 
01114         req.send();
01115 
01116         try {
01117             return (String) req.getReturnedObject();
01118         } catch (SecurityException e) {
01119             throw e;
01120         } catch (IOException e) {
01121             throw e;
01122         } catch (Exception e) {
01123             e.printStackTrace();
01124 
01125             return null;
01126         }
01127     }
01128 }