Backport: revoke-key command: Allow for multiple '--with-key-password' options

This commit is contained in:
Paul Schaub 2024-10-31 13:25:04 +01:00
parent 00925e6511
commit 84abace9af
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -11,6 +11,8 @@ import sop.exception.SOPGPException;
import sop.operation.RevokeKey; import sop.operation.RevokeKey;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@CommandLine.Command(name = "revoke-key", @CommandLine.Command(name = "revoke-key",
resourceBundle = "msg_revoke-key", resourceBundle = "msg_revoke-key",
@ -23,7 +25,7 @@ public class RevokeKeyCmd extends AbstractSopCmd {
@CommandLine.Option(names = "--with-key-password", @CommandLine.Option(names = "--with-key-password",
paramLabel = "PASSWORD") paramLabel = "PASSWORD")
String withKeyPassword; List<String> withKeyPassword = new ArrayList<>();
@Override @Override
public void run() { public void run() {
@ -36,8 +38,10 @@ public class RevokeKeyCmd extends AbstractSopCmd {
if (withKeyPassword != null) { if (withKeyPassword != null) {
try { try {
String password = stringFromInputStream(getInput(withKeyPassword)); for (String passwordFile : withKeyPassword) {
revokeKey.withKeyPassword(password); String password = stringFromInputStream(getInput(passwordFile));
revokeKey.withKeyPassword(password);
}
} catch (SOPGPException.UnsupportedOption e) { } catch (SOPGPException.UnsupportedOption e) {
String errorMsg = getMsg("sop.error.feature_support.option_not_supported", "--with-key-password"); String errorMsg = getMsg("sop.error.feature_support.option_not_supported", "--with-key-password");
throw new SOPGPException.UnsupportedOption(errorMsg, e); throw new SOPGPException.UnsupportedOption(errorMsg, e);