mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-11-26 17:12:08 +01:00
Add support for --with-key-password to DecryptCmd
This commit is contained in:
parent
6438ebc59c
commit
45ee435a18
1 changed files with 19 additions and 0 deletions
|
@ -87,6 +87,11 @@ public class DecryptCmd implements Runnable {
|
||||||
paramLabel = "KEY")
|
paramLabel = "KEY")
|
||||||
List<File> keys = new ArrayList<>();
|
List<File> keys = new ArrayList<>();
|
||||||
|
|
||||||
|
@CommandLine.Option(names = "--with-key-password",
|
||||||
|
description = "Provide indirect file type pointing at passphrase(s) for secret key(s)",
|
||||||
|
paramLabel = "PASSWORD")
|
||||||
|
List<String> withKeyPassword = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
throwIfOutputExists(verifyOut, VERIFY_OUT);
|
throwIfOutputExists(verifyOut, VERIFY_OUT);
|
||||||
|
@ -101,6 +106,7 @@ public class DecryptCmd implements Runnable {
|
||||||
setNotBefore(notBefore, decrypt);
|
setNotBefore(notBefore, decrypt);
|
||||||
setWithPasswords(withPassword, decrypt);
|
setWithPasswords(withPassword, decrypt);
|
||||||
setWithSessionKeys(withSessionKey, decrypt);
|
setWithSessionKeys(withSessionKey, decrypt);
|
||||||
|
setWithKeyPassword(withKeyPassword, decrypt);
|
||||||
setVerifyWith(certs, decrypt);
|
setVerifyWith(certs, decrypt);
|
||||||
setDecryptWith(keys, decrypt);
|
setDecryptWith(keys, decrypt);
|
||||||
|
|
||||||
|
@ -229,6 +235,19 @@ public class DecryptCmd implements Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setWithKeyPassword(List<String> withKeyPassword, Decrypt decrypt) {
|
||||||
|
for (String passwordFile : withKeyPassword) {
|
||||||
|
try {
|
||||||
|
String password = FileUtil.stringFromInputStream(FileUtil.getFileInputStream(passwordFile));
|
||||||
|
decrypt.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setNotAfter(String notAfter, Decrypt decrypt) {
|
private void setNotAfter(String notAfter, Decrypt decrypt) {
|
||||||
Date notAfterDate = DateParser.parseNotAfter(notAfter);
|
Date notAfterDate = DateParser.parseNotAfter(notAfter);
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue