1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-05 03:55:58 +01:00

Add toString() methods to WOT network classes

This commit is contained in:
Paul Schaub 2023-06-24 10:15:30 +02:00
parent c4f1bf1bc0
commit e1d3180e1e
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
5 changed files with 40 additions and 1 deletions

View file

@ -157,4 +157,9 @@ public class WebOfTrust implements CertificateAuthority {
public boolean isAuthorized(PGPPublicKeyRing certificate, String userId) {
return false;
}
@Override
public String toString() {
return network.toString();
}
}

View file

@ -71,4 +71,9 @@ public class CertSynopsis {
public Set<String> userIds() {
return new HashSet<>(userIds);
}
@Override
public String toString() {
return fingerprint + (userIds.isEmpty() ? "" : "(" + userIds.iterator().next() + ")");
}
}

View file

@ -166,4 +166,13 @@ public class Certification {
public RegexSet getRegexes() {
return regex;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(issuer.getFingerprint()).append((issuer.userIds().isEmpty() ? " " : " (" + issuer.userIds().iterator().next() + ") "));
sb.append(userId.isPresent() ? "certifies" : "delegates to").append(userId.isPresent() ? " [" + userId.get() + "] " : " ").append(target.getFingerprint())
.append(userId.isEmpty() && !target.userIds().isEmpty() ? " (" + target.userIds().iterator().next() + ")" : "");
return sb.toString();
}
}

View file

@ -110,4 +110,15 @@ public final class CertificationSet {
// TODO: Prevent duplicates, only keep newest timestamped sig?
certificationsForUserId.add(certification);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (Map.Entry<Optional<String>, List<Certification>> entry : certifications.entrySet()) {
for (Certification certification : entry.getValue()) {
sb.append(certification).append("\n");
}
}
return sb.toString();
}
}

View file

@ -58,4 +58,13 @@ public class Network {
return referenceTime;
}
}
public String toString() {
StringBuilder sb = new StringBuilder("Network with " + getNodes().size() + " nodes, " + getEdges().size() + " edges:\n");
for (OpenPgpFingerprint issuer : getNodes().keySet()) {
for (CertificationSet edge : getReverseEdges().get(issuer)) {
sb.append(edge);
}
}
return sb.toString();
}
}