• 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

0.0
/pgpainless-cert-d-cli/src/main/java/pgp/cert_d/cli/commands/Import.java
1
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
2
//
3
// SPDX-License-Identifier: Apache-2.0
4

5
package pgp.cert_d.cli.commands;
6

7
import org.bouncycastle.openpgp.api.OpenPGPCertificate;
8
import org.pgpainless.PGPainless;
9
import org.slf4j.Logger;
10
import org.slf4j.LoggerFactory;
11
import org.pgpainless.certificate_store.MergeCallbacks;
12
import pgp.cert_d.cli.PGPCertDCli;
13
import pgp.certificate_store.certificate.Certificate;
14
import pgp.certificate_store.exception.BadDataException;
15
import picocli.CommandLine;
16

17
import java.io.ByteArrayInputStream;
18
import java.io.IOException;
19

20
@CommandLine.Command(name = "import",
21
        resourceBundle = "msg_import")
22
public class Import implements Runnable {
×
23

24
    private static final Logger LOGGER = LoggerFactory.getLogger(Import.class);
×
25

26
    @Override
27
    public void run() {
28
        try {
NEW
29
            java.util.List<OpenPGPCertificate> certsOrKeys = PGPainless.getInstance().readKey().parseKeysOrCertificates(System.in);
×
NEW
30
            for (OpenPGPCertificate toInsert : certsOrKeys) {
×
31
                try {
NEW
32
                    Certificate inserted = PGPCertDCli.getCertificateDirectory().insert(
×
NEW
33
                            new ByteArrayInputStream(toInsert.getEncoded()),
×
NEW
34
                            MergeCallbacks.mergeWithExisting());
×
NEW
35
                    LOGGER.info(inserted.getFingerprint());
×
36
                } catch (BadDataException e) {
×
NEW
37
                    LOGGER.error("Certificate " + toInsert.getKeyIdentifier() + " contains bad data.", e);
×
38
                } catch (IOException e) {
×
NEW
39
                    LOGGER.error("IO error importing certificate " + toInsert.getKeyIdentifier(), e);
×
40
                } catch (InterruptedException e) {
×
NEW
41
                    LOGGER.error("Thread interrupted while importing certificate " + toInsert.getKeyIdentifier(), e);
×
42
                    System.exit(1);
×
43
                }
×
44
            }
×
45
        } catch (IOException e) {
×
46
            LOGGER.error("IO-Error.", e);
×
47
            System.exit(1);
×
48
        }
×
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