From 7e33ec1d49946422cb41efddf9d9027420573bea Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 6 Apr 2022 19:53:49 +0200 Subject: [PATCH] Removed jDKIM --- ATTRIBUTION.md | 1 - app/build.gradle | 9 --- app/src/main/assets/ATTRIBUTION.md | 1 - .../java/eu/faircode/email/MessageHelper.java | 70 +------------------ 4 files changed, 1 insertion(+), 80 deletions(-) diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index dc47111dc4..59a6bd3681 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -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) diff --git a/app/build.gradle b/app/build.gradle index fcbbe2b0f3..a52f05865f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' ] @@ -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" - } } diff --git a/app/src/main/assets/ATTRIBUTION.md b/app/src/main/assets/ATTRIBUTION.md index dc47111dc4..59a6bd3681 100644 --- a/app/src/main/assets/ATTRIBUTION.md +++ b/app/src/main/assets/ATTRIBUTION.md @@ -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) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 61c4d97f58..54f88d4953 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -55,12 +55,6 @@ import org.apache.commons.compress.archivers.ArchiveInputStream; 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; @@ -1877,69 +1871,7 @@ public class MessageHelper { } boolean verifyDKIM(Context context) throws MessagingException { - ensureHeaders(); - - try { - // https://datatracker.ietf.org/doc/html/rfc6376/ - DKIMVerifier jdkim = new DKIMVerifier(new PublicKeyRecordRetriever() { - @Override - public List 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 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 records = jdkim.verify(new Headers() { - @Override - public List getFields() { - Log.e("DKIM getFields"); - throw new IllegalArgumentException("getFields"); - } - - @Override - public List getFields(String name) { - try { - List 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) {