• 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/Get.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.bouncycastle.util.io.Streams;
9
import org.pgpainless.PGPainless;
10
import org.slf4j.Logger;
11
import org.slf4j.LoggerFactory;
12
import pgp.cert_d.SpecialNames;
13
import pgp.cert_d.cli.PGPCertDCli;
14
import pgp.certificate_store.certificate.KeyMaterial;
15
import pgp.certificate_store.exception.BadDataException;
16
import pgp.certificate_store.exception.BadNameException;
17
import picocli.CommandLine;
18

19
import java.io.IOException;
20
import java.util.NoSuchElementException;
21

22
@CommandLine.Command(name = "get",
23
        resourceBundle = "msg_get")
24
public class Get implements Runnable {
×
25

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

28
    // https://www.cyberciti.biz/faq/linux-bash-exit-status-set-exit-statusin-bash/
29
    public static final int EXIT_CODE_NO_SUCH_ELEMENT = 2;
30
    public static final int EXIT_CODE_IO_ERROR = 5;
31

32
    @CommandLine.Option(names = {"-a", "--armor"})
×
33
    boolean armor = false;
34

35
    @CommandLine.Parameters(
36
            paramLabel = "IDENTIFIER",
37
            arity = "1"
38
    )
39
    String identifier;
40

41
    @Override
42
    public void run() {
43
        try {
44
            KeyMaterial record;
45
            if (SpecialNames.lookupSpecialName(identifier) != null) {
×
46
                record = PGPCertDCli.getCertificateDirectory().getBySpecialName(identifier);
×
47
            } else {
48
                record = PGPCertDCli.getCertificateDirectory().getByFingerprint(identifier.toLowerCase());
×
49
            }
50
            if (record == null) {
×
51
                return;
×
52
            }
53

54
            if (armor) {
×
NEW
55
                OpenPGPCertificate certOrKey = PGPainless.getInstance().readKey().parseCertificateOrKey(record.getInputStream());
×
56
                // CHECKSTYLE:OFF
NEW
57
                System.out.println(certOrKey.toAsciiArmoredString());
×
58
                // CHECKSTYLE:ON
59
            } else {
×
60
                Streams.pipeAll(record.getInputStream(), System.out);
×
61
            }
62

63
        } catch (NoSuchElementException e) {
×
64
            LOGGER.debug("Certificate not found.", e);
×
65
            System.exit(EXIT_CODE_NO_SUCH_ELEMENT);
×
66
        } catch (IOException e) {
×
67
            LOGGER.error("IO Error", e);
×
68
            System.exit(EXIT_CODE_IO_ERROR);
×
69
        } catch (BadDataException e) {
×
70
            LOGGER.error("Certificate file contains bad data.", e);
×
71
            System.exit(-1);
×
72
        } catch (BadNameException e) {
×
73
            LOGGER.error("Certificate fingerprint mismatch.", e);
×
74
            System.exit(-1);
×
75
        }
×
76
    }
×
77
}
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