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

pgpainless / cert-d-pgpainless / #1

27 Sep 2025 10:11AM UTC coverage: 46.875% (+0.3%) from 46.575%
#1

push

other

vanitasvitae
Upgrade build system and depdencies

1 of 13 new or added lines in 2 files covered. (7.69%)

3 existing lines in 1 file now uncovered.

135 of 288 relevant lines covered (46.88%)

0.47 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.PGPPublicKeyRing;
8
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
9
import org.pgpainless.PGPainless;
10
import org.pgpainless.key.OpenPgpFingerprint;
11
import org.slf4j.Logger;
12
import org.slf4j.LoggerFactory;
13
import org.pgpainless.certificate_store.MergeCallbacks;
14
import pgp.cert_d.cli.PGPCertDCli;
15
import pgp.certificate_store.certificate.Certificate;
16
import pgp.certificate_store.exception.BadDataException;
17
import picocli.CommandLine;
18

19
import java.io.ByteArrayInputStream;
20
import java.io.IOException;
21

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

UNCOV
26
    private static final Logger LOGGER = LoggerFactory.getLogger(Import.class);
×
27

28
    @Override
29
    public void run() {
30
        try {
UNCOV
31
            PGPPublicKeyRingCollection certificates = PGPainless.readKeyRing().publicKeyRingCollection(System.in);
×
32
            for (PGPPublicKeyRing cert : certificates) {
×
33
                ByteArrayInputStream certIn = new ByteArrayInputStream(cert.getEncoded());
×
34
                try {
NEW
35
                    Certificate certificate = PGPCertDCli.getCertificateDirectory()
×
NEW
36
                            .insert(certIn, MergeCallbacks.mergeWithExisting());
×
NEW
37
                    LOGGER.info(certificate.getFingerprint());
×
NEW
38
                } catch (BadDataException e) {
×
NEW
39
                    LOGGER.error("Certificate " + OpenPgpFingerprint.of(cert) + " contains bad data.", e);
×
NEW
40
                } catch (IOException e) {
×
NEW
41
                    LOGGER.error("IO error importing certificate " + OpenPgpFingerprint.of(cert), e);
×
NEW
42
                } catch (InterruptedException e) {
×
NEW
43
                    LOGGER.error("Thread interrupted while importing certificate " + OpenPgpFingerprint.of(cert), e);
×
NEW
44
                    System.exit(1);
×
NEW
45
                }
×
46
            }
×
47
        } catch (IOException e) {
×
48
            LOGGER.error("IO-Error.", e);
×
NEW
49
            System.exit(1);
×
50
        }
×
51
    }
×
52
}
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