You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2019/06/26 10:22:21 UTC

[james-project] 02/02: JAMES-1975 Inject PublicKeyRecordRetriever for DKIMVerify mailet

This is an automated email from the ASF dual-hosted git repository.

rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 6861d2a3b419674057bccdeaa0aa250c7f858496
Author: Gautier DI FOLCO <gd...@linagora.com>
AuthorDate: Mon Jun 3 15:43:11 2019 +0200

    JAMES-1975 Inject PublicKeyRecordRetriever for DKIMVerify mailet
---
 pom.xml                                            |  5 --
 server/container/guice/cassandra-guice/pom.xml     |  4 --
 .../org/apache/james/CassandraJamesServerMain.java |  4 +-
 server/container/guice/jpa-guice/pom.xml           |  4 --
 .../java/org/apache/james/JPAJamesServerMain.java  |  4 +-
 server/container/guice/jpa-smtp-common/pom.xml     |  4 --
 .../java/org/apache/james/JPAJamesServerMain.java  |  4 +-
 server/container/guice/mailet/pom.xml              |  4 ++
 .../james/modules/server/DKIMMailetModule.java}    |  4 +-
 server/container/guice/memory-guice/pom.xml        |  4 --
 .../org/apache/james/MemoryJamesServerMain.java    |  4 +-
 .../org/apache/james/jdkim/mailets/DKIMVerify.java | 30 +++++----
 .../mailets/MockPublicKeyRecordRetriever.java      | 57 +++++++++++++++++
 .../apache/james/jdkim/mailets/DKIMSignTest.java   |  1 -
 .../apache/james/jdkim/mailets/DKIMVerifyTest.java | 13 +---
 server/mailet/integration-testing/pom.xml          |  4 ++
 .../apache/james/mailets/DKIMIntegrationTest.java  | 72 +++++++++++-----------
 server/mailet/mailets-guice/pom.xml                | 47 --------------
 server/pom.xml                                     |  1 -
 19 files changed, 134 insertions(+), 136 deletions(-)

diff --git a/pom.xml b/pom.xml
index eda4654..670f5c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1560,11 +1560,6 @@
             </dependency>
             <dependency>
                 <groupId>${james.groupId}</groupId>
-                <artifactId>james-server-mailets-guice</artifactId>
-                <version>${project.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>${james.groupId}</groupId>
                 <artifactId>james-server-memory-guice</artifactId>
                 <version>${project.version}</version>
             </dependency>
diff --git a/server/container/guice/cassandra-guice/pom.xml b/server/container/guice/cassandra-guice/pom.xml
index cbbddc0..206e9bd 100644
--- a/server/container/guice/cassandra-guice/pom.xml
+++ b/server/container/guice/cassandra-guice/pom.xml
@@ -83,10 +83,6 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
-            <artifactId>james-server-mailets-guice</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${james.groupId}</groupId>
             <artifactId>apache-james-mailbox-quota-search-elasticsearch</artifactId>
         </dependency>
         <dependency>
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
index ddab14f..0bdafb5 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
@@ -19,7 +19,6 @@
 
 package org.apache.james;
 
-import org.apache.james.mailets.configuration.MailetsConfigurationModule;
 import org.apache.james.modules.BlobExportMechanismModule;
 import org.apache.james.modules.MailboxModule;
 import org.apache.james.modules.activemq.ActiveMQQueueModule;
@@ -49,6 +48,7 @@ import org.apache.james.modules.protocols.ProtocolHandlerModule;
 import org.apache.james.modules.protocols.SMTPServerModule;
 import org.apache.james.modules.server.CassandraDataRoutesModules;
 import org.apache.james.modules.server.CassandraRoutesModule;
+import org.apache.james.modules.server.DKIMMailetModule;
 import org.apache.james.modules.server.DLPRoutesModule;
 import org.apache.james.modules.server.DataRoutesModules;
 import org.apache.james.modules.server.ElasticSearchMetricReporterModule;
@@ -133,7 +133,7 @@ public class CassandraJamesServerMain {
         CASSANDRA_MAILBOX_MODULE,
         PROTOCOLS,
         PLUGINS,
-        new MailetsConfigurationModule());
+        new DKIMMailetModule());
 
     public static void main(String[] args) throws Exception {
         Configuration configuration = Configuration.builder()
diff --git a/server/container/guice/jpa-guice/pom.xml b/server/container/guice/jpa-guice/pom.xml
index d10f37a..0340513 100644
--- a/server/container/guice/jpa-guice/pom.xml
+++ b/server/container/guice/jpa-guice/pom.xml
@@ -147,10 +147,6 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
-            <artifactId>james-server-mailets-guice</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${james.groupId}</groupId>
             <artifactId>james-server-testing</artifactId>
             <scope>test</scope>
         </dependency>
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
index b036a22..df86f96 100644
--- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
+++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
@@ -19,7 +19,6 @@
 
 package org.apache.james;
 
-import org.apache.james.mailets.configuration.MailetsConfigurationModule;
 import org.apache.james.modules.MailboxModule;
 import org.apache.james.modules.activemq.ActiveMQQueueModule;
 import org.apache.james.modules.data.JPADataModule;
@@ -33,6 +32,7 @@ import org.apache.james.modules.protocols.ManageSieveServerModule;
 import org.apache.james.modules.protocols.POP3ServerModule;
 import org.apache.james.modules.protocols.ProtocolHandlerModule;
 import org.apache.james.modules.protocols.SMTPServerModule;
+import org.apache.james.modules.server.DKIMMailetModule;
 import org.apache.james.modules.server.DataRoutesModules;
 import org.apache.james.modules.server.DefaultProcessorsConfigurationProviderModule;
 import org.apache.james.modules.server.ElasticSearchMetricReporterModule;
@@ -97,7 +97,7 @@ public class JPAJamesServerMain {
         GuiceJamesServer server = GuiceJamesServer.forConfiguration(configuration)
                     .combineWith(JPA_MODULE_AGGREGATE,
                             new JMXServerModule(),
-                            new MailetsConfigurationModule());
+                            new DKIMMailetModule());
         server.start();
     }
 
diff --git a/server/container/guice/jpa-smtp-common/pom.xml b/server/container/guice/jpa-smtp-common/pom.xml
index a4e6dc0..522f208 100644
--- a/server/container/guice/jpa-smtp-common/pom.xml
+++ b/server/container/guice/jpa-smtp-common/pom.xml
@@ -74,10 +74,6 @@
             <artifactId>james-server-jpa-common-guice</artifactId>
         </dependency>
         <dependency>
-            <groupId>${james.groupId}</groupId>
-            <artifactId>james-server-mailets-guice</artifactId>
-        </dependency>
-        <dependency>
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-classic</artifactId>
         </dependency>
diff --git a/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAJamesServerMain.java b/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAJamesServerMain.java
index d2238d1..e7af8a1 100644
--- a/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAJamesServerMain.java
+++ b/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAJamesServerMain.java
@@ -19,12 +19,12 @@
 
 package org.apache.james;
 
-import org.apache.james.mailets.configuration.MailetsConfigurationModule;
 import org.apache.james.modules.activemq.ActiveMQQueueModule;
 import org.apache.james.modules.data.JPADataModule;
 import org.apache.james.modules.data.JPAEntityManagerModule;
 import org.apache.james.modules.protocols.ProtocolHandlerModule;
 import org.apache.james.modules.protocols.SMTPServerModule;
+import org.apache.james.modules.server.DKIMMailetModule;
 import org.apache.james.modules.server.DataRoutesModules;
 import org.apache.james.modules.server.DefaultProcessorsConfigurationProviderModule;
 import org.apache.james.modules.server.ElasticSearchMetricReporterModule;
@@ -63,7 +63,7 @@ public class JPAJamesServerMain {
             .build();
 
         GuiceJamesServer server = GuiceJamesServer.forConfiguration(configuration)
-                    .combineWith(JPA_SERVER_MODULE, PROTOCOLS, new MailetsConfigurationModule());
+                    .combineWith(JPA_SERVER_MODULE, PROTOCOLS, new DKIMMailetModule());
         server.start();
     }
 
diff --git a/server/container/guice/mailet/pom.xml b/server/container/guice/mailet/pom.xml
index 71f324f..4cd2a76 100644
--- a/server/container/guice/mailet/pom.xml
+++ b/server/container/guice/mailet/pom.xml
@@ -57,6 +57,10 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-mailet-dkim</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
             <artifactId>james-server-mailetcontainer-api</artifactId>
         </dependency>
         <dependency>
diff --git a/server/mailet/mailets-guice/src/main/java/org/apache/james/mailets/configuration/MailetsConfigurationModule.java b/server/container/guice/mailet/src/main/java/org/apache/james/modules/server/DKIMMailetModule.java
similarity index 93%
rename from server/mailet/mailets-guice/src/main/java/org/apache/james/mailets/configuration/MailetsConfigurationModule.java
rename to server/container/guice/mailet/src/main/java/org/apache/james/modules/server/DKIMMailetModule.java
index 8c54221..ac89563 100644
--- a/server/mailet/mailets-guice/src/main/java/org/apache/james/mailets/configuration/MailetsConfigurationModule.java
+++ b/server/container/guice/mailet/src/main/java/org/apache/james/modules/server/DKIMMailetModule.java
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mailets.configuration;
+package org.apache.james.modules.server;
 
 import org.apache.james.jdkim.api.PublicKeyRecordRetriever;
 import org.apache.james.jdkim.impl.DNSPublicKeyRecordRetriever;
@@ -25,7 +25,7 @@ import org.apache.james.jdkim.impl.MultiplexingPublicKeyRecordRetriever;
 
 import com.google.inject.AbstractModule;
 
-public class MailetsConfigurationModule extends AbstractModule {
+public class DKIMMailetModule extends AbstractModule {
     @Override
     public void configure() {
         bind(PublicKeyRecordRetriever.class).toInstance(new MultiplexingPublicKeyRecordRetriever("dns", new DNSPublicKeyRecordRetriever()));
diff --git a/server/container/guice/memory-guice/pom.xml b/server/container/guice/memory-guice/pom.xml
index a3a9fb8..e558b01 100644
--- a/server/container/guice/memory-guice/pom.xml
+++ b/server/container/guice/memory-guice/pom.xml
@@ -174,10 +174,6 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
-            <artifactId>james-server-mailets-guice</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${james.groupId}</groupId>
             <artifactId>james-server-mailrepository-memory</artifactId>
         </dependency>
         <dependency>
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
index 73d33d2..191cf83 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
@@ -23,7 +23,6 @@ import java.util.Optional;
 
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.james.jwt.JwtConfiguration;
-import org.apache.james.mailets.configuration.MailetsConfigurationModule;
 import org.apache.james.modules.BlobExportMechanismModule;
 import org.apache.james.modules.BlobMemoryModule;
 import org.apache.james.modules.MailboxModule;
@@ -39,6 +38,7 @@ import org.apache.james.modules.protocols.POP3ServerModule;
 import org.apache.james.modules.protocols.ProtocolHandlerModule;
 import org.apache.james.modules.protocols.SMTPServerModule;
 import org.apache.james.modules.server.CamelMailetContainerModule;
+import org.apache.james.modules.server.DKIMMailetModule;
 import org.apache.james.modules.server.DLPRoutesModule;
 import org.apache.james.modules.server.DataRoutesModules;
 import org.apache.james.modules.server.JMXServerModule;
@@ -125,7 +125,7 @@ public class MemoryJamesServerMain {
         PROTOCOLS,
         JMAP,
         WEBADMIN,
-        new MailetsConfigurationModule());
+        new DKIMMailetModule());
 
     public static void main(String[] args) throws Exception {
         Configuration configuration = Configuration.builder()
diff --git a/server/mailet/dkim/src/main/java/org/apache/james/jdkim/mailets/DKIMVerify.java b/server/mailet/dkim/src/main/java/org/apache/james/jdkim/mailets/DKIMVerify.java
index 92e6015..2a2b11a 100644
--- a/server/mailet/dkim/src/main/java/org/apache/james/jdkim/mailets/DKIMVerify.java
+++ b/server/mailet/dkim/src/main/java/org/apache/james/jdkim/mailets/DKIMVerify.java
@@ -24,12 +24,14 @@ import java.io.OutputStream;
 import java.util.List;
 import java.util.Optional;
 
+import javax.inject.Inject;
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.james.jdkim.DKIMVerifier;
 import org.apache.james.jdkim.api.BodyHasher;
 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.FailException;
 import org.apache.mailet.Attribute;
@@ -42,30 +44,36 @@ import com.google.common.annotations.VisibleForTesting;
 
 /**
  * This mailet verify a message using the DKIM protocol
- * 
+ *
  * Sample configuration:
  * <pre><code>
  * &lt;mailet match=&quot;All&quot; class=&quot;DKIMVerify&quot;&gt;
  * &lt;/mailet&gt;
  * </code></pre>
- * 
- * By default the mailet assume that Javamail will use LF instead of CRLF 
- * so it will verify the hash using converted newlines. If you don't want this 
- * behaviout then set forceCRLF attribute to false. 
+ *
+ * By default the mailet assume that Javamail will use LF instead of CRLF
+ * so it will verify the hash using converted newlines. If you don't want this
+ * behaviour then set forceCRLF attribute to false.
  */
 public class DKIMVerify extends GenericMailet {
 
     public static final AttributeName DKIM_AUTH_RESULT = AttributeName.of("jDKIM.AUTHRESULT");
-    
-    @VisibleForTesting DKIMVerifier verifier = null;
+
+    @VisibleForTesting
+    DKIMVerifier verifier;
+
     private boolean forceCRLF;
 
+    @Inject
+    public DKIMVerify(PublicKeyRecordRetriever publicKeyRecordRetriever) {
+        verifier = new DKIMVerifier(publicKeyRecordRetriever);
+    }
+
     @Override
     public void init() {
-        verifier = new DKIMVerifier();
         forceCRLF = getInitParameter("forceCRLF", true);
     }
-    
+
     public void service(Mail mail) throws MessagingException {
         try {
             MimeMessage message = mail.getMessage();
@@ -96,13 +104,13 @@ public class DKIMVerify extends GenericMailet {
 
     @VisibleForTesting
     static List<SignatureRecord> verify(DKIMVerifier verifier, MimeMessage message, boolean forceCRLF)
-            throws MessagingException, FailException {
+        throws MessagingException, FailException {
         Headers headers = new MimeMessageHeaders(message);
         BodyHasher bh = verifier.newBodyHasher(headers);
         try {
             if (bh != null) {
                 OutputStream os = new HeaderSkippingOutputStream(bh
-                        .getOutputStream());
+                    .getOutputStream());
                 if (forceCRLF) {
                     os = new CRLFOutputStream(os);
                 }
diff --git a/server/mailet/dkim/src/main/java/org/apache/james/jdkim/mailets/MockPublicKeyRecordRetriever.java b/server/mailet/dkim/src/main/java/org/apache/james/jdkim/mailets/MockPublicKeyRecordRetriever.java
new file mode 100644
index 0000000..d3b5d63
--- /dev/null
+++ b/server/mailet/dkim/src/main/java/org/apache/james/jdkim/mailets/MockPublicKeyRecordRetriever.java
@@ -0,0 +1,57 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.jdkim.mailets;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.james.jdkim.api.PublicKeyRecordRetriever;
+import org.apache.james.jdkim.exceptions.PermFailException;
+import org.apache.james.jdkim.exceptions.TempFailException;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMultimap;
+
+public class MockPublicKeyRecordRetriever implements PublicKeyRecordRetriever {
+    private final ImmutableMultimap<String, String> records;
+
+    public MockPublicKeyRecordRetriever(String record, CharSequence selector, CharSequence token) {
+        records = ImmutableMultimap.of(makeKey(selector, token), record);
+    }
+
+    public List<String> getRecords(CharSequence methodAndOptions, CharSequence selector, CharSequence token) throws TempFailException, PermFailException {
+        if ("dns/txt".equals(methodAndOptions)) {
+            String search = makeKey(selector, token);
+            Collection<String> res = this.records.get(search);
+            if (res.size() <= 0) {
+                throw new TempFailException("Timout or servfail");
+            } else {
+                return ImmutableList.copyOf(res);
+            }
+        } else {
+            throw new PermFailException("Unsupported method");
+        }
+    }
+
+    private String makeKey(CharSequence selector, CharSequence token) {
+        return selector.toString() + "._domainkey." + token.toString();
+    }
+}
+
diff --git a/server/mailet/dkim/src/test/java/org/apache/james/jdkim/mailets/DKIMSignTest.java b/server/mailet/dkim/src/test/java/org/apache/james/jdkim/mailets/DKIMSignTest.java
index 305ff5f..28f98cd 100644
--- a/server/mailet/dkim/src/test/java/org/apache/james/jdkim/mailets/DKIMSignTest.java
+++ b/server/mailet/dkim/src/test/java/org/apache/james/jdkim/mailets/DKIMSignTest.java
@@ -36,7 +36,6 @@ import javax.mail.internet.MimeMessage;
 import javax.mail.internet.MimeMessage.RecipientType;
 
 import org.apache.james.jdkim.DKIMVerifier;
-import org.apache.james.jdkim.MockPublicKeyRecordRetriever;
 import org.apache.james.jdkim.api.SignatureRecord;
 import org.apache.james.jdkim.exceptions.FailException;
 import org.apache.james.jdkim.exceptions.PermFailException;
diff --git a/server/mailet/dkim/src/test/java/org/apache/james/jdkim/mailets/DKIMVerifyTest.java b/server/mailet/dkim/src/test/java/org/apache/james/jdkim/mailets/DKIMVerifyTest.java
index 27650ab..03f06dc 100644
--- a/server/mailet/dkim/src/test/java/org/apache/james/jdkim/mailets/DKIMVerifyTest.java
+++ b/server/mailet/dkim/src/test/java/org/apache/james/jdkim/mailets/DKIMVerifyTest.java
@@ -93,16 +93,9 @@ public class DKIMVerifyTest {
     }
 
     private Mail process(String message) throws Exception {
-        Mailet mailet = new DKIMVerify() {
-
-            @Override
-            public void init() {
-                verifier = new DKIMVerifier(new MockPublicKeyRecordRetriever(
-                        "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoTM5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRHr7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB;",
-                        "selector", "example.com"));
-            }
-            
-        };
+        Mailet mailet = new DKIMVerify((new MockPublicKeyRecordRetriever(
+            "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoTM5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRHr7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB;",
+            "selector", "example.com")));
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .mailetName("Test")
diff --git a/server/mailet/integration-testing/pom.xml b/server/mailet/integration-testing/pom.xml
index 697b075..1aa05f1 100644
--- a/server/mailet/integration-testing/pom.xml
+++ b/server/mailet/integration-testing/pom.xml
@@ -84,6 +84,10 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-mailet-dkim</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
             <artifactId>james-server-memory-guice</artifactId>
         </dependency>
         <dependency>
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/DKIMIntegrationTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/DKIMIntegrationTest.java
index 79bb150..f686b66 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/DKIMIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/DKIMIntegrationTest.java
@@ -30,10 +30,10 @@ import java.util.List;
 import java.util.Optional;
 
 import org.apache.james.MemoryJamesServerMain;
-import org.apache.james.jdkim.MockPublicKeyRecordRetriever;
 import org.apache.james.jdkim.api.PublicKeyRecordRetriever;
 import org.apache.james.jdkim.mailets.DKIMSign;
 import org.apache.james.jdkim.mailets.DKIMVerify;
+import org.apache.james.jdkim.mailets.MockPublicKeyRecordRetriever;
 import org.apache.james.mailets.configuration.CommonProcessors;
 import org.apache.james.mailets.configuration.MailetConfiguration;
 import org.apache.james.mailets.configuration.MailetContainer;
@@ -52,6 +52,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 
+import com.google.inject.util.Modules;
 
 public class DKIMIntegrationTest {
 
@@ -61,32 +62,35 @@ public class DKIMIntegrationTest {
     private static final String RECIPIENT = RECIPIENT_LOCAL_PART + "@" + DEFAULT_DOMAIN;
 
     private static final String TESTING_PEM = "-----BEGIN RSA PRIVATE KEY-----\r\n" +
-            "MIICXAIBAAKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoT\r\n" +
-            "M5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRH\r\n" +
-            "r7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB\r\n" +
-            "AoGBAI8XcwnZi0Sq5N89wF+gFNhnREFo3rsJDaCY8iqHdA5DDlnr3abb/yhipw0I\r\n" +
-            "/1HlgC6fIG2oexXOXFWl+USgqRt1kTt9jXhVFExg8mNko2UelAwFtsl8CRjVcYQO\r\n" +
-            "cedeH/WM/mXjg2wUqqZenBmlKlD6vNb70jFJeVaDJ/7n7j8BAkEA9NkH2D4Zgj/I\r\n" +
-            "OAVYccZYH74+VgO0e7VkUjQk9wtJ2j6cGqJ6Pfj0roVIMUWzoBb8YfErR8l6JnVQ\r\n" +
-            "bfy83gJeiQJBAOHk3ow7JjAn8XuOyZx24KcTaYWKUkAQfRWYDFFOYQF4KV9xLSEt\r\n" +
-            "ycY0kjsdxGKDudWcsATllFzXDCQF6DTNIWECQEA52ePwTjKrVnLTfCLEG4OgHKvl\r\n" +
-            "Zud4amthwDyJWoMEH2ChNB2je1N4JLrABOE+hk+OuoKnKAKEjWd8f3Jg/rkCQHj8\r\n" +
-            "mQmogHqYWikgP/FSZl518jV48Tao3iXbqvU9Mo2T6yzYNCCqIoDLFWseNVnCTZ0Q\r\n" +
-            "b+IfiEf1UeZVV5o4J+ECQDatNnS3V9qYUKjj/krNRD/U0+7eh8S2ylLqD3RlSn9K\r\n" +
-            "tYGRMgAtUXtiOEizBH6bd/orzI9V9sw8yBz+ZqIH25Q=\r\n" +
-            "-----END RSA PRIVATE KEY-----\r\n";
+        "MIICXAIBAAKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoT\r\n" +
+        "M5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRH\r\n" +
+        "r7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB\r\n" +
+        "AoGBAI8XcwnZi0Sq5N89wF+gFNhnREFo3rsJDaCY8iqHdA5DDlnr3abb/yhipw0I\r\n" +
+        "/1HlgC6fIG2oexXOXFWl+USgqRt1kTt9jXhVFExg8mNko2UelAwFtsl8CRjVcYQO\r\n" +
+        "cedeH/WM/mXjg2wUqqZenBmlKlD6vNb70jFJeVaDJ/7n7j8BAkEA9NkH2D4Zgj/I\r\n" +
+        "OAVYccZYH74+VgO0e7VkUjQk9wtJ2j6cGqJ6Pfj0roVIMUWzoBb8YfErR8l6JnVQ\r\n" +
+        "bfy83gJeiQJBAOHk3ow7JjAn8XuOyZx24KcTaYWKUkAQfRWYDFFOYQF4KV9xLSEt\r\n" +
+        "ycY0kjsdxGKDudWcsATllFzXDCQF6DTNIWECQEA52ePwTjKrVnLTfCLEG4OgHKvl\r\n" +
+        "Zud4amthwDyJWoMEH2ChNB2je1N4JLrABOE+hk+OuoKnKAKEjWd8f3Jg/rkCQHj8\r\n" +
+        "mQmogHqYWikgP/FSZl518jV48Tao3iXbqvU9Mo2T6yzYNCCqIoDLFWseNVnCTZ0Q\r\n" +
+        "b+IfiEf1UeZVV5o4J+ECQDatNnS3V9qYUKjj/krNRD/U0+7eh8S2ylLqD3RlSn9K\r\n" +
+        "tYGRMgAtUXtiOEizBH6bd/orzI9V9sw8yBz+ZqIH25Q=\r\n" +
+        "-----END RSA PRIVATE KEY-----\r\n";
     private static final MailetConfiguration DKIMSIGN_MAILET = MailetConfiguration.builder()
-            .matcher(All.class)
-            .mailet(DKIMSign.class)
-            .addProperty(
-                    "signatureTemplate",
-                    "v=1; s=selector; d=example.com; h=from:to:received:received; a=rsa-sha256; bh=; b=;")
-            .addProperty("privateKey", TESTING_PEM)
-            .build();
+        .matcher(All.class)
+        .mailet(DKIMSign.class)
+        .addProperty(
+            "signatureTemplate",
+            "v=1; s=selector; d=example.com; h=from:to:received:received; a=rsa-sha256; bh=; b=;")
+        .addProperty("privateKey", TESTING_PEM)
+        .build();
+
     private static final MailetConfiguration DKIMVERIFY_MAILET = MailetConfiguration.builder()
-            .matcher(All.class)
-            .mailet(DKIMVerify.class)
-            .build();
+        .matcher(All.class)
+        .mailet(DKIMVerify.class)
+        .build();
+
+
     private static final MailetConfiguration STUB_MAILET = MailetConfiguration.builder()
         .matcher(All.class)
         .mailet(ExtractAttributeStub.class)
@@ -105,7 +109,6 @@ public class DKIMIntegrationTest {
     public SMTPMessageSender messageSender = new SMTPMessageSender(DEFAULT_DOMAIN);
 
     private TemporaryJamesServer jamesServer;
-    private DataProbe dataProbe;
     private List<Optional<String>> dkimAuthResults;
 
     @Before
@@ -113,21 +116,20 @@ public class DKIMIntegrationTest {
         dkimAuthResults = new ArrayList<>();
         ExtractAttributeStub.setDkimAuthResultInspector(value -> dkimAuthResults.add(value.map(result -> (String) result)));
         MailetContainer.Builder mailetContainer = TemporaryJamesServer.SIMPLE_MAILET_CONTAINER_CONFIGURATION
-                .putProcessor(ProcessorConfiguration.transport()
-                        .addMailet(DKIMSIGN_MAILET)
-                        .addMailet(DKIMVERIFY_MAILET)
-                        .addMailet(STUB_MAILET)
-                        .addMailetsFrom(CommonProcessors.transport()));
+            .putProcessor(ProcessorConfiguration.transport()
+                .addMailet(DKIMSIGN_MAILET)
+                .addMailet(DKIMVERIFY_MAILET)
+                .addMailet(STUB_MAILET)
+                .addMailetsFrom(CommonProcessors.transport()));
 
         jamesServer = TemporaryJamesServer
             .builder()
-            .withBase(Modules.combine(
-                MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE,
-                binder -> binder.bind(PublicKeyRecordRetriever.class).toInstance(MOCK_PUBLIC_KEY_RECORD_RETRIEVER)))
+            .withBase(MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE)
+            .withOverrides(binder -> binder.bind(PublicKeyRecordRetriever.class).toInstance(MOCK_PUBLIC_KEY_RECORD_RETRIEVER))
             .withMailetContainer(mailetContainer)
             .build(temporaryFolder);
 
-        dataProbe = jamesServer.getProbe(DataProbeImpl.class);
+        DataProbe dataProbe = jamesServer.getProbe(DataProbeImpl.class);
         dataProbe.addDomain(DEFAULT_DOMAIN);
 
         dataProbe.addUser(RECIPIENT, PASSWORD);
diff --git a/server/mailet/mailets-guice/pom.xml b/server/mailet/mailets-guice/pom.xml
deleted file mode 100644
index f91b437..0000000
--- a/server/mailet/mailets-guice/pom.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements. See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership. The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License. You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied. See the License for the
-    specific language governing permissions and limitations
-    under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-    <parent>
-        <groupId>org.apache.james</groupId>
-        <artifactId>james-server</artifactId>
-        <version>3.4.0-SNAPSHOT</version>
-        <relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <artifactId>james-server-mailets-guice</artifactId>
-    <packaging>bundle</packaging>
-
-    <name>Apache James :: Server :: Mailets Guice</name>
-
-    <dependencies>
-        <dependency>
-            <groupId>com.google.inject</groupId>
-            <artifactId>guice</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james.jdkim</groupId>
-            <artifactId>apache-jdkim-library</artifactId>
-            <version>0.2</version>
-        </dependency>
-    </dependencies>
-
-</project>
diff --git a/server/pom.xml b/server/pom.xml
index 025a57e..0d82ea6 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -77,7 +77,6 @@
         <module>mailet/mailetcontainer-api</module>
         <module>mailet/mailetcontainer-camel</module>
         <module>mailet/mailets</module>
-        <module>mailet/mailets-guice</module>
 
         <module>mailrepository/deleted-messages-vault-repository</module>
         <module>mailrepository/mailrepository-api</module>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org