Mark messages with failed DKIM, SPF or DMARC authentication

This commit is contained in:
M66B
2019-04-12 16:15:42 +02:00
parent c312725446
commit a29de1bd3f
8 changed files with 1744 additions and 1 deletions

View File

@@ -90,6 +90,9 @@ public class EntityMessage implements Serializable {
public String deliveredto;
public String inreplyto;
public String thread; // compose = null
public Boolean dkim;
public Boolean spf;
public Boolean dmarc;
public String avatar; // lookup URI from sender
public String sender; // sort key
public Address[] from;
@@ -182,6 +185,31 @@ public class EntityMessage implements Serializable {
}
}
static Boolean getAuthentication(String type, String header) {
if (header == null)
return null;
// https://tools.ietf.org/html/rfc7601
Boolean result = null;
String[] part = header.split(";");
for (int i = 1; i < part.length; i++) {
String[] kv = part[i].split("=");
if (kv.length > 1) {
String key = kv[0].trim();
String[] val = kv[1].split(" ");
if (val.length > 0 && type.equals(key)) {
if ("fail".equals(val[0]))
result = false;
else if ("pass".equals(val[0]))
if (result == null)
result = true;
}
}
}
return result;
}
public boolean uiEquals(Object obj) {
if (obj instanceof EntityMessage) {
EntityMessage other = (EntityMessage) obj;