• 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

92.86
/pgpainless-cert-d/src/main/java/org/pgpainless/certificate_store/KeyMaterialReader.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.openpgp.api.OpenPGPCertificate;
8
import org.bouncycastle.openpgp.api.OpenPGPKey;
9
import org.pgpainless.PGPainless;
10
import pgp.certificate_store.certificate.KeyMaterial;
11
import pgp.certificate_store.certificate.KeyMaterialReaderBackend;
12
import pgp.certificate_store.exception.BadDataException;
13

14
import java.io.EOFException;
15
import java.io.IOException;
16
import java.io.InputStream;
17

18
public class KeyMaterialReader implements KeyMaterialReaderBackend {
1✔
19

20
    @Override
21
    public KeyMaterial read(InputStream data, Long tag) throws IOException, BadDataException {
22
        OpenPGPCertificate keyOrCertificate;
23
        try {
24
            keyOrCertificate = PGPainless.getInstance()
1✔
25
                    .readKey()
1✔
26
                    .parseCertificateOrKey(data);
1✔
27
        } catch (EOFException e) {
1✔
28
            // TODO: Pass 'e' once cert-d-java is bumped to 0.2.4
29
            throw new BadDataException();
1✔
30
        } catch (IOException e) {
1✔
31
            if (e.getMessage().contains("Neither a certificate, nor secret key.")) {
1✔
32
                throw new BadDataException();
1✔
33
            }
NEW
34
            throw e;
×
35
        }
1✔
36

37
        if (keyOrCertificate.isSecretKey()) {
1✔
38
            return KeyFactory.keyFromOpenPGPKey((OpenPGPKey) keyOrCertificate, tag);
1✔
39
        } else {
40
            return CertificateFactory.certificateFromOpenPGPCertificate(keyOrCertificate, tag);
1✔
41
        }
42
    }
43
}
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