mirror of
https://codeberg.org/PGPainless/cert-d-pgpainless.git
synced 2024-12-22 13:17:58 +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;
|
package pgp.cert_d.cli.commands;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.bouncycastle.util.io.Streams;
|
import org.bouncycastle.util.io.Streams;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import pgp.cert_d.BadDataException;
|
import pgp.cert_d.BadDataException;
|
||||||
import pgp.cert_d.BadNameException;
|
import pgp.cert_d.BadNameException;
|
||||||
|
import pgp.cert_d.SpecialNames;
|
||||||
import pgp.cert_d.cli.PGPCertDCli;
|
import pgp.cert_d.cli.PGPCertDCli;
|
||||||
import pgp.certificate.Certificate;
|
import pgp.certificate.KeyMaterial;
|
||||||
import picocli.CommandLine;
|
import picocli.CommandLine;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
@CommandLine.Command(name = "get",
|
@CommandLine.Command(name = "get",
|
||||||
resourceBundle = "msg_get")
|
resourceBundle = "msg_get")
|
||||||
public class Get implements Runnable {
|
public class Get implements Runnable {
|
||||||
|
@ -30,12 +31,16 @@ public class Get implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
Certificate certificate = PGPCertDCli.getCertificateDirectory()
|
KeyMaterial record;
|
||||||
.getByFingerprint(identifer);
|
if (SpecialNames.lookupSpecialName(identifer) != null) {
|
||||||
if (certificate == null) {
|
record = PGPCertDCli.getCertificateDirectory().getBySpecialName(identifer);
|
||||||
|
} else {
|
||||||
|
record = PGPCertDCli.getCertificateDirectory().getByFingerprint(identifer);
|
||||||
|
}
|
||||||
|
if (record == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Streams.pipeAll(certificate.getInputStream(), System.out);
|
Streams.pipeAll(record.getInputStream(), System.out);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("IO Error", e);
|
LOGGER.error("IO Error", e);
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
|
|
Loading…
Reference in a new issue