mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 12:57:57 +01:00
Make Sign.withKeyPassword indirect data type
This commit is contained in:
parent
de11c17967
commit
6438ebc59c
1 changed files with 13 additions and 2 deletions
|
@ -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) {
|
||||
sign.withKeyPassword(password);
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue