mirror of
https://codeberg.org/PGPainless/wkd-java.git
synced 2025-12-05 12:51:10 +01:00
Bump dependencies
Bump pgpainless-core to 2.0.0 Bump cert-d-java to 0.2.3 Bump cert-d-pgpainless to 0.2.3
This commit is contained in:
parent
b6643b4543
commit
483efe0412
5 changed files with 45 additions and 42 deletions
|
|
@ -5,11 +5,10 @@
|
|||
package pgp.wkd.cli;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.api.OpenPGPCertificate;
|
||||
import org.bouncycastle.openpgp.api.OpenPGPKey;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.certificate_store.CertificateFactory;
|
||||
import org.pgpainless.key.collection.PGPKeyRingCollection;
|
||||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
import pgp.certificate_store.certificate.Certificate;
|
||||
import pgp.wkd.CertificateAndUserIds;
|
||||
import pgp.wkd.discovery.CertificateParser;
|
||||
|
|
@ -18,20 +17,20 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PGPainlessCertificateParser implements CertificateParser {
|
||||
@Override
|
||||
public List<CertificateAndUserIds> read(InputStream inputStream) throws IOException {
|
||||
List<CertificateAndUserIds> certificatesAndUserIds = new ArrayList<>();
|
||||
try {
|
||||
PGPKeyRingCollection keyMaterial = PGPainless.readKeyRing().keyRingCollection(inputStream, true);
|
||||
if (keyMaterial.getPGPSecretKeyRingCollection().size() != 0) {
|
||||
List<OpenPGPCertificate> keyMaterial = PGPainless.getInstance().readKey().parseKeysOrCertificates(inputStream);
|
||||
if (keyMaterial.stream().anyMatch(it -> it instanceof OpenPGPKey)) {
|
||||
throw new PGPException("Secret key material encountered!");
|
||||
}
|
||||
for (PGPPublicKeyRing certificate : keyMaterial.getPgpPublicKeyRingCollection()) {
|
||||
KeyRingInfo info = PGPainless.inspectKeyRing(certificate);
|
||||
Certificate parsedCert = CertificateFactory.certificateFromPublicKeyRing(certificate, 0L);
|
||||
List<String> userIds = info.getValidAndExpiredUserIds();
|
||||
for (OpenPGPCertificate certificate : keyMaterial) {
|
||||
Certificate parsedCert = CertificateFactory.certificateFromOpenPGPCertificate(certificate, 0L);
|
||||
List<String> userIds = certificate.getValidUserIds().stream().map(OpenPGPCertificate.OpenPGPUserId::getUserId).collect(Collectors.toList());
|
||||
certificatesAndUserIds.add(new CertificateAndUserIds(parsedCert, userIds));
|
||||
}
|
||||
return certificatesAndUserIds;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue