Commit 99b94105 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

continue to implement authentication result

parent 61141227
......@@ -43,13 +43,13 @@ void DKIMAuthenticationStatusInfoConverter::setStatusInfo(const MessageViewer::D
mStatusInfo = statusInfo;
}
QVector<DKIMCheckSignatureJob::CheckSignatureResult> DKIMAuthenticationStatusInfoConverter::convert() const
QVector<DKIMCheckSignatureJob::DKIMCheckSignatureAuthenticationResult> DKIMAuthenticationStatusInfoConverter::convert() const
{
QVector<DKIMCheckSignatureJob::CheckSignatureResult> lstResult;
QVector<DKIMCheckSignatureJob::DKIMCheckSignatureAuthenticationResult> lstResult;
const QVector<DKIMAuthenticationStatusInfo::AuthStatusInfo> lstInfo = mStatusInfo.listAuthStatusInfo();
for (const DKIMAuthenticationStatusInfo::AuthStatusInfo &info : lstInfo) {
DKIMCheckSignatureJob::CheckSignatureResult convertedResult;
convertedResult.authenticationResult.method = MessageViewer::DKIMUtil::convertAuthenticationMethodStringToEnum(info.method);
DKIMCheckSignatureJob::DKIMCheckSignatureAuthenticationResult convertedResult;
convertedResult.method = MessageViewer::DKIMUtil::convertAuthenticationMethodStringToEnum(info.method);
const QString &infoResult = info.result;
if (infoResult == QLatin1String("none")) {
convertedResult.status = DKIMCheckSignatureJob::DKIMStatus::EmailNotSigned;
......@@ -79,12 +79,12 @@ QVector<DKIMCheckSignatureJob::CheckSignatureResult> DKIMAuthenticationStatusInf
|| infoResult == QLatin1String("permerror")) {
convertedResult.status = DKIMCheckSignatureJob::DKIMStatus::Invalid;
if (!info.reason.isEmpty()) {
convertedResult.authenticationResult.errorStr = info.reason;
convertedResult.errorStr = info.reason;
}
} else if (infoResult == QLatin1String("temperror")) {
convertedResult.status = DKIMCheckSignatureJob::DKIMStatus::Invalid;
if (!info.reason.isEmpty()) {
convertedResult.authenticationResult.errorStr = info.reason;
convertedResult.errorStr = info.reason;
}
} else {
qCWarning(MESSAGEVIEWER_DKIMCHECKER_LOG) << "Invalid result type " << infoResult;
......
......@@ -36,7 +36,7 @@ public:
Q_REQUIRED_RESULT MessageViewer::DKIMAuthenticationStatusInfo statusInfo() const;
void setStatusInfo(const MessageViewer::DKIMAuthenticationStatusInfo &statusInfo);
Q_REQUIRED_RESULT QVector<DKIMCheckSignatureJob::CheckSignatureResult> convert() const;
Q_REQUIRED_RESULT QVector<DKIMCheckSignatureJob::DKIMCheckSignatureAuthenticationResult> convert() const;
private:
MessageViewer::DKIMAuthenticationStatusInfo mStatusInfo;
......
......@@ -142,11 +142,10 @@ void DKIMCheckFullJob::slotCheckAuthenticationStatusResult(const MessageViewer::
DKIMAuthenticationStatusInfoConverter converter;
converter.setStatusInfo(info);
//TODO Convert to CheckSignatureAuthenticationResult + add this list to CheckSignatureResult directly
const QVector<DKIMCheckSignatureJob::CheckSignatureResult> lst = converter.convert();
for (const DKIMCheckSignatureJob::CheckSignatureResult &result : lst) {
qDebug() << " lst" << result;
//TODO verify it.
}
const QVector<DKIMCheckSignatureJob::DKIMCheckSignatureAuthenticationResult> lst = converter.convert();
qDebug() << " lst " << lst;
//TODO use it.
//TODO check info ! if auth is ok not necessary to checkSignature
if (mCheckPolicy.useOnlyAuthenticationResults()) {
//Don't check signature if not necessary.
......
......@@ -662,7 +662,7 @@ bool DKIMCheckSignatureJob::CheckSignatureResult::operator==(const DKIMCheckSign
&& fromEmail == other.fromEmail
&& auid == other.auid
&& sdid == other.sdid
&& authenticationResult == other.authenticationResult;
&& listSignatureAuthenticationResult == other.listSignatureAuthenticationResult;
}
bool DKIMCheckSignatureJob::CheckSignatureResult::operator!=(const DKIMCheckSignatureJob::CheckSignatureResult &other) const
......@@ -678,18 +678,25 @@ QDebug operator <<(QDebug d, const DKIMCheckSignatureJob::CheckSignatureResult &
d << "signedBy " << t.sdid;
d << "fromEmail " << t.fromEmail;
d << "auid " << t.auid;
d << "authenticationResult " << t.authenticationResult;
d << "authenticationResult " << t.listSignatureAuthenticationResult;
return d;
}
QDebug operator <<(QDebug d, const DKIMCheckSignatureJob::CheckSignatureResult::AuthenticationResult &t)
QDebug operator <<(QDebug d, const DKIMCheckSignatureJob::DKIMCheckSignatureAuthenticationResult &t)
{
d << "method " << t.method;
d << "errorStr " << t.errorStr;
d << "status " << t.status;
d << "sdid " << t.sdid;
d << "auid " << t.auid;
return d;
}
bool DKIMCheckSignatureJob::CheckSignatureResult::AuthenticationResult::operator==(const DKIMCheckSignatureJob::CheckSignatureResult::AuthenticationResult &other) const
bool DKIMCheckSignatureJob::DKIMCheckSignatureAuthenticationResult::operator==(const DKIMCheckSignatureJob::DKIMCheckSignatureAuthenticationResult &other) const
{
return errorStr == other.errorStr && method == other.method;
return errorStr == other.errorStr &&
method == other.method &&
status == other.status &&
sdid == other.sdid &&
auid == other.auid;
}
......@@ -90,6 +90,15 @@ public:
Q_ENUM(AuthenticationMethod)
struct DKIMCheckSignatureAuthenticationResult {
QString errorStr;
AuthenticationMethod method = AuthenticationMethod::Unknown;
DKIMCheckSignatureJob::DKIMStatus status = DKIMCheckSignatureJob::DKIMStatus::Unknown;
QString sdid; //Signing Domain Identifier
QString auid; //DKIM MAY optionally provide a single responsible Agent or User Identifier (AUID).
Q_REQUIRED_RESULT bool operator==(const DKIMCheckSignatureAuthenticationResult &other) const;
};
struct CheckSignatureResult {
Q_REQUIRED_RESULT bool isValid() const;
......@@ -104,13 +113,7 @@ public:
QString auid; //DKIM MAY optionally provide a single responsible Agent or User Identifier (AUID).
QString fromEmail;
//Authentication result values.
struct AuthenticationResult {
QString errorStr;
AuthenticationMethod method = AuthenticationMethod::Unknown;
Q_REQUIRED_RESULT bool operator==(const AuthenticationResult &other) const;
};
AuthenticationResult authenticationResult;
QVector<DKIMCheckSignatureAuthenticationResult> listSignatureAuthenticationResult;
};
explicit DKIMCheckSignatureJob(QObject *parent = nullptr);
......@@ -171,6 +174,7 @@ private:
};
}
MESSAGEVIEWER_EXPORT QDebug operator <<(QDebug d, const MessageViewer::DKIMCheckSignatureJob::CheckSignatureResult &t);
MESSAGEVIEWER_EXPORT QDebug operator <<(QDebug d, const MessageViewer::DKIMCheckSignatureJob::CheckSignatureResult::AuthenticationResult &t);
MESSAGEVIEWER_EXPORT QDebug operator <<(QDebug d, const MessageViewer::DKIMCheckSignatureJob::DKIMCheckSignatureAuthenticationResult &t);
Q_DECLARE_METATYPE(MessageViewer::DKIMCheckSignatureJob::CheckSignatureResult)
Q_DECLARE_TYPEINFO(MessageViewer::DKIMCheckSignatureJob::DKIMCheckSignatureAuthenticationResult, Q_MOVABLE_TYPE);
#endif // DKIMCHECKSIGNATUREJOB_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment