1 7 8 package java.security; 9 10 import java.io.Serializable ; 11 import java.security.cert.CertPath ; 12 import java.security.cert.X509Extension ; 13 import java.util.Date ; 14 15 25 26 public final class Timestamp implements Serializable { 27 28 private static final long serialVersionUID = -5502683707821851294L; 29 30 35 private Date timestamp; 36 37 42 private CertPath signerCertPath; 43 44 47 private transient int myhash = -1; 48 49 56 public Timestamp(Date timestamp, CertPath signerCertPath) { 57 if (timestamp == null || signerCertPath == null) { 58 throw new NullPointerException (); 59 } 60 this.timestamp = new Date (timestamp.getTime()); this.signerCertPath = signerCertPath; 62 } 63 64 69 public Date getTimestamp() { 70 return new Date (timestamp.getTime()); } 72 73 78 public CertPath getSignerCertPath() { 79 return signerCertPath; 80 } 81 82 89 public int hashCode() { 90 if (myhash == -1) { 91 myhash = timestamp.hashCode() + signerCertPath.hashCode(); 92 } 93 return myhash; 94 } 95 96 105 public boolean equals(Object obj) { 106 if (obj == null || (!(obj instanceof Timestamp ))) { 107 return false; 108 } 109 Timestamp that = (Timestamp )obj; 110 111 if (this == that) { 112 return true; 113 } 114 return (timestamp.equals(that.getTimestamp()) && 115 signerCertPath.equals(that.getSignerCertPath())); 116 } 117 118 124 public String toString() { 125 StringBuffer sb = new StringBuffer (); 126 sb.append("("); 127 sb.append("timestamp: " + timestamp); 128 sb.append("TSA: " + signerCertPath.getCertificates().get(0)); 129 sb.append(")"); 130 return sb.toString(); 131 } 132 } 133 | Popular Tags |