• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pgpainless / cert-d-pgpainless / #3

29 Sep 2025 12:32PM UTC coverage: 42.053% (-4.8%) from 46.875%
#3

push

other

vanitasvitae
Bump PGPainless to 2.0.0, cert-d-java to 0.2.3

49 of 83 new or added lines in 7 files covered. (59.04%)

11 existing lines in 2 files now uncovered.

127 of 302 relevant lines covered (42.05%)

0.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

46.67
/pgpainless-cert-d/src/main/java/org/pgpainless/certificate_store/CertificateFactory.java
1
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
2
//
3
// SPDX-License-Identifier: Apache-2.0
4

5
package org.pgpainless.certificate_store;
6

7
import org.bouncycastle.bcpg.PacketFormat;
8
import org.bouncycastle.openpgp.PGPPublicKey;
9
import org.bouncycastle.openpgp.PGPPublicKeyRing;
10
import org.bouncycastle.openpgp.api.OpenPGPCertificate;
11
import org.pgpainless.key.OpenPgpFingerprint;
12
import pgp.certificate_store.certificate.Certificate;
13

14
import java.io.IOException;
15
import java.util.ArrayList;
16
import java.util.Iterator;
17
import java.util.List;
18
import java.util.stream.Collectors;
19

20
public class CertificateFactory {
×
21

22
    /**
23
     * Create a {@link Certificate} from the given {@link PGPPublicKeyRing} and tag.
24
     *
25
     * @param publicKeyRing PGPPublicKeyRing
26
     * @param tag tag
27
     * @return certificate
28
     * @throws IOException if the certificate cannot be encoded
29
     *
30
     * @deprecated use {@link #certificateFromOpenPGPCertificate(OpenPGPCertificate, Long)} instead.
31
     */
32
    @Deprecated
33
    public static Certificate certificateFromPublicKeyRing(PGPPublicKeyRing publicKeyRing, Long tag)
34
            throws IOException {
UNCOV
35
        byte[] bytes = publicKeyRing.getEncoded();
×
UNCOV
36
        String fingerprint = OpenPgpFingerprint.of(publicKeyRing).toString().toLowerCase();
×
UNCOV
37
        List<Long> subkeyIds = new ArrayList<>();
×
UNCOV
38
        Iterator<PGPPublicKey> keys = publicKeyRing.getPublicKeys();
×
UNCOV
39
        while (keys.hasNext()) {
×
UNCOV
40
            subkeyIds.add(keys.next().getKeyID());
×
41
        }
42

UNCOV
43
        return new Certificate(bytes, fingerprint, subkeyIds, tag);
×
44
    }
45

46
    /**
47
     * Create a {@link Certificate} from the given {@link OpenPGPCertificate} and tag.
48
     *
49
     * @param openPGPCertificate OpenPGPCertificate
50
     * @param tag tag
51
     * @return certificate
52
     * @throws IOException if the certificate cannot be encoded
53
     */
54
    public static Certificate certificateFromOpenPGPCertificate(OpenPGPCertificate openPGPCertificate, Long tag)
55
            throws IOException {
56
        byte[] bytes = openPGPCertificate.getEncoded(PacketFormat.ROUNDTRIP);
1✔
57
        String fingerprint = OpenPgpFingerprint.of(openPGPCertificate).getFingerprint().toLowerCase();
1✔
58
        List<Long> subkeyIds = openPGPCertificate.getValidKeys()
1✔
59
                .stream()
1✔
60
                .map(it -> it.getKeyIdentifier().getKeyId())
1✔
61
                .collect(Collectors.toList());
1✔
62
        return new Certificate(bytes, fingerprint, subkeyIds, tag);
1✔
63
    }
64
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc