SOP: Add support for key password in GenerateKeyCmd

This commit is contained in:
Paul Schaub 2022-05-24 21:49:40 +02:00
parent 580c3af350
commit 9016c9f428
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -28,6 +28,10 @@ public class GenerateKeyCmd implements Runnable {
@CommandLine.Parameters(description = "User-ID, eg. \"Alice <alice@example.com>\"") @CommandLine.Parameters(description = "User-ID, eg. \"Alice <alice@example.com>\"")
List<String> userId = new ArrayList<>(); List<String> userId = new ArrayList<>();
@CommandLine.Option(names = "--with-key-password",
description = "Password to protect the key")
String withKeyPassword;
@Override @Override
public void run() { public void run() {
GenerateKey generateKey = SopCLI.getSop().generateKey(); GenerateKey generateKey = SopCLI.getSop().generateKey();
@ -43,6 +47,10 @@ public class GenerateKeyCmd implements Runnable {
generateKey.noArmor(); generateKey.noArmor();
} }
if (withKeyPassword != null && !withKeyPassword.trim().isEmpty()) {
generateKey.withKeyPassword(withKeyPassword.trim());
}
try { try {
Ready ready = generateKey.generate(); Ready ready = generateKey.generate();
ready.writeTo(System.out); ready.writeTo(System.out);