1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-16 17:32:06 +01:00

A bit of documentation

This commit is contained in:
Paul Schaub 2023-06-24 17:06:31 +02:00
parent 8f5aca6af9
commit 0ee3f0ed9a
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -41,6 +41,18 @@ import org.slf4j.LoggerFactory;
import pgp.certificate_store.certificate.Certificate; import pgp.certificate_store.certificate.Certificate;
import pgp.certificate_store.exception.BadDataException; import pgp.certificate_store.exception.BadDataException;
/**
* Build a Web of Trust from a set of certificates.
* <p>
* The process of building a WoT is as follows:
* <ul>
* <li>Consume and synopsize all certificates as network nodes</li>
* <li>Iterate over cross-certificate signatures and perform signature verification</li>
* <li>Identify signatures as edges between nodes</li>
* </ul>
*
* @see <a href="https://sequoia-pgp.gitlab.io/sequoia-wot/">OpenPGP Web of Trust</a>
*/
public class WebOfTrust implements CertificateAuthority { public class WebOfTrust implements CertificateAuthority {
private static final Logger LOGGER = LoggerFactory.getLogger(WebOfTrust.class); private static final Logger LOGGER = LoggerFactory.getLogger(WebOfTrust.class);
@ -123,6 +135,7 @@ public class WebOfTrust implements CertificateAuthority {
Policy policy, Policy policy,
ReferenceTime referenceTime) { ReferenceTime referenceTime) {
// TODO: Move heavy lifting from NetworkBuilder constructor to buildNetwork()?
NetworkBuilder nb = new NetworkBuilder(validatedCertificates, policy, referenceTime); NetworkBuilder nb = new NetworkBuilder(validatedCertificates, policy, referenceTime);
return nb.buildNetwork(); return nb.buildNetwork();
} }
@ -299,11 +312,17 @@ public class WebOfTrust implements CertificateAuthority {
} }
} }
/**
* Return the constructed, initialized {@link Network}.
*
* @return finished network
*/
public Network buildNetwork() { public Network buildNetwork() {
return new Network(certSynopsisMap, edges, reverseEdges, referenceTime); return new Network(certSynopsisMap, edges, reverseEdges, referenceTime);
} }
} }
// Map signature to its revocation state
private static RevocationState revocationStateFromSignature(PGPSignature revocation) { private static RevocationState revocationStateFromSignature(PGPSignature revocation) {
if (revocation == null) { if (revocation == null) {
return RevocationState.notRevoked(); return RevocationState.notRevoked();
@ -318,6 +337,7 @@ public class WebOfTrust implements CertificateAuthority {
RevocationState.hardRevoked() : RevocationState.softRevoked(revocation.getCreationTime()); RevocationState.hardRevoked() : RevocationState.softRevoked(revocation.getCreationTime());
} }
// Java 8 is not supported on old Android
private static <K, V> V getOrDefault(Map<K, V> map, K key, Supplier<V> defaultValue) { private static <K, V> V getOrDefault(Map<K, V> map, K key, Supplier<V> defaultValue) {
V value = map.get(key); V value = map.get(key);
if (value == null) { if (value == null) {
@ -329,6 +349,7 @@ public class WebOfTrust implements CertificateAuthority {
@Override @Override
public boolean isAuthorized(PGPPublicKeyRing certificate, String userId) { public boolean isAuthorized(PGPPublicKeyRing certificate, String userId) {
// TODO: Heiko! Implement!
return false; return false;
} }