1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-01-08 19:27:57 +01:00

Remove unused BCUtil.publicKeyRingFromSecretKeyRing method

Use KeyRingUtils.publicKeyRingFrom(secertKeys) instead
This commit is contained in:
Paul Schaub 2021-01-21 14:33:52 +01:00
parent 74c0c8a32e
commit bd9a580600
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 5 additions and 19 deletions

View file

@ -64,20 +64,6 @@ public class BCUtil {
return new PGPSecretKeyRingCollection(Arrays.asList(rings));
}
public static PGPPublicKeyRing publicKeyRingFromSecretKeyRing(@Nonnull PGPSecretKeyRing secretKeys)
throws PGPException, IOException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(512);
for (PGPSecretKey secretKey : secretKeys) {
PGPPublicKey publicKey = secretKey.getPublicKey();
if (publicKey != null) {
publicKey.encode(buffer, false);
}
}
KeyFingerPrintCalculator fingerprintCalculator = ImplementationFactory.getInstance().getKeyFingerprintCalculator();
return new PGPPublicKeyRing(buffer.toByteArray(), fingerprintCalculator);
}
/*
PGPXxxKeyRingCollection -> PGPXxxKeyRing
*/

View file

@ -15,19 +15,19 @@
*/
package org.pgpainless.sop.commands;
import static org.pgpainless.sop.Print.err_ln;
import static org.pgpainless.sop.Print.print_ln;
import java.io.IOException;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.pgpainless.PGPainless;
import org.pgpainless.key.util.KeyRingUtils;
import org.pgpainless.sop.Print;
import org.pgpainless.util.BCUtil;
import picocli.CommandLine;
import static org.pgpainless.sop.Print.err_ln;
import static org.pgpainless.sop.Print.print_ln;
@CommandLine.Command(name = "extract-cert",
description = "Extract a public key certificate from a secret key from standard input")
public class ExtractCert implements Runnable {
@ -41,7 +41,7 @@ public class ExtractCert implements Runnable {
public void run() {
try {
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(System.in);
PGPPublicKeyRing publicKeys = BCUtil.publicKeyRingFromSecretKeyRing(secretKeys);
PGPPublicKeyRing publicKeys = KeyRingUtils.publicKeyRingFrom(secretKeys);
print_ln(Print.toString(publicKeys.getEncoded(), armor));
} catch (IOException | PGPException e) {