View Javadoc
1 package jsdsi; 2 3 import java.net.URI; 4 5 import jsdsi.sexp.SexpList; 6 import jsdsi.sexp.SexpParseException; 7 8 /*** 9 * The cryptographic hash of a public key. 10 * 11 * @author Sameer Ajmani 12 * @author Sean Radford 13 * @version $Revision: 1.5.2.1 $ $Date: 2005/11/08 03:12:52 $ 14 */ 15 public class PublicKeyHash extends Principal { 16 17 private static final long serialVersionUID = -1085604011787649865L; 18 19 /*** 20 * The hash. 21 */ 22 private transient final Hash hash; 23 24 /*** 25 * Creates a new <code>PublicKeyHash</code>. 26 * 27 * @param h hash to create the <code>PublicKeyHash</code>. 28 */ 29 public PublicKeyHash(Hash h) { 30 assert(h != null) : "null hash"; 31 hash = h; 32 } 33 34 /*** 35 * @return the hash. 36 */ 37 public Hash getHash() { 38 return hash; 39 } 40 41 /*** 42 * @see jsdsi.Principal#getURIs() 43 */ 44 public URI[] getURIs() { 45 return hash.getURIs(); 46 } 47 48 /*** 49 * @see jsdsi.Principal#samePrincipalAs(Principal) 50 */ 51 public boolean samePrincipalAs(Principal p) { 52 if (p == null) { 53 return false; 54 } 55 if (p instanceof PublicKeyHash) { 56 return equals(p); 57 } 58 // p is a public key, so check that hashes match 59 Hash h = new Hash(hash.getDigest(), p, hash.getURIs()); 60 return hash.equals(h); 61 } 62 63 /*** 64 * @see java.lang.Object#equals(Object) 65 */ 66 public boolean equals(Object o) { 67 return (o instanceof PublicKeyHash) 68 && hash.equals(((PublicKeyHash) o).hash); 69 } 70 71 /*** 72 * @see java.lang.Object#hashCode() 73 */ 74 public int hashCode() { 75 return hash.hashCode(); 76 } 77 78 public SexpList toSexp() { 79 return getHash().toSexp(); 80 } 81 82 public static PublicKeyHash parsePublicKeyHash(SexpList l) 83 throws SexpParseException { 84 return new PublicKeyHash(Hash.parseHash(l)); 85 } 86 }

This page was automatically generated by Maven