mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-12 15:32:06 +01:00
CertSynopsis: Change userId set to map with revocation states
This commit is contained in:
parent
b06dea379c
commit
9f4b11174e
3 changed files with 19 additions and 13 deletions
|
@ -8,7 +8,6 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -198,6 +197,12 @@ public class WebOfTrust implements CertificateAuthority {
|
|||
}
|
||||
certsWithKey.add(cert);
|
||||
|
||||
Map<String, RevocationState> userIds = new HashMap<>();
|
||||
for (String userId : cert.getUserIds()) {
|
||||
RevocationState state = revocationStateFromSignature(cert.getUserIdRevocation(userId));
|
||||
userIds.put(userId, state);
|
||||
}
|
||||
|
||||
// index synopses
|
||||
Date expirationDate;
|
||||
try {
|
||||
|
@ -210,7 +215,7 @@ public class WebOfTrust implements CertificateAuthority {
|
|||
new CertSynopsis(cert.getFingerprint(),
|
||||
expirationDate,
|
||||
revocationStateFromSignature(cert.getRevocationSelfSignature()),
|
||||
new HashSet<>(cert.getValidUserIds())));
|
||||
userIds));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,19 +4,20 @@
|
|||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.pgpainless.algorithm.RevocationState;
|
||||
import org.pgpainless.key.OpenPgpFingerprint;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class CertSynopsis {
|
||||
|
||||
private final OpenPgpFingerprint fingerprint;
|
||||
private final Date expirationTime;
|
||||
private final RevocationState revocationState;
|
||||
private final Set<String> userIds;
|
||||
private final Map<String, RevocationState> userIds;
|
||||
|
||||
/**
|
||||
* Create a new {@link CertSynopsis}.
|
||||
|
@ -29,7 +30,7 @@ public class CertSynopsis {
|
|||
public CertSynopsis(OpenPgpFingerprint fingerprint,
|
||||
Date expirationTime,
|
||||
RevocationState revocationState,
|
||||
Set<String> userIds) {
|
||||
Map<String, RevocationState> userIds) {
|
||||
this.fingerprint = fingerprint;
|
||||
this.expirationTime = expirationTime;
|
||||
this.revocationState = revocationState;
|
||||
|
@ -68,12 +69,12 @@ public class CertSynopsis {
|
|||
*
|
||||
* @return user-ids
|
||||
*/
|
||||
public Set<String> userIds() {
|
||||
return new HashSet<>(userIds);
|
||||
public Map<String, RevocationState> userIds() {
|
||||
return new HashMap<>(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return fingerprint + (userIds.isEmpty() ? "" : "(" + userIds.iterator().next() + ")");
|
||||
return fingerprint + (userIds.isEmpty() ? "" : "(" + userIds.keySet().iterator().next() + ")");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,9 +140,9 @@ public class Certification {
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(issuer.getFingerprint()).append((issuer.userIds().isEmpty() ? " " : " (" + issuer.userIds().iterator().next() + ") "));
|
||||
sb.append(issuer.getFingerprint()).append((issuer.userIds().isEmpty() ? " " : " (" + issuer.userIds().keySet().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() + ")" : "");
|
||||
.append(userId.isEmpty() && !target.userIds().isEmpty() ? " (" + target.userIds().keySet().iterator().next() + ")" : "");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue