JAMES-4025 Drop JMAP draft guice binding
diff --git a/server/container/guice/protocols/jmap/pom.xml b/server/container/guice/protocols/jmap/pom.xml
index 58bd487..ace63a7 100644
--- a/server/container/guice/protocols/jmap/pom.xml
+++ b/server/container/guice/protocols/jmap/pom.xml
@@ -29,7 +29,7 @@
<artifactId>james-server-guice-jmap</artifactId>
<name>Apache James :: Server :: Guice :: JMAP</name>
- <description>JMAP (draft and RFC8621) modules for Guice implementation of James server</description>
+ <description>JMAP RFC8621 modules for Guice implementation of James server</description>
<dependencies>
<dependency>
@@ -59,10 +59,6 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-jmap-draft</artifactId>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
<artifactId>james-server-jmap-rfc-8621</artifactId>
</dependency>
<dependency>
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
index 7f7ff39..741d05a 100644
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
+++ b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
@@ -19,7 +19,6 @@
package org.apache.james.jmap;
import java.io.FileNotFoundException;
-import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.Clock;
import java.util.EnumSet;
@@ -47,10 +46,6 @@
import org.apache.james.jmap.core.SubmissionCapabilityFactory;
import org.apache.james.jmap.core.VacationResponseCapabilityFactory$;
import org.apache.james.jmap.core.WebSocketCapabilityFactory$;
-import org.apache.james.jmap.draft.DraftMethodsModule;
-import org.apache.james.jmap.draft.JMAPDraftCommonModule;
-import org.apache.james.jmap.draft.JMAPDraftConfiguration;
-import org.apache.james.jmap.draft.methods.RequestHandler;
import org.apache.james.jmap.mailet.filter.JMAPFiltering;
import org.apache.james.jmap.rfc8621.RFC8621MethodsModule;
import org.apache.james.jmap.send.PostDequeueDecoratorFactory;
@@ -120,16 +115,13 @@
@Override
protected void configure() {
- install(new JMAPDraftCommonModule());
install(new JMAPWithoutDraftCommonModule());
- install(new DraftMethodsModule());
install(new RFC8621MethodsModule());
install(binder -> binder
.bind(MailetContainerModule.DefaultProcessorsConfigurationSupplier.class)
.toInstance(DEFAULT_JMAP_PROCESSORS_CONFIGURATION_SUPPLIER));
bind(JMAPServer.class).in(Scopes.SINGLETON);
- bind(RequestHandler.class).in(Scopes.SINGLETON);
bind(JsoupHtmlTextExtractor.class).in(Scopes.SINGLETON);
bind(HtmlTextExtractor.class).to(JsoupHtmlTextExtractor.class);
@@ -228,35 +220,19 @@
@Provides
@Singleton
- JMAPDraftConfiguration provideDraftConfiguration(PropertiesProvider propertiesProvider, FileSystem fileSystem) throws ConfigurationException, IOException {
+ @Named("jmap")
+ JwtTokenVerifier providesJwtTokenVerifier(PropertiesProvider propertiesProvider, FileSystem fileSystem) throws ConfigurationException {
try {
Configuration configuration = propertiesProvider.getConfiguration("jmap");
- return JMAPDraftConfiguration.builder()
- .enabled(configuration.getBoolean("enabled", true))
- .keystore(configuration.getString("tls.keystoreURL", null))
- .privateKey(configuration.getString("tls.privateKey", null))
- .certificates(configuration.getString("tls.certificates", null))
- .keystoreType(configuration.getString("tls.keystoreType", null))
- .secret(configuration.getString("tls.secret", null))
- .jwtPublicKeyPem(loadPublicKey(fileSystem, ImmutableList.copyOf(configuration.getStringArray("jwt.publickeypem.url"))))
- .authenticationStrategies(Optional.ofNullable(configuration.getList(String.class, "authentication.strategy.draft", null)))
- .build();
+ List<String> loadedPublicKey = loadPublicKey(fileSystem, ImmutableList.copyOf(configuration.getStringArray("jwt.publickeypem.url")));
+ JwtConfiguration jwtConfiguration = new JwtConfiguration(loadedPublicKey);
+ return JwtTokenVerifier.create(jwtConfiguration);
} catch (FileNotFoundException e) {
- LOGGER.warn("Could not find JMAP configuration file. JMAP server will not be enabled.");
- return JMAPDraftConfiguration.builder()
- .disable()
- .build();
+ LOGGER.warn("Could not find JMAP configuration file. JwtTokenVerifier was initialized with empty public key ");
+ return JwtTokenVerifier.create(new JwtConfiguration(List.of()));
}
}
- @Provides
- @Singleton
- @Named("jmap")
- JwtTokenVerifier providesJwtTokenVerifier(JMAPDraftConfiguration jmapConfiguration) {
- JwtConfiguration jwtConfiguration = new JwtConfiguration(jmapConfiguration.getJwtPublicKeyPem());
- return JwtTokenVerifier.create(jwtConfiguration);
- }
-
private List<String> loadPublicKey(FileSystem fileSystem, List<String> jwtPublickeyPemUrl) {
return jwtPublickeyPemUrl.stream()
.map(Throwing.function(url -> FileUtils.readFileToString(fileSystem.getFile(url), StandardCharsets.US_ASCII)))
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPWithoutDraftCommonModule.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPWithoutDraftCommonModule.java
index 4bef219..3e645f7 100644
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPWithoutDraftCommonModule.java
+++ b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPWithoutDraftCommonModule.java
@@ -19,6 +19,9 @@
package org.apache.james.jmap;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.james.jmap.api.access.AccessTokenRepository;
import org.apache.james.jmap.json.ObjectMapperFactory;
import org.apache.james.jmap.methods.BlobManager;
import org.apache.james.jmap.methods.BlobManagerImpl;
@@ -34,8 +37,10 @@
import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
+import com.google.inject.name.Names;
public class JMAPWithoutDraftCommonModule extends AbstractModule {
+ private static final long DEFAULT_TOKEN_EXPIRATION_IN_MS = TimeUnit.MILLISECONDS.convert(15, TimeUnit.MINUTES);
@Override
protected void configure() {
@@ -53,5 +58,7 @@
bind(ObjectMapperFactory.class).in(Scopes.SINGLETON);
bind(JmapResponseWriterImpl.class).in(Scopes.SINGLETON);
bind(JmapResponseWriter.class).to(JmapResponseWriterImpl.class);
+
+ bindConstant().annotatedWith(Names.named(AccessTokenRepository.TOKEN_EXPIRATION_IN_MS)).to(DEFAULT_TOKEN_EXPIRATION_IN_MS);
}
}
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/DraftMethodsModule.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/DraftMethodsModule.java
deleted file mode 100644
index e9ccbb2..0000000
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/DraftMethodsModule.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************
- * 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.jmap.draft;
-
-import java.util.List;
-import java.util.Set;
-
-import org.apache.james.jmap.draft.methods.GetFilterMethod;
-import org.apache.james.jmap.draft.methods.GetMailboxesMethod;
-import org.apache.james.jmap.draft.methods.GetMessageListMethod;
-import org.apache.james.jmap.draft.methods.GetMessagesMethod;
-import org.apache.james.jmap.draft.methods.GetVacationResponseMethod;
-import org.apache.james.jmap.draft.methods.JmapRequestParser;
-import org.apache.james.jmap.draft.methods.JmapRequestParserImpl;
-import org.apache.james.jmap.draft.methods.SendMDNProcessor;
-import org.apache.james.jmap.draft.methods.SetFilterMethod;
-import org.apache.james.jmap.draft.methods.SetMailboxesCreationProcessor;
-import org.apache.james.jmap.draft.methods.SetMailboxesDestructionProcessor;
-import org.apache.james.jmap.draft.methods.SetMailboxesMethod;
-import org.apache.james.jmap.draft.methods.SetMailboxesProcessor;
-import org.apache.james.jmap.draft.methods.SetMailboxesUpdateProcessor;
-import org.apache.james.jmap.draft.methods.SetMessagesCreationProcessor;
-import org.apache.james.jmap.draft.methods.SetMessagesDestructionProcessor;
-import org.apache.james.jmap.draft.methods.SetMessagesMethod;
-import org.apache.james.jmap.draft.methods.SetMessagesProcessor;
-import org.apache.james.jmap.draft.methods.SetMessagesUpdateProcessor;
-import org.apache.james.jmap.draft.methods.SetVacationResponseMethod;
-import org.apache.james.jmap.http.AccessTokenAuthenticationStrategy;
-import org.apache.james.jmap.http.AuthenticationStrategy;
-import org.apache.james.jmap.http.Authenticator;
-import org.apache.james.jmap.http.InjectionKeys;
-import org.apache.james.jmap.http.JWTAuthenticationStrategy;
-import org.apache.james.jmap.http.QueryParameterAccessTokenAuthenticationStrategy;
-import org.apache.james.jmap.methods.Method;
-import org.apache.james.metrics.api.MetricFactory;
-import org.apache.james.utils.ClassName;
-import org.apache.james.utils.GuiceGenericLoader;
-import org.apache.james.utils.NamingScheme;
-import org.apache.james.utils.PackageName;
-
-import com.github.fge.lambdas.Throwing;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.Scopes;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-import com.google.inject.name.Named;
-import com.google.inject.name.Names;
-
-public class DraftMethodsModule extends AbstractModule {
- private static PackageName IMPLICIT_AUTHENTICATION_STRATEGY_FQDN_PREFIX = PackageName.of("org.apache.james.jmap.http");
- private static List<String> DEFAULT_AUTHENTICATION_STRATEGIES = ImmutableList.of(AccessTokenAuthenticationStrategy.class.getSimpleName(),
- JWTAuthenticationStrategy.class.getSimpleName(),
- QueryParameterAccessTokenAuthenticationStrategy.class.getSimpleName());
-
- @Override
- protected void configure() {
- bind(JmapRequestParserImpl.class).in(Scopes.SINGLETON);
- bind(JmapRequestParser.class).to(JmapRequestParserImpl.class);
-
- bindConstant().annotatedWith(Names.named(GetMessageListMethod.MAXIMUM_LIMIT)).to(GetMessageListMethod.DEFAULT_MAXIMUM_LIMIT);
-
- Multibinder<Method> methods = Multibinder.newSetBinder(binder(), Method.class);
- methods.addBinding().to(GetMailboxesMethod.class);
- methods.addBinding().to(GetMessageListMethod.class);
- methods.addBinding().to(GetMessagesMethod.class);
- methods.addBinding().to(SetMessagesMethod.class);
- methods.addBinding().to(SetMailboxesMethod.class);
- methods.addBinding().to(GetVacationResponseMethod.class);
- methods.addBinding().to(SetVacationResponseMethod.class);
- methods.addBinding().to(GetFilterMethod.class);
- methods.addBinding().to(SetFilterMethod.class);
-
- Multibinder<SetMailboxesProcessor> setMailboxesProcessor =
- Multibinder.newSetBinder(binder(), SetMailboxesProcessor.class);
- setMailboxesProcessor.addBinding().to(SetMailboxesCreationProcessor.class);
- setMailboxesProcessor.addBinding().to(SetMailboxesUpdateProcessor.class);
- setMailboxesProcessor.addBinding().to(SetMailboxesDestructionProcessor.class);
-
- Multibinder<SetMessagesProcessor> setMessagesProcessors =
- Multibinder.newSetBinder(binder(), SetMessagesProcessor.class);
- setMessagesProcessors.addBinding().to(SetMessagesUpdateProcessor.class);
- setMessagesProcessors.addBinding().to(SetMessagesCreationProcessor.class);
- setMessagesProcessors.addBinding().to(SetMessagesDestructionProcessor.class);
- setMessagesProcessors.addBinding().to(SendMDNProcessor.class);
- }
-
- @Provides
- @Named(InjectionKeys.DRAFT)
- Authenticator provideAuthenticator(MetricFactory metricFactory,
- @Named("draftJmapAuthenticationStrategies") Set<AuthenticationStrategy> strategies) {
- return Authenticator.of(metricFactory, strategies);
- }
-
- @Provides
- @Singleton
- @Named("draftJmapAuthenticationStrategies")
- public Set<AuthenticationStrategy> provideAuthenticationStrategies(GuiceGenericLoader loader,
- JMAPDraftConfiguration configuration) {
- return configuration.getAuthenticationStrategies()
- .orElse(DEFAULT_AUTHENTICATION_STRATEGIES)
- .stream()
- .map(ClassName::new)
- .map(Throwing.function(loader.<AuthenticationStrategy>withNamingSheme(
- new NamingScheme.OptionalPackagePrefix(IMPLICIT_AUTHENTICATION_STRATEGY_FQDN_PREFIX))::instantiate))
- .collect(ImmutableSet.toImmutableSet());
- }
-}
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPConfigurationStartUpCheck.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPConfigurationStartUpCheck.java
deleted file mode 100644
index 30766ed..0000000
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPConfigurationStartUpCheck.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************
- * 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.jmap.draft;
-
-import jakarta.inject.Inject;
-
-import org.apache.james.jmap.draft.crypto.SecurityKeyLoader;
-import org.apache.james.lifecycle.api.StartUpCheck;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JMAPConfigurationStartUpCheck implements StartUpCheck {
- private static final Logger LOGGER = LoggerFactory.getLogger(JMAPConfigurationStartUpCheck.class);
- public static final String CHECK_NAME = "JMAPConfigurationStartUpCheck";
-
- private final SecurityKeyLoader securityKeyLoader;
- private final JMAPDraftConfiguration jmapConfiguration;
-
- @Inject
- JMAPConfigurationStartUpCheck(SecurityKeyLoader securityKeyLoader, JMAPDraftConfiguration jmapConfiguration) {
- this.securityKeyLoader = securityKeyLoader;
- this.jmapConfiguration = jmapConfiguration;
- }
-
- @Override
- public CheckResult check() {
- if (jmapConfiguration.isEnabled()) {
- return checkSecurityKey();
- }
-
- return CheckResult.builder()
- .checkName(checkName())
- .resultType(ResultType.GOOD)
- .build();
- }
-
- private CheckResult checkSecurityKey() {
- try {
- securityKeyLoader.load();
- return CheckResult.builder()
- .checkName(checkName())
- .resultType(ResultType.GOOD)
- .build();
- } catch (Exception e) {
- LOGGER.error("Cannot load security key from jmap configuration", e);
- return CheckResult.builder()
- .checkName(checkName())
- .resultType(ResultType.BAD)
- .description(e.getMessage())
- .build();
- }
- }
-
- @Override
- public String checkName() {
- return CHECK_NAME;
- }
-}
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPDraftCommonModule.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPDraftCommonModule.java
deleted file mode 100644
index 5b4f147..0000000
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPDraftCommonModule.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************
- * 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.jmap.draft;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.james.jmap.api.access.AccessTokenRepository;
-import org.apache.james.jmap.draft.api.AccessTokenManager;
-import org.apache.james.jmap.draft.api.SimpleTokenFactory;
-import org.apache.james.jmap.draft.api.SimpleTokenManager;
-import org.apache.james.jmap.draft.crypto.AccessTokenManagerImpl;
-import org.apache.james.jmap.draft.crypto.JamesSignatureHandler;
-import org.apache.james.jmap.draft.crypto.SecurityKeyLoader;
-import org.apache.james.jmap.draft.crypto.SignatureHandler;
-import org.apache.james.jmap.draft.crypto.SignedTokenFactory;
-import org.apache.james.jmap.draft.crypto.SignedTokenManager;
-import org.apache.james.jmap.draft.model.MailboxFactory;
-import org.apache.james.jmap.draft.send.MailSpool;
-import org.apache.james.lifecycle.api.ConfigurationSanitizer;
-import org.apache.james.lifecycle.api.StartUpCheck;
-import org.apache.james.utils.InitializationOperation;
-import org.apache.james.utils.InitilizationOperationBuilder;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
-import com.google.inject.multibindings.Multibinder;
-import com.google.inject.multibindings.ProvidesIntoSet;
-import com.google.inject.name.Names;
-
-public class JMAPDraftCommonModule extends AbstractModule {
-
- private static final long DEFAULT_TOKEN_EXPIRATION_IN_MS = TimeUnit.MILLISECONDS.convert(15, TimeUnit.MINUTES);
-
- @Override
- protected void configure() {
- bind(JamesSignatureHandler.class).in(Scopes.SINGLETON);
- bind(SignedTokenManager.class).in(Scopes.SINGLETON);
- bind(AccessTokenManagerImpl.class).in(Scopes.SINGLETON);
- bind(MailSpool.class).in(Scopes.SINGLETON);
- bind(MailboxFactory.class).in(Scopes.SINGLETON);
- bind(SecurityKeyLoader.class).in(Scopes.SINGLETON);
-
- bind(SignatureHandler.class).to(JamesSignatureHandler.class);
-
- bind(SimpleTokenManager.class).to(SignedTokenManager.class);
- bind(SimpleTokenFactory.class).to(SignedTokenFactory.class);
-
- bindConstant().annotatedWith(Names.named(AccessTokenRepository.TOKEN_EXPIRATION_IN_MS)).to(DEFAULT_TOKEN_EXPIRATION_IN_MS);
- bind(AccessTokenManager.class).to(AccessTokenManagerImpl.class);
-
- Multibinder.newSetBinder(binder(), StartUpCheck.class)
- .addBinding().to(JMAPConfigurationStartUpCheck.class);
-
- Multibinder.newSetBinder(binder(), ConfigurationSanitizer.class)
- .addBinding().to(JmapConfigurationSanitizer.class);
- }
-
- @ProvidesIntoSet
- InitializationOperation workQueue(MailSpool instance) {
- return InitilizationOperationBuilder
- .forClass(MailSpool.class)
- .init(instance::start);
- }
-}
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JmapConfigurationSanitizer.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JmapConfigurationSanitizer.java
deleted file mode 100644
index c63e114..0000000
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JmapConfigurationSanitizer.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************
- * 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.jmap.draft;
-
-import java.io.FileNotFoundException;
-
-import jakarta.inject.Inject;
-
-import org.apache.james.RunArguments;
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.lifecycle.api.ConfigurationSanitizer;
-import org.apache.james.utils.KeystoreCreator;
-
-public class JmapConfigurationSanitizer implements ConfigurationSanitizer {
- private final JMAPDraftConfiguration jmapDraftConfiguration;
- private final KeystoreCreator keystoreCreator;
- private final FileSystem fileSystem;
- private final RunArguments runArguments;
-
- @Inject
- public JmapConfigurationSanitizer(JMAPDraftConfiguration jmapDraftConfiguration, KeystoreCreator keystoreCreator, FileSystem fileSystem, RunArguments runArguments) {
- this.jmapDraftConfiguration = jmapDraftConfiguration;
- this.keystoreCreator = keystoreCreator;
- this.fileSystem = fileSystem;
- this.runArguments = runArguments;
- }
-
- @Override
- public void sanitize() throws Exception {
- if (jmapDraftConfiguration.isEnabled()
- && jmapDraftConfiguration.getKeystore().isPresent()
- && !keystoreExists()
- && runArguments.contain(RunArguments.Argument.GENERATE_KEYSTORE)) {
-
- keystoreCreator.generateKeystore(jmapDraftConfiguration.getKeystore().get(),
- jmapDraftConfiguration.getSecret()
- .orElseThrow(() -> new IllegalArgumentException("Can not auto-generate keystore as the keystore secret is missing from the configuration")),
- jmapDraftConfiguration.getKeystoreType());
- }
- }
-
- private boolean keystoreExists() {
- try {
- return fileSystem.getFile(jmapDraftConfiguration.getKeystore().get()).exists();
- } catch (FileNotFoundException e) {
- return false;
- }
- }
-}
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java
index a0d0371..637f0a6 100644
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java
+++ b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java
@@ -23,16 +23,10 @@
import org.apache.james.jmap.JMAPConfiguration;
import org.apache.james.jmap.JMAPModule;
-import org.apache.james.jmap.JMAPRoutesHandler;
import org.apache.james.jmap.JMAPServer;
import org.apache.james.jmap.JmapGuiceProbe;
import org.apache.james.jmap.MessageIdProbe;
-import org.apache.james.jmap.Version;
-import org.apache.james.jmap.draft.crypto.JamesSignatureHandler;
-import org.apache.james.jmap.http.AuthenticationRoutes;
-import org.apache.james.jmap.http.DownloadRoutes;
-import org.apache.james.jmap.http.JMAPApiRoutes;
-import org.apache.james.jmap.http.UploadRoutes;
+import org.apache.james.jmap.methods.Method;
import org.apache.james.utils.GuiceProbe;
import org.apache.james.utils.InitializationOperation;
import org.apache.james.utils.InitilizationOperationBuilder;
@@ -49,33 +43,22 @@
install(new JMAPModule());
Multibinder.newSetBinder(binder(), GuiceProbe.class).addBinding().to(JmapGuiceProbe.class);
Multibinder.newSetBinder(binder(), GuiceProbe.class).addBinding().to(MessageIdProbe.class);
+
+ Multibinder.newSetBinder(binder(), Method.class);
}
@ProvidesIntoSet
- InitializationOperation startJmap(JMAPServer server, JamesSignatureHandler signatureHandler, JMAPConfiguration jmapConfiguration) {
+ InitializationOperation startJmap(JMAPServer server, JMAPConfiguration jmapConfiguration) {
return InitilizationOperationBuilder
.forClass(JMAPServer.class)
.init(() -> {
if (jmapConfiguration.isEnabled()) {
- signatureHandler.init();
server.start();
registerPEMWithSecurityProvider();
}
});
}
- @ProvidesIntoSet
- JMAPRoutesHandler routesHandler(AuthenticationRoutes authenticationRoutes,
- JMAPApiRoutes jmapApiRoutes,
- UploadRoutes uploadRoutes,
- DownloadRoutes downloadRoutes) {
- return new JMAPRoutesHandler(Version.DRAFT,
- authenticationRoutes,
- jmapApiRoutes,
- uploadRoutes,
- downloadRoutes);
- }
-
private void registerPEMWithSecurityProvider() {
Security.addProvider(new BouncyCastleProvider());
}
diff --git a/server/container/guice/protocols/jmap/src/test/java/org/apache/james/modules/TestJMAPServerModule.java b/server/container/guice/protocols/jmap/src/test/java/org/apache/james/modules/TestJMAPServerModule.java
index 9f4541f..7b70263 100644
--- a/server/container/guice/protocols/jmap/src/test/java/org/apache/james/modules/TestJMAPServerModule.java
+++ b/server/container/guice/protocols/jmap/src/test/java/org/apache/james/modules/TestJMAPServerModule.java
@@ -22,41 +22,20 @@
import java.io.FileNotFoundException;
import java.util.Optional;
+import jakarta.inject.Named;
import jakarta.inject.Singleton;
import org.apache.commons.configuration2.ex.ConfigurationException;
import org.apache.james.jmap.JMAPConfiguration;
-import org.apache.james.jmap.draft.JMAPDraftConfiguration;
-import org.apache.james.jmap.draft.methods.GetMessageListMethod;
-import org.apache.james.jmap.pushsubscription.PushClientConfiguration;
+import org.apache.james.jwt.JwtConfiguration;
+import org.apache.james.jwt.JwtTokenVerifier;
import org.apache.james.modules.mailbox.FastRetryBackoffModule;
import com.google.common.collect.ImmutableList;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
-import com.google.inject.name.Names;
public class TestJMAPServerModule extends AbstractModule {
- public static class SearchModule extends AbstractModule {
- public static final long LIMIT_TO_3_MESSAGES = 3;
-
- public static SearchModule maximumMessages(long maximumLimit) {
- return new SearchModule(maximumLimit);
- }
-
- private final long maximumLimit;
-
- public SearchModule(long maximumLimit) {
- this.maximumLimit = maximumLimit;
- }
-
- @Override
- protected void configure() {
- bindConstant().annotatedWith(Names.named(GetMessageListMethod.MAXIMUM_LIMIT)).to(maximumLimit);
-
- bind(PushClientConfiguration.class).toInstance(PushClientConfiguration.UNSAFE_DEFAULT());
- }
- }
private static final String PUBLIC_PEM_KEY =
"-----BEGIN PUBLIC KEY-----\n" +
@@ -101,14 +80,6 @@
"ICQil1aaN7/2au+p7E4n7nzfYG7nRX5syDoqgBbdhpJxV8/5ohA=\n" +
"-----END RSA PRIVATE KEY-----\n";
- public static JMAPDraftConfiguration.Builder jmapDraftConfigurationBuilder() {
- return JMAPDraftConfiguration.builder()
- .enable()
- .keystore("keystore")
- .keystoreType("JKS")
- .secret("james72laBalle")
- .jwtPublicKeyPem(ImmutableList.of(PUBLIC_PEM_KEY));
- }
@Override
protected void configure() {
@@ -128,7 +99,8 @@
@Provides
@Singleton
- JMAPDraftConfiguration provideDraftConfiguration() throws FileNotFoundException, ConfigurationException {
- return jmapDraftConfigurationBuilder().build();
+ @Named("jmap")
+ JwtTokenVerifier providesJwtTokenVerifier() {
+ return JwtTokenVerifier.create(new JwtConfiguration(ImmutableList.of(PUBLIC_PEM_KEY)));
}
}