1 7 8 package java.security; 9 10 import java.io.Serializable ; 11 import java.security.cert.CertPath ; 12 13 21 22 public final class CodeSigner implements Serializable { 23 24 private static final long serialVersionUID = 6819288105193937581L; 25 26 31 private CertPath signerCertPath; 32 33 38 private Timestamp timestamp; 39 40 43 private transient int myhash = -1; 44 45 56 public CodeSigner(CertPath signerCertPath, Timestamp timestamp) { 57 if (signerCertPath == null) { 58 throw new NullPointerException (); 59 } 60 this.signerCertPath = signerCertPath; 61 this.timestamp = timestamp; 62 } 63 64 69 public CertPath getSignerCertPath() { 70 return signerCertPath; 71 } 72 73 78 public Timestamp getTimestamp() { 79 return timestamp; 80 } 81 82 89 public int hashCode() { 90 if (myhash == -1) { 91 if (timestamp == null) { 92 myhash = signerCertPath.hashCode(); 93 } else { 94 myhash = signerCertPath.hashCode() + timestamp.hashCode(); 95 } 96 } 97 return myhash; 98 } 99 100 110 public boolean equals(Object obj) { 111 if (obj == null || (!(obj instanceof CodeSigner ))) { 112 return false; 113 } 114 CodeSigner that = (CodeSigner )obj; 115 116 if (this == that) { 117 return true; 118 } 119 Timestamp thatTimestamp = that.getTimestamp(); 120 if (timestamp == null) { 121 if (thatTimestamp != null) { 122 return false; 123 } 124 } else { 125 if (thatTimestamp == null || 126 (! timestamp.equals(thatTimestamp))) { 127 return false; 128 } 129 } 130 return signerCertPath.equals(that.getSignerCertPath()); 131 } 132 133 139 public String toString() { 140 StringBuffer sb = new StringBuffer (); 141 sb.append("("); 142 sb.append("Signer: " + signerCertPath.getCertificates().get(0)); 143 if (timestamp != null) { 144 sb.append("timestamp: " + timestamp); 145 } 146 sb.append(")"); 147 return sb.toString(); 148 } 149 } 150 | Popular Tags |