Skip to content

Commit

Permalink
Removed jDKIM
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Apr 6, 2022
1 parent c4d02ce commit 7e33ec1
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 80 deletions.
1 change: 0 additions & 1 deletion ATTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ FairEmail uses:
* [Lato font](https://fonts.google.com/specimen/Lato). By Łukasz Dziedzic. [Apache License 2.0](https://fonts.google.com/specimen/Lato#license).
* [Caladea font](https://fonts.google.com/specimen/Caladea). By Andrés Torresi, Carolina Giovanolli. [Apache License 2.0](https://fonts.google.com/specimen/Caladea#license).
* [Apache Commons Compress](https://commons.apache.org/proper/commons-compress/). Copyright © 2002-2021 The Apache Software Foundation. All Rights Reserved. [Apache License 2.0](https://www.apache.org/licenses/).
* [Apache JAMES jDKIM](https://github.com/Bedework/apache-jdkim). Copyright 2009-2010 The Apache Software Foundation. [Apache License 2.0](https://github.com/Bedework/apache-jdkim/blob/master/LICENSE)
9 changes: 0 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ android {
'META-INF/COPYRIGHT.html',
'META-INF/LICENSE.gpl.txt',
'META-INF/LICENSE.commercial.txt',
'META-INF/README',
'META-INF/DEPENDENCIES',
'META-INF/INDEX.LIST',
'LICENSE-2.0.txt',
'RELEASE.txt'
]
Expand Down Expand Up @@ -584,10 +581,4 @@ dependencies {
// https://commons.apache.org/proper/commons-compress/
// https://mvnrepository.com/artifact/org.apache.commons/commons-compress
implementation "org.apache.commons:commons-compress:$compress_version"

implementation("org.bedework:apache-jdkim:0.6") {
exclude group: "org.apache.geronimo.specs", module: "geronimo-activation_1.1_spec"
exclude group: "org.apache.geronimo.javamail", module: "geronimo-javamail_1.4_mail"
exclude group: "dnsjava", module: "dnsjava"
}
}
1 change: 0 additions & 1 deletion app/src/main/assets/ATTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ FairEmail uses:
* [Lato font](https://fonts.google.com/specimen/Lato). By Łukasz Dziedzic. [Apache License 2.0](https://fonts.google.com/specimen/Lato#license).
* [Caladea font](https://fonts.google.com/specimen/Caladea). By Andrés Torresi, Carolina Giovanolli. [Apache License 2.0](https://fonts.google.com/specimen/Caladea#license).
* [Apache Commons Compress](https://commons.apache.org/proper/commons-compress/). Copyright © 2002-2021 The Apache Software Foundation. All Rights Reserved. [Apache License 2.0](https://www.apache.org/licenses/).
* [Apache JAMES jDKIM](https://github.com/Bedework/apache-jdkim). Copyright 2009-2010 The Apache Software Foundation. [Apache License 2.0](https://github.com/Bedework/apache-jdkim/blob/master/LICENSE)
70 changes: 1 addition & 69 deletions app/src/main/java/eu/faircode/email/MessageHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
import org.apache.commons.compress.archivers.zip.UnsupportedZipFeatureException;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.apache.james.jdkim.DKIMVerifier;
import org.apache.james.jdkim.api.Headers;
import org.apache.james.jdkim.api.PublicKeyRecordRetriever;
import org.apache.james.jdkim.api.SignatureRecord;
import org.apache.james.jdkim.exceptions.PermFailException;
import org.apache.james.jdkim.exceptions.TempFailException;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
Expand Down Expand Up @@ -1877,69 +1871,7 @@ boolean checkDKIMRequirements() throws MessagingException {
}

boolean verifyDKIM(Context context) throws MessagingException {
ensureHeaders();

try {
// https://datatracker.ietf.org/doc/html/rfc6376/
DKIMVerifier jdkim = new DKIMVerifier(new PublicKeyRecordRetriever() {
@Override
public List<String> getRecords(CharSequence methodAndOptions, CharSequence selector, CharSequence token)
throws TempFailException, PermFailException {
if (methodAndOptions == null ||
!"dns/txt".equalsIgnoreCase(methodAndOptions.toString()))
throw new PermFailException("Query method=" + methodAndOptions);
try {
String query = selector + "._domainkey." + token;
DnsHelper.DnsRecord[] records = DnsHelper.lookup(context, query, "txt");
List<String> result = new ArrayList<>();
for (DnsHelper.DnsRecord record : records)
result.add(record.name);
return result;
} catch (Exception ex) {
Log.w(ex);
throw new PermFailException("dns/lookup", ex);
}
}
});
List<SignatureRecord> records = jdkim.verify(new Headers() {
@Override
public List<String> getFields() {
Log.e("DKIM getFields");
throw new IllegalArgumentException("getFields");
}

@Override
public List<String> getFields(String name) {
try {
List<String> result = new ArrayList<>();
String[] headers = imessage.getHeader(name);
if (headers != null)
for (String header : headers)
result.add(name + ": " + header);
return result;
} catch (MessagingException ex) {
Log.e(ex);
return new ArrayList<>();
}
}
}, imessage.getRawInputStream());

if (records == null)
return false;

for (SignatureRecord record : records) {
String hash = record.getHashAlgo().toString();
if ("sha-1".equalsIgnoreCase(hash))
throw new IllegalArgumentException("hash=" + hash);
if (!"sha-256".equalsIgnoreCase(hash))
Log.w("DKIM hash=" + hash);
}

return (records.size() > 0);
} catch (Throwable ex) {
Log.e("DKIM", ex);
return false;
}
return true;
}

Address[] getMailFrom(String[] headers) {
Expand Down

0 comments on commit 7e33ec1

Please sign in to comment.