From e065d99becfa68f5fdc2959d874bd421a793a098 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sun, 25 Jun 2023 20:17:28 +0200 Subject: [PATCH] Remove unnecessary fields from WebOfTrust class --- .../java/org/pgpainless/wot/WebOfTrust.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/pgpainless-wot/src/main/java/org/pgpainless/wot/WebOfTrust.java b/pgpainless-wot/src/main/java/org/pgpainless/wot/WebOfTrust.java index d668db83..6ff7b7d0 100644 --- a/pgpainless-wot/src/main/java/org/pgpainless/wot/WebOfTrust.java +++ b/pgpainless-wot/src/main/java/org/pgpainless/wot/WebOfTrust.java @@ -89,8 +89,9 @@ public class WebOfTrust implements CertificateAuthority { Optional optReferenceTime) { ReferenceTime referenceTime = optReferenceTime.isPresent() ? optReferenceTime.get() : ReferenceTime.now(); - Iterable validCerts = parseValidCertificates(certificates, policy, referenceTime.getTimestamp()); + List validCerts = parseValidCertificates(certificates, policy, referenceTime.getTimestamp()); + LOGGER.debug("Successfully parsed " + validCerts.size() + " certificates."); return fromValidCertificates( validCerts, policy, @@ -98,7 +99,7 @@ public class WebOfTrust implements CertificateAuthority { ); } - private static Iterable parseValidCertificates(Iterable certificates, Policy policy, Date referenceTime) { + private static List parseValidCertificates(Iterable certificates, Policy policy, Date referenceTime) { // Parse all certificates List validCerts = new ArrayList<>(); for (Certificate cert : certificates) { @@ -132,7 +133,7 @@ public class WebOfTrust implements CertificateAuthority { * @return network */ public static Network fromValidCertificates( - Iterable validatedCertificates, + List validatedCertificates, Policy policy, ReferenceTime referenceTime) { @@ -141,34 +142,38 @@ public class WebOfTrust implements CertificateAuthority { return nb.buildNetwork(); } + /** + * Class for building the {@link Network Flow network} from the given set of OpenPGP keys. + * + */ private static final class NetworkBuilder { - // Index structures + // certificates keyed by fingerprint private final Map byFingerprint = new HashMap<>(); + // certificates keyed by (sub-) key-id private final Map> byKeyId = new HashMap<>(); + // certificate synopses keyed by fingerprint private final Map certSynopsisMap = new HashMap<>(); - // Issuer -> Target, Signatures by an issuer + // Issuer -> Target, edges keyed by issuer private final Map> edges = new HashMap<>(); - // Target -> Issuer, Signatures on the target + // Target -> Issuer, edges keyed by target private final Map> reverseEdges = new HashMap<>(); - private final Iterable validatedCertificates; private final Policy policy; private final ReferenceTime referenceTime; - private NetworkBuilder(Iterable validatedCertificates, + private NetworkBuilder(List validatedCertificates, Policy policy, ReferenceTime referenceTime) { - this.validatedCertificates = validatedCertificates; this.policy = policy; this.referenceTime = referenceTime; - synopsizeCertificates(); - findEdges(); + synopsizeCertificates(validatedCertificates); + findEdges(validatedCertificates); } - private void synopsizeCertificates() { + private void synopsizeCertificates(List validatedCertificates) { for (KeyRingInfo cert : validatedCertificates) { synopsize(cert); } @@ -209,7 +214,7 @@ public class WebOfTrust implements CertificateAuthority { } - private void findEdges() { + private void findEdges(List validatedCertificates) { // Identify certifications and delegations // Target = cert carrying a signature for (KeyRingInfo validatedTarget : validatedCertificates) {