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

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


The following commit(s) were added to refs/heads/3.9.x by this push:
     new 07506a753c JAMES-4160 Add LegacyReadOnlyUsersLDAPRepository for Spring 
users using LDAP
07506a753c is described below

commit 07506a753c3e1d26bbc6a3363f6f3eb50b1b7200
Author: Benoit TELLIER <[email protected]>
AuthorDate: Tue Jan 13 17:30:55 2026 +0100

    JAMES-4160 Add LegacyReadOnlyUsersLDAPRepository for Spring users using LDAP
---
 .../ldap/LegacyReadOnlyUsersLDAPRepository.java    | 134 +++++++++++++++++++++
 upgrade-instructions.md                            |   7 ++
 2 files changed, 141 insertions(+)

diff --git 
a/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/LegacyReadOnlyUsersLDAPRepository.java
 
b/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/LegacyReadOnlyUsersLDAPRepository.java
new file mode 100644
index 0000000000..8bd00978de
--- /dev/null
+++ 
b/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/LegacyReadOnlyUsersLDAPRepository.java
@@ -0,0 +1,134 @@
+/****************************************************************
+ * 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.user.ldap;
+
+import java.util.Iterator;
+import java.util.Optional;
+
+import jakarta.inject.Inject;
+
+import org.apache.commons.configuration2.HierarchicalConfiguration;
+import org.apache.commons.configuration2.ex.ConfigurationException;
+import org.apache.commons.configuration2.tree.ImmutableNode;
+import org.apache.james.core.MailAddress;
+import org.apache.james.core.Username;
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.lifecycle.api.Configurable;
+import org.apache.james.metrics.api.GaugeRegistry;
+import org.apache.james.user.api.UsersRepository;
+import org.apache.james.user.api.UsersRepositoryException;
+import org.apache.james.user.api.model.User;
+import org.reactivestreams.Publisher;
+
+/**
+ * Spring support: do not attempt to mutualize the LDAP connection pool.
+ */
+public class LegacyReadOnlyUsersLDAPRepository implements Configurable, 
UsersRepository {
+    private final DomainList domainList;
+    private final GaugeRegistry gaugeRegistry;
+    private ReadOnlyUsersLDAPRepository delegate;
+
+    @Inject
+    public LegacyReadOnlyUsersLDAPRepository(DomainList domainList,
+                                             GaugeRegistry gaugeRegistry) {
+        this.domainList = domainList;
+        this.gaugeRegistry = gaugeRegistry;
+    }
+
+    @Override
+    public void configure(HierarchicalConfiguration<ImmutableNode> config) 
throws ConfigurationException {
+        try {
+            delegate = new ReadOnlyUsersLDAPRepository(domainList, 
gaugeRegistry, LdapRepositoryConfiguration.from(config));
+        } catch (Exception e) {
+            throw new ConfigurationException(e);
+        }
+        delegate.configure(config);
+    }
+
+    @Override
+    public void addUser(Username username, String password) throws 
UsersRepositoryException {
+        delegate.addUser(username, password);
+    }
+
+    @Override
+    public User getUserByName(Username name) throws UsersRepositoryException {
+        return delegate.getUserByName(name);
+    }
+
+    @Override
+    public void updateUser(User user) throws UsersRepositoryException {
+        delegate.updateUser(user);
+    }
+
+    @Override
+    public void removeUser(Username name) throws UsersRepositoryException {
+        delegate.removeUser(name);
+    }
+
+    @Override
+    public boolean contains(Username name) throws UsersRepositoryException {
+        return delegate.contains(name);
+    }
+
+    @Override
+    public Publisher<Boolean> containsReactive(Username name) {
+        return delegate.containsReactive(name);
+    }
+
+    @Override
+    public Optional<Username> test(Username name, String password) throws 
UsersRepositoryException {
+        return delegate.test(name, password);
+    }
+
+    @Override
+    public int countUsers() throws UsersRepositoryException {
+        return delegate.countUsers();
+    }
+
+    @Override
+    public Iterator<Username> list() throws UsersRepositoryException {
+        return delegate.list();
+    }
+
+    @Override
+    public Publisher<Username> listReactive() {
+        return delegate.listReactive();
+    }
+
+    @Override
+    public boolean supportVirtualHosting() {
+        return delegate.supportVirtualHosting();
+    }
+
+    @Override
+    public MailAddress getMailAddressFor(Username username) throws 
UsersRepositoryException {
+        return delegate.getMailAddressFor(username);
+    }
+
+    @Override
+    public boolean isAdministrator(Username username) throws 
UsersRepositoryException {
+        return delegate.isAdministrator(username);
+    }
+
+    @Override
+    public boolean isReadOnly() {
+        return delegate.isReadOnly();
+    }
+}
diff --git a/upgrade-instructions.md b/upgrade-instructions.md
index 5550a2bfc7..6153210449 100644
--- a/upgrade-instructions.md
+++ b/upgrade-instructions.md
@@ -42,6 +42,13 @@ Change list:
  - [JAMES-4118 Cleanup message previews](#james-4118-cleanup-message-previews)
  - [JAMES-4128 Breaking Mailet API 
changes](#james-4128-breaking-mailet-api-changes)
 
+### JAMES-4160 LDAP with spring update
+Date: 13/01/2026
+
+JIRA: https://issues.apache.org/jira/browse/JAMES-4160
+
+Users using Spring in addition with LDAP usersrepository needs to use 
`org.apache.james.user.ldap.LegacyReadOnlyUsersLDAPRepository` instead.
+
 ### JAMES-4128 Breaking Mailet API changes
 Date: 02/04/2025
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to