mirror of
https://codeberg.org/PGPainless/cert-d-pgpainless.git
synced 2024-12-22 05:17:56 +01:00
Fix get command to also be able to get by special name
This commit is contained in:
parent
c7cdf4c353
commit
8b853267ff
1 changed files with 12 additions and 7 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue