1 31 32 package org.objectweb.proactive.ext.security; 33 34 import java.io.IOException ; 35 import java.io.Serializable ; 36 import java.security.cert.CertificateEncodingException ; 37 import java.security.cert.X509Certificate ; 38 39 import org.apache.log4j.Logger; 40 41 47 public abstract class Entity implements Serializable { 48 protected static Logger logger = Logger.getLogger(Entity.class.getName()); 49 protected X509Certificate applicationCertificate; 50 protected X509Certificate certificate; 51 52 public X509Certificate getApplicationCertificate() { 53 return applicationCertificate; 54 } 55 56 public X509Certificate getCertificate(){ 57 return certificate; 58 } 59 public abstract String getName(); 60 public abstract boolean equals(Entity e); 61 62 private void writeObject(java.io.ObjectOutputStream out) 64 throws IOException { 65 out.defaultWriteObject(); 66 67 if (applicationCertificate != null ) { 68 69 try { 70 byte[] certE = applicationCertificate.getEncoded(); 71 out.writeInt(certE.length); 72 out.write(certE); 73 } catch (CertificateEncodingException e) { 74 e.printStackTrace(); 75 } catch (IOException e) { 76 e.printStackTrace(); 77 } 78 } else { 79 out.writeInt(0); 80 } 81 } 82 private void readObject(java.io.ObjectInputStream in) 83 throws IOException , ClassNotFoundException { 84 in.defaultReadObject(); 85 86 int i = in.readInt(); 87 if ( i != 0 ) { 88 89 byte[] certEncoded = new byte[i]; 90 in.read(certEncoded); 91 92 applicationCertificate = ProActiveSecurity.decodeCertificate(certEncoded); 93 } 94 } 95 96 } 97 | Popular Tags |