mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-11-22 23:22:05 +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.MicAlg;
|
||||||
import sop.ReadyWithResult;
|
import sop.ReadyWithResult;
|
||||||
import sop.SigningResult;
|
import sop.SigningResult;
|
||||||
|
import sop.cli.picocli.FileUtil;
|
||||||
import sop.cli.picocli.Print;
|
import sop.cli.picocli.Print;
|
||||||
import sop.cli.picocli.SopCLI;
|
import sop.cli.picocli.SopCLI;
|
||||||
import sop.enums.SignAs;
|
import sop.enums.SignAs;
|
||||||
import sop.exception.SOPGPException;
|
import sop.exception.SOPGPException;
|
||||||
|
import sop.operation.Decrypt;
|
||||||
import sop.operation.Sign;
|
import sop.operation.Sign;
|
||||||
|
|
||||||
@CommandLine.Command(name = "sign",
|
@CommandLine.Command(name = "sign",
|
||||||
|
@ -27,6 +29,8 @@ import sop.operation.Sign;
|
||||||
exitCodeOnInvalidInput = 37)
|
exitCodeOnInvalidInput = 37)
|
||||||
public class SignCmd implements Runnable {
|
public class SignCmd implements Runnable {
|
||||||
|
|
||||||
|
private static final String ERROR_UNSUPPORTED_OPTION = "Option '%s' is not supported.";
|
||||||
|
|
||||||
@CommandLine.Option(names = "--no-armor",
|
@CommandLine.Option(names = "--no-armor",
|
||||||
description = "ASCII armor the output",
|
description = "ASCII armor the output",
|
||||||
negatable = true)
|
negatable = true)
|
||||||
|
@ -74,8 +78,15 @@ public class SignCmd implements Runnable {
|
||||||
System.exit(19);
|
System.exit(19);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String password : withKeyPassword) {
|
for (String passwordFile : withKeyPassword) {
|
||||||
sign.withKeyPassword(password);
|
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) {
|
for (File keyFile : secretKeyFile) {
|
||||||
|
|
Loading…
Reference in a new issue