Added auth results signer

This commit is contained in:
M66B 2024-05-24 08:33:57 +02:00
parent bce1420a4e
commit 6019218e18
2 changed files with 36 additions and 4 deletions

View File

@ -3505,12 +3505,12 @@ class Core {
message.identity = (identity == null ? null : identity.id); message.identity = (identity == null ? null : identity.id);
boolean fromSelf = message.fromSelf(identity); boolean fromSelf = message.fromSelf(identity);
List<String> signers = new ArrayList<>();
if (native_dkim && if (native_dkim &&
!fromSelf && !fromSelf &&
!EntityFolder.isOutgoing(folder.type) && !EntityFolder.isOutgoing(folder.type) &&
!BuildConfig.PLAY_STORE_RELEASE) { !BuildConfig.PLAY_STORE_RELEASE) {
List<String> signers = helper.verifyDKIM(context); signers.addAll(helper.verifyDKIM(context));
message.signedby = (signers.isEmpty() ? null : TextUtils.join(",", signers));
message.dkim = !signers.isEmpty(); message.dkim = !signers.isEmpty();
if (message.dkim) { if (message.dkim) {
boolean aligned = helper.isAligned(context, signers, message.return_path, message.smtp_from, message.from); boolean aligned = helper.isAligned(context, signers, message.return_path, message.smtp_from, message.from);
@ -3521,6 +3521,11 @@ class Core {
} }
} }
String signer = helper.getSigner(authentication);
if (signer != null)
signers.add(0, signer);
message.signedby = (signers.isEmpty() ? null : TextUtils.join(",", signers));
if (message.size == null && message.total != null) if (message.size == null && message.total != null)
message.size = message.total; message.size = message.total;
@ -4666,12 +4671,12 @@ class Core {
message.identity = (identity == null ? null : identity.id); message.identity = (identity == null ? null : identity.id);
boolean fromSelf = message.fromSelf(identity); boolean fromSelf = message.fromSelf(identity);
List<String> signers = new ArrayList<>();
if (native_dkim && if (native_dkim &&
!fromSelf && !fromSelf &&
!EntityFolder.isOutgoing(folder.type) && !EntityFolder.isOutgoing(folder.type) &&
!BuildConfig.PLAY_STORE_RELEASE) { !BuildConfig.PLAY_STORE_RELEASE) {
List<String> signers = helper.verifyDKIM(context); signers.addAll(helper.verifyDKIM(context));
message.signedby = (signers.isEmpty() ? null : TextUtils.join(",", signers));
message.dkim = !signers.isEmpty(); message.dkim = !signers.isEmpty();
if (message.dkim) { if (message.dkim) {
boolean aligned = helper.isAligned(context, signers, message.return_path, message.smtp_from, message.from); boolean aligned = helper.isAligned(context, signers, message.return_path, message.smtp_from, message.from);
@ -4682,6 +4687,11 @@ class Core {
} }
} }
String signer = helper.getSigner(authentication);
if (signer != null)
signers.add(0, signer);
message.signedby = (signers.isEmpty() ? null : TextUtils.join(",", signers));
// Borrow reply name from sender name // Borrow reply name from sender name
if (message.from != null && message.from.length == 1 && if (message.from != null && message.from.length == 1 &&
message.reply != null && message.reply.length == 1) { message.reply != null && message.reply.length == 1) {

View File

@ -2233,6 +2233,28 @@ public class MessageHelper {
return mailfrom; return mailfrom;
} }
String getSigner(String[] headers) {
if (headers == null || headers.length == 0)
return null;
int semi = headers[0].indexOf(';');
if (semi < 0)
return null;
String signer = headers[0].substring(0, semi).trim();
if (signer.toLowerCase(Locale.ROOT).startsWith("i=")) {
int semi2 = headers[0].indexOf(';', semi + 1);
if (semi2 < 0)
return null;
signer = headers[0].substring(semi + 1, semi2).trim();
}
if (TextUtils.isEmpty(signer))
signer = null;
return signer;
}
boolean getSPF() throws MessagingException { boolean getSPF() throws MessagingException {
ensureHeaders(); ensureHeaders();