mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-25 12:27:58 +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.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -198,6 +197,12 @@ public class WebOfTrust implements CertificateAuthority {
|
||||||
}
|
}
|
||||||
certsWithKey.add(cert);
|
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
|
// index synopses
|
||||||
Date expirationDate;
|
Date expirationDate;
|
||||||
try {
|
try {
|
||||||
|
@ -210,7 +215,7 @@ public class WebOfTrust implements CertificateAuthority {
|
||||||
new CertSynopsis(cert.getFingerprint(),
|
new CertSynopsis(cert.getFingerprint(),
|
||||||
expirationDate,
|
expirationDate,
|
||||||
revocationStateFromSignature(cert.getRevocationSelfSignature()),
|
revocationStateFromSignature(cert.getRevocationSelfSignature()),
|
||||||
new HashSet<>(cert.getValidUserIds())));
|
userIds));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,19 +4,20 @@
|
||||||
|
|
||||||
package org.pgpainless.wot.dijkstra.sq;
|
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.algorithm.RevocationState;
|
||||||
import org.pgpainless.key.OpenPgpFingerprint;
|
import org.pgpainless.key.OpenPgpFingerprint;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class CertSynopsis {
|
public class CertSynopsis {
|
||||||
|
|
||||||
private final OpenPgpFingerprint fingerprint;
|
private final OpenPgpFingerprint fingerprint;
|
||||||
private final Date expirationTime;
|
private final Date expirationTime;
|
||||||
private final RevocationState revocationState;
|
private final RevocationState revocationState;
|
||||||
private final Set<String> userIds;
|
private final Map<String, RevocationState> userIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link CertSynopsis}.
|
* Create a new {@link CertSynopsis}.
|
||||||
|
@ -29,7 +30,7 @@ public class CertSynopsis {
|
||||||
public CertSynopsis(OpenPgpFingerprint fingerprint,
|
public CertSynopsis(OpenPgpFingerprint fingerprint,
|
||||||
Date expirationTime,
|
Date expirationTime,
|
||||||
RevocationState revocationState,
|
RevocationState revocationState,
|
||||||
Set<String> userIds) {
|
Map<String, RevocationState> userIds) {
|
||||||
this.fingerprint = fingerprint;
|
this.fingerprint = fingerprint;
|
||||||
this.expirationTime = expirationTime;
|
this.expirationTime = expirationTime;
|
||||||
this.revocationState = revocationState;
|
this.revocationState = revocationState;
|
||||||
|
@ -68,12 +69,12 @@ public class CertSynopsis {
|
||||||
*
|
*
|
||||||
* @return user-ids
|
* @return user-ids
|
||||||
*/
|
*/
|
||||||
public Set<String> userIds() {
|
public Map<String, RevocationState> userIds() {
|
||||||
return new HashSet<>(userIds);
|
return new HashMap<>(userIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
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())
|
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();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue