mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 21:07:57 +01:00
Add Verification.fromString(string), equals(other) and hashCode()
This commit is contained in:
parent
dad75bb522
commit
137d2e7f85
1 changed files with 29 additions and 0 deletions
|
@ -20,6 +20,15 @@ public class Verification {
|
||||||
this.signingCertFingerprint = signingCertFingerprint;
|
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.
|
* Return the signatures' creation time.
|
||||||
*
|
*
|
||||||
|
@ -55,4 +64,24 @@ public class Verification {
|
||||||
' ' +
|
' ' +
|
||||||
getSigningCertFingerprint();
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue