diff --git a/sop-java/src/main/java/sop/Verification.java b/sop-java/src/main/java/sop/Verification.java index 2047c3d..6ff63f6 100644 --- a/sop-java/src/main/java/sop/Verification.java +++ b/sop-java/src/main/java/sop/Verification.java @@ -20,6 +20,15 @@ public class Verification { this.signingCertFingerprint = signingCertFingerprint; } + public static Verification fromString(String toString) { + String[] split = toString.trim().split(" "); + if (split.length != 3) { + throw new IllegalArgumentException("Verification must be of the format 'UTC-DATE OpenPGPFingerprint OpenPGPFingerprint'"); + } + + return new Verification(UTCUtil.parseUTCDate(split[0]), split[1], split[2]); + } + /** * Return the signatures' creation time. * @@ -55,4 +64,24 @@ public class Verification { ' ' + getSigningCertFingerprint(); } + + @Override + public int hashCode() { + return toString().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (this == obj) { + return true; + } + if (!(obj instanceof Verification)) { + return false; + } + Verification other = (Verification) obj; + return toString().equals(other.toString()); + } }