1 9 package org.objectweb.proactive.ext.mixedlocation; 10 11 import java.io.IOException ; 12 import java.security.PublicKey ; 13 import java.security.cert.X509Certificate ; 14 import java.util.ArrayList ; 15 16 import org.objectweb.proactive.core.UniqueID; 17 import org.objectweb.proactive.core.body.UniversalBody; 18 import org.objectweb.proactive.core.body.reply.Reply; 19 import org.objectweb.proactive.core.body.request.Request; 20 import org.objectweb.proactive.ext.security.Communication; 21 import org.objectweb.proactive.ext.security.CommunicationForbiddenException; 22 import org.objectweb.proactive.ext.security.Policy; 23 import org.objectweb.proactive.ext.security.ProActiveSecurityManager; 24 import org.objectweb.proactive.ext.security.RenegotiateSessionException; 25 import org.objectweb.proactive.ext.security.SecurityContext; 26 import org.objectweb.proactive.ext.security.SecurityNotAvailableException; 27 import org.objectweb.proactive.ext.security.crypto.AuthenticationException; 28 import org.objectweb.proactive.ext.security.crypto.ConfidentialityTicket; 29 import org.objectweb.proactive.ext.security.crypto.KeyExchangeException; 30 31 32 public class UniversalBodyWrapper implements UniversalBody, Runnable { 33 protected UniversalBody wrappedBody; 34 protected long time; 35 protected UniqueID id; 36 protected boolean stop; 37 protected long creationTime; 38 39 41 46 public UniversalBodyWrapper(UniversalBody body, long time) { 47 this.wrappedBody = body; 48 this.time = time; 49 this.creationTime = System.currentTimeMillis(); 50 this.id = this.wrappedBody.getID(); 52 53 } 55 56 public void receiveRequest(Request request) throws IOException , RenegotiateSessionException { 57 if (this.wrappedBody == null) { 59 throw new IOException (); 60 } 61 62 if (System.currentTimeMillis() > (this.creationTime + this.time)) { 64 throw new IOException (); 69 } else { 70 try { 71 this.wrappedBody.receiveRequest(request); 72 } catch (IOException e) { 73 e.printStackTrace(); 74 throw e; 75 } 76 } 77 78 } 80 81 public void receiveReply(Reply r) throws IOException { 82 this.wrappedBody.receiveReply(r); 83 } 84 85 public String getNodeURL() { 86 return this.wrappedBody.getNodeURL(); 87 } 88 89 public UniqueID getID() { 90 return this.id; 91 } 92 93 public void updateLocation(UniqueID id, UniversalBody body) 94 throws IOException { 95 this.wrappedBody.updateLocation(id, body); 96 } 97 98 public UniversalBody getRemoteAdapter() { 99 return this.wrappedBody.getRemoteAdapter(); 100 } 101 102 public void enableAC() throws java.io.IOException { 103 this.wrappedBody.enableAC(); 104 } 105 106 public void disableAC() throws java.io.IOException { 107 this.wrappedBody.disableAC(); 108 } 109 110 public void setImmediateService(String methodName) 111 throws java.io.IOException { 112 this.wrappedBody.setImmediateService(methodName); 113 } 114 115 protected void updateServer() { 116 } 125 126 public void run() { 142 try { 144 } catch (Exception e) { 147 e.printStackTrace(); 148 } 149 150 this.updateServer(); 152 this.wrappedBody = null; 153 System.gc(); 154 } 155 156 public void initiateSession(int type,UniversalBody body) 158 throws java.io.IOException , CommunicationForbiddenException, 159 AuthenticationException, RenegotiateSessionException, 160 SecurityNotAvailableException { 161 wrappedBody.initiateSession(type,body); 162 } 163 164 public void terminateSession(long sessionID) 165 throws java.io.IOException , SecurityNotAvailableException { 166 wrappedBody.terminateSession(sessionID); 167 } 168 169 public X509Certificate getCertificate() 170 throws java.io.IOException , SecurityNotAvailableException { 171 return wrappedBody.getCertificate(); 172 } 173 174 public ProActiveSecurityManager getProActiveSecurityManager() 175 throws java.io.IOException , SecurityNotAvailableException { 176 return wrappedBody.getProActiveSecurityManager(); 177 } 178 179 public Policy getPolicyFrom(X509Certificate certificate) 180 throws java.io.IOException , SecurityNotAvailableException { 181 return wrappedBody.getPolicyFrom(certificate); 182 } 183 184 public long startNewSession(Communication policy) 185 throws java.io.IOException , RenegotiateSessionException, 186 SecurityNotAvailableException { 187 return wrappedBody.startNewSession(policy); 188 } 189 190 public ConfidentialityTicket negociateKeyReceiverSide( 191 ConfidentialityTicket confidentialityTicket, long sessionID) 192 throws java.io.IOException , KeyExchangeException, 193 SecurityNotAvailableException { 194 return wrappedBody.negociateKeyReceiverSide(confidentialityTicket, 195 sessionID); 196 } 197 198 public PublicKey getPublicKey() 199 throws java.io.IOException , SecurityNotAvailableException { 200 return wrappedBody.getPublicKey(); 201 } 202 203 public byte[] randomValue(long sessionID, byte[] cl_rand) 204 throws Exception , SecurityNotAvailableException { 205 return wrappedBody.randomValue(sessionID, cl_rand); 206 } 207 208 public byte[][] publicKeyExchange(long sessionID, 209 UniversalBody distantBody, byte[] my_pub, byte[] my_cert, 210 byte[] sig_code) throws Exception , SecurityNotAvailableException { 211 return wrappedBody.publicKeyExchange(sessionID, distantBody, my_pub, 212 my_cert, sig_code); 213 } 214 215 public byte[][] secretKeyExchange(long sessionID, byte[] tmp, byte[] tmp1, 216 byte[] tmp2, byte[] tmp3, byte[] tmp4) 217 throws Exception , SecurityNotAvailableException { 218 return wrappedBody.secretKeyExchange(sessionID, tmp, tmp1, tmp2, tmp3, 219 tmp4); 220 } 221 222 225 public String getVNName() throws IOException , SecurityNotAvailableException { 226 return wrappedBody.getVNName(); 227 } 228 229 232 public byte[] getCertificateEncoded() 233 throws IOException , SecurityNotAvailableException { 234 return wrappedBody.getCertificateEncoded(); 235 } 236 237 240 public SecurityContext getPolicy(SecurityContext securityContext) 241 throws SecurityNotAvailableException, IOException { 242 return wrappedBody.getPolicy(securityContext); 243 } 244 245 public ArrayList getEntities() throws SecurityNotAvailableException, IOException { 246 return wrappedBody.getEntities(); 247 } 248 249 public Communication getPolicyTo(String vn, String from, String to) 250 throws java.io.IOException , SecurityNotAvailableException { 251 return this.wrappedBody.getPolicyTo(vn, from, to); 252 } 253 254 255 256 } 257 | Popular Tags |