Merge pull request #7415 from thunderbird/clean_up_CertificateValidationException

Remove unused code from `CertificateValidationException`
This commit is contained in:
cketti 2023-12-06 13:24:26 +01:00 committed by GitHub
commit 0d13561b22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 40 deletions

View file

@ -16,6 +16,7 @@ import com.fsck.k9.backend.BackendManager;
import com.fsck.k9.backend.api.Backend;
import com.fsck.k9.mail.AuthType;
import com.fsck.k9.mail.AuthenticationFailedException;
import com.fsck.k9.mail.CertificateChainException;
import com.fsck.k9.mail.CertificateValidationException;
import com.fsck.k9.mail.ConnectionSecurity;
import com.fsck.k9.mail.Flag;
@ -355,7 +356,8 @@ public class MessagingControllerTest extends K9RobolectricTest {
@Test
public void sendPendingMessagesSynchronous_withCertificateFailure_shouldNotify() throws MessagingException {
setupAccountWithMessageToSend();
doThrow(new CertificateValidationException("Test")).when(backend).sendMessage(localMessageToSend1);
doThrow(new CertificateValidationException("Test", new CertificateChainException("", null, null)))
.when(backend).sendMessage(localMessageToSend1);
controller.sendPendingMessagesSynchronous(account);

View file

@ -1,4 +1,3 @@
package com.fsck.k9.mail;
import java.security.cert.CertPathValidatorException;
@ -8,49 +7,14 @@ import java.security.cert.X509Certificate;
import javax.net.ssl.SSLHandshakeException;
public class CertificateValidationException extends MessagingException {
public static final long serialVersionUID = -1;
private final Reason mReason;
private X509Certificate[] mCertChain;
private boolean mNeedsUserAttention = false;
private String mAlias;
public enum Reason {
Unknown, UseMessage, Expired, MissingCapability, RetrievalFailure
}
public CertificateValidationException(String message) {
this(message, Reason.UseMessage, null);
}
public CertificateValidationException(Reason reason) {
this(null, reason, null);
}
public CertificateValidationException(String message, Reason reason, String alias) {
super(message);
/*
* Instances created without a Throwable parameter as a cause are
* presumed to need user attention.
*/
mNeedsUserAttention = true;
mReason = reason;
mAlias = alias;
}
public CertificateValidationException(final String message, Throwable throwable) {
super(message, throwable);
mReason = Reason.Unknown;
public CertificateValidationException(final String message, Throwable cause) {
super(message, cause);
scanForCause();
}
public String getAlias() {
return mAlias;
}
public Reason getReason() {
return mReason;
}
private void scanForCause() {
Throwable throwable = getCause();