1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-23 11:27:57 +01:00

Throw MissingDecryptionMethodException when missing decryption key or -passphrase

This commit is contained in:
Paul Schaub 2021-05-28 23:20:25 +02:00
parent 77800f26e8
commit ea03c66400
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 32 additions and 1 deletions

View file

@ -57,6 +57,7 @@ import org.pgpainless.algorithm.CompressionAlgorithm;
import org.pgpainless.algorithm.StreamEncoding;
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
import org.pgpainless.exception.MessageNotIntegrityProtectedException;
import org.pgpainless.exception.MissingDecryptionMethodException;
import org.pgpainless.exception.UnacceptableAlgorithmException;
import org.pgpainless.implementation.ImplementationFactory;
import org.pgpainless.key.OpenPgpV4Fingerprint;
@ -272,7 +273,7 @@ public final class DecryptionStreamFactory {
}
if (decryptionKey == null) {
throw new PGPException("Decryption failed - No suitable decryption key or passphrase found");
throw new MissingDecryptionMethodException("Decryption failed - No suitable decryption key or passphrase found");
}
PublicKeyDataDecryptorFactory dataDecryptor = ImplementationFactory.getInstance()

View file

@ -0,0 +1,30 @@
/*
* Copyright 2021 Paul Schaub.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pgpainless.exception;
import org.bouncycastle.openpgp.PGPException;
/**
* Exception that is thrown when decryption fails due to a missing decryption key or decryption passphrase.
* This can happen when the user does not provide the right set of keys / the right password when decrypting
* a message.
*/
public class MissingDecryptionMethodException extends PGPException {
public MissingDecryptionMethodException(String message) {
super(message);
}
}