mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-16 17:32:06 +01:00
Fix prematurely throwing of MissingPassphraseException
This commit is contained in:
parent
b7bf722ecf
commit
f05be3dc30
2 changed files with 5 additions and 1 deletions
|
@ -392,8 +392,10 @@ public final class DecryptionStreamFactory {
|
||||||
for (Tuple<SubkeyIdentifier, ?> k : postponedDueToMissingPassphrase) {
|
for (Tuple<SubkeyIdentifier, ?> k : postponedDueToMissingPassphrase) {
|
||||||
keyIds.add(k.getA());
|
keyIds.add(k.getA());
|
||||||
}
|
}
|
||||||
|
if (!keyIds.isEmpty()) {
|
||||||
throw new MissingPassphraseException(keyIds);
|
throw new MissingPassphraseException(keyIds);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (options.getMissingKeyPassphraseStrategy() == MissingKeyPassphraseStrategy.INTERACTIVE) {
|
else if (options.getMissingKeyPassphraseStrategy() == MissingKeyPassphraseStrategy.INTERACTIVE) {
|
||||||
// Interactive mode: Fire protector callbacks to get passphrases interactively
|
// Interactive mode: Fire protector callbacks to get passphrases interactively
|
||||||
for (Tuple<SubkeyIdentifier, PGPPublicKeyEncryptedData> missingPassphrases : postponedDueToMissingPassphrase) {
|
for (Tuple<SubkeyIdentifier, PGPPublicKeyEncryptedData> missingPassphrases : postponedDueToMissingPassphrase) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.decryption_verification.ConsumerOptions;
|
import org.pgpainless.decryption_verification.ConsumerOptions;
|
||||||
import org.pgpainless.decryption_verification.DecryptionStream;
|
import org.pgpainless.decryption_verification.DecryptionStream;
|
||||||
|
import org.pgpainless.decryption_verification.MissingKeyPassphraseStrategy;
|
||||||
import org.pgpainless.encryption_signing.EncryptionOptions;
|
import org.pgpainless.encryption_signing.EncryptionOptions;
|
||||||
import org.pgpainless.encryption_signing.EncryptionStream;
|
import org.pgpainless.encryption_signing.EncryptionStream;
|
||||||
import org.pgpainless.encryption_signing.ProducerOptions;
|
import org.pgpainless.encryption_signing.ProducerOptions;
|
||||||
|
@ -113,6 +114,7 @@ public class SymmetricEncryptionTest {
|
||||||
assertThrows(MissingDecryptionMethodException.class, () -> PGPainless.decryptAndOrVerify()
|
assertThrows(MissingDecryptionMethodException.class, () -> PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(new ByteArrayInputStream(ciphertextOut.toByteArray()))
|
.onInputStream(new ByteArrayInputStream(ciphertextOut.toByteArray()))
|
||||||
.withOptions(new ConsumerOptions()
|
.withOptions(new ConsumerOptions()
|
||||||
|
.setMissingKeyPassphraseStrategy(MissingKeyPassphraseStrategy.THROW_EXCEPTION)
|
||||||
.addDecryptionPassphrase(Passphrase.fromPassword("meldir"))));
|
.addDecryptionPassphrase(Passphrase.fromPassword("meldir"))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue