mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-01 19:42:08 +01:00
GenerateKeyCmd: Make --with-key-password indirect data type
This commit is contained in:
parent
45ee435a18
commit
8184c30617
1 changed files with 11 additions and 3 deletions
|
@ -10,6 +10,7 @@ import java.util.List;
|
||||||
|
|
||||||
import picocli.CommandLine;
|
import picocli.CommandLine;
|
||||||
import sop.Ready;
|
import sop.Ready;
|
||||||
|
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.exception.SOPGPException;
|
import sop.exception.SOPGPException;
|
||||||
|
@ -29,7 +30,7 @@ public class GenerateKeyCmd implements Runnable {
|
||||||
List<String> userId = new ArrayList<>();
|
List<String> userId = new ArrayList<>();
|
||||||
|
|
||||||
@CommandLine.Option(names = "--with-key-password",
|
@CommandLine.Option(names = "--with-key-password",
|
||||||
description = "Password to protect the key",
|
description = "Indirect file type pointing to file containing password to protect the key",
|
||||||
paramLabel = "PASSWORD")
|
paramLabel = "PASSWORD")
|
||||||
String withKeyPassword;
|
String withKeyPassword;
|
||||||
|
|
||||||
|
@ -48,8 +49,15 @@ public class GenerateKeyCmd implements Runnable {
|
||||||
generateKey.noArmor();
|
generateKey.noArmor();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (withKeyPassword != null && !withKeyPassword.trim().isEmpty()) {
|
if (withKeyPassword != null) {
|
||||||
generateKey.withKeyPassword(withKeyPassword.trim());
|
try {
|
||||||
|
String password = FileUtil.stringFromInputStream(FileUtil.getFileInputStream(withKeyPassword));
|
||||||
|
generateKey.withKeyPassword(password);
|
||||||
|
} catch (SOPGPException.UnsupportedOption e) {
|
||||||
|
throw new SOPGPException.UnsupportedOption("Option '--with-key-password' is not supported.");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue