• 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

37.5
/pgpainless-cert-d/src/main/java/org/pgpainless/certificate_store/KeyFactory.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.PGPPublicKeyRing;
9
import org.bouncycastle.openpgp.PGPSecretKeyRing;
10
import org.bouncycastle.openpgp.api.OpenPGPKey;
11
import org.pgpainless.PGPainless;
12
import pgp.certificate_store.certificate.Certificate;
13
import pgp.certificate_store.certificate.Key;
14

15
import java.io.IOException;
16

17
public class KeyFactory {
×
18

19
    /**
20
     * Create a {@link Key} from the given {@link PGPSecretKeyRing} and tag.
21
     *
22
     * @param secretKeyRing PGPSecretKeyRing
23
     * @param tag tag
24
     * @return key
25
     * @throws IOException if the key cannot be encoded
26
     *
27
     * @deprecated use {@link #keyFromOpenPGPKey(OpenPGPKey, Long)} instead.
28
     */
29
    @Deprecated
30
    public static Key keyFromSecretKeyRing(PGPSecretKeyRing secretKeyRing, Long tag) throws IOException {
UNCOV
31
        byte[] bytes = secretKeyRing.getEncoded();
×
UNCOV
32
        PGPPublicKeyRing publicKeyRing = PGPainless.extractCertificate(secretKeyRing);
×
UNCOV
33
        Certificate certificate = CertificateFactory.certificateFromPublicKeyRing(publicKeyRing, tag);
×
UNCOV
34
        return new Key(bytes, certificate, tag);
×
35
    }
36

37
    /**
38
     * Create a {@link Key} from the given {@link OpenPGPKey} and tag.
39
     *
40
     * @param key OpenPGP key
41
     * @param tag tag
42
     * @return key
43
     * @throws IOException if the key cannot be encoded
44
     */
45
    public static Key keyFromOpenPGPKey(OpenPGPKey key, Long tag) throws IOException {
46
        byte[] bytes = key.getEncoded(PacketFormat.ROUNDTRIP);
1✔
47
        Certificate certificate = CertificateFactory.certificateFromOpenPGPCertificate(key.toCertificate(), tag);
1✔
48
        return new Key(bytes, certificate, tag);
1✔
49
    }
50
}
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

© 2025 Coveralls, Inc