Make Sign.withKeyPassword indirect data type

This commit is contained in:
Paul Schaub 2022-05-24 22:09:49 +02:00
parent de11c17967
commit 6438ebc59c
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -16,10 +16,12 @@ import picocli.CommandLine;
import sop.MicAlg;
import sop.ReadyWithResult;
import sop.SigningResult;
import sop.cli.picocli.FileUtil;
import sop.cli.picocli.Print;
import sop.cli.picocli.SopCLI;
import sop.enums.SignAs;
import sop.exception.SOPGPException;
import sop.operation.Decrypt;
import sop.operation.Sign;
@CommandLine.Command(name = "sign",
@ -27,6 +29,8 @@ import sop.operation.Sign;
exitCodeOnInvalidInput = 37)
public class SignCmd implements Runnable {
private static final String ERROR_UNSUPPORTED_OPTION = "Option '%s' is not supported.";
@CommandLine.Option(names = "--no-armor",
description = "ASCII armor the output",
negatable = true)
@ -74,8 +78,15 @@ public class SignCmd implements Runnable {
System.exit(19);
}
for (String password : withKeyPassword) {
for (String passwordFile : withKeyPassword) {
try {
String password = FileUtil.stringFromInputStream(FileUtil.getFileInputStream(passwordFile));
sign.withKeyPassword(password);
} catch (SOPGPException.UnsupportedOption unsupportedOption) {
throw new SOPGPException.UnsupportedOption(String.format(ERROR_UNSUPPORTED_OPTION, "--with-key-password"), unsupportedOption);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
for (File keyFile : secretKeyFile) {