SSL Handshake Prompt for IMAP (#381)

* Fix an incorrect namespace for copy auth url request.

* Implemented SSL handshake process for testing imap configuration.

* Implemented SSL handshake process for testing imap configuration.

* Replace certificate PathIcon with WinoFontIcon in XAML.
This commit is contained in:
Burak Kaan Köse
2024-09-14 21:51:43 +02:00
committed by GitHub
parent cad9250cb7
commit 56bfbeca58
24 changed files with 473 additions and 113 deletions

View File

@@ -0,0 +1,50 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Wino.Core.Domain.Exceptions;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Connectivity;
using Wino.Core.Domain.Models.Server;
using Wino.Messaging.Server;
using Wino.Server.Core;
namespace Wino.Server.MessageHandlers
{
public class ImapConnectivityTestHandler : ServerMessageHandler<ImapConnectivityTestRequested, ImapConnectivityTestResults>
{
private readonly IImapTestService _imapTestService;
public override WinoServerResponse<ImapConnectivityTestResults> FailureDefaultResponse(Exception ex)
=> WinoServerResponse<ImapConnectivityTestResults>.CreateErrorResponse(ex.Message);
public ImapConnectivityTestHandler(IImapTestService imapTestService)
{
_imapTestService = imapTestService;
}
protected override async Task<WinoServerResponse<ImapConnectivityTestResults>> HandleAsync(ImapConnectivityTestRequested message, CancellationToken cancellationToken = default)
{
try
{
await _imapTestService.TestImapConnectionAsync(message.ServerInformation, message.IsSSLHandshakeAllowed);
return WinoServerResponse<ImapConnectivityTestResults>.CreateSuccessResponse(ImapConnectivityTestResults.Success());
}
catch (ImapTestSSLCertificateException sslTestException)
{
// User must confirm to continue ignoring the SSL certificate.
return WinoServerResponse<ImapConnectivityTestResults>.CreateSuccessResponse(ImapConnectivityTestResults.CertificateUIRequired(sslTestException.Issuer, sslTestException.ExpirationDateString, sslTestException.ValidFromDateString));
}
catch (ImapClientPoolException clientPoolException)
{
// Connectivity failed with protocol log.
return WinoServerResponse<ImapConnectivityTestResults>.CreateSuccessResponse(ImapConnectivityTestResults.Failure(clientPoolException, clientPoolException.ProtocolLog));
}
catch (Exception exception)
{
// Unknown error
return WinoServerResponse<ImapConnectivityTestResults>.CreateSuccessResponse(ImapConnectivityTestResults.Failure(exception, string.Empty));
}
}
}
}