From 8b853267ff553e8ea4505e8c8576e848c177793a Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Tue, 9 Aug 2022 18:40:28 +0200 Subject: [PATCH] Fix get command to also be able to get by special name --- .../java/pgp/cert_d/cli/commands/Get.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pgpainless-cert-d-cli/src/main/java/pgp/cert_d/cli/commands/Get.java b/pgpainless-cert-d-cli/src/main/java/pgp/cert_d/cli/commands/Get.java index c5ce49b..94d907d 100644 --- a/pgpainless-cert-d-cli/src/main/java/pgp/cert_d/cli/commands/Get.java +++ b/pgpainless-cert-d-cli/src/main/java/pgp/cert_d/cli/commands/Get.java @@ -4,17 +4,18 @@ package pgp.cert_d.cli.commands; -import java.io.IOException; - import org.bouncycastle.util.io.Streams; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import pgp.cert_d.BadDataException; import pgp.cert_d.BadNameException; +import pgp.cert_d.SpecialNames; import pgp.cert_d.cli.PGPCertDCli; -import pgp.certificate.Certificate; +import pgp.certificate.KeyMaterial; import picocli.CommandLine; +import java.io.IOException; + @CommandLine.Command(name = "get", resourceBundle = "msg_get") public class Get implements Runnable { @@ -30,12 +31,16 @@ public class Get implements Runnable { @Override public void run() { try { - Certificate certificate = PGPCertDCli.getCertificateDirectory() - .getByFingerprint(identifer); - if (certificate == null) { + KeyMaterial record; + if (SpecialNames.lookupSpecialName(identifer) != null) { + record = PGPCertDCli.getCertificateDirectory().getBySpecialName(identifer); + } else { + record = PGPCertDCli.getCertificateDirectory().getByFingerprint(identifer); + } + if (record == null) { return; } - Streams.pipeAll(certificate.getInputStream(), System.out); + Streams.pipeAll(record.getInputStream(), System.out); } catch (IOException e) { LOGGER.error("IO Error", e); System.exit(-1);