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

smolnar82 pushed a commit to branch knox_idf
in repository https://gitbox.apache.org/repos/asf/knox.git

commit 2dfcb1e09f52b0ef0d1d64c84dc412b0602af34e
Author: hanicz <[email protected]>
AuthorDate: Tue Jun 9 07:54:35 2026 +0200

    KNOX-3336: New LDAP Service Factory (#1250)
---
 .../gateway/services/DefaultGatewayServices.java   | 10 +---
 .../services/factory/LdapServiceFactory.java       | 54 ++++++++++++++++++++++
 ...org.apache.knox.gateway.services.ServiceFactory |  3 +-
 3 files changed, 57 insertions(+), 10 deletions(-)

diff --git 
a/gateway-server/src/main/java/org/apache/knox/gateway/services/DefaultGatewayServices.java
 
b/gateway-server/src/main/java/org/apache/knox/gateway/services/DefaultGatewayServices.java
index 0e1c8419c..131d2e1c1 100644
--- 
a/gateway-server/src/main/java/org/apache/knox/gateway/services/DefaultGatewayServices.java
+++ 
b/gateway-server/src/main/java/org/apache/knox/gateway/services/DefaultGatewayServices.java
@@ -21,13 +21,11 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.knox.gateway.GatewayMessages;
-import org.apache.knox.gateway.GatewayServer;
 import org.apache.knox.gateway.config.GatewayConfig;
 import org.apache.knox.gateway.deploy.DeploymentContext;
 import org.apache.knox.gateway.descriptor.FilterParamDescriptor;
 import org.apache.knox.gateway.descriptor.ResourceDescriptor;
 import org.apache.knox.gateway.i18n.messages.MessagesFactory;
-import org.apache.knox.gateway.services.ldap.KnoxLDAPService;
 import org.apache.knox.gateway.services.security.KeystoreService;
 import org.apache.knox.gateway.services.security.KeystoreServiceException;
 import org.apache.knox.gateway.topology.Provider;
@@ -85,13 +83,7 @@ public class DefaultGatewayServices extends 
AbstractGatewayServices {
 
     addService(ServiceType.GATEWAY_STATUS_SERVICE, 
gatewayServiceFactory.create(this, ServiceType.GATEWAY_STATUS_SERVICE, config, 
options));
 
-    // LDAP Service - infrastructure service for embedded LDAP server
-    if (config.isLDAPEnabled()) {
-      KnoxLDAPService ldapService = new KnoxLDAPService();
-      ldapService.init(config, options);
-      GatewayServer.registerConfigChangeListener(ldapService);
-      addService(ServiceType.LDAP_SERVICE, ldapService);
-    }
+    addService(ServiceType.LDAP_SERVICE, gatewayServiceFactory.create(this, 
ServiceType.LDAP_SERVICE, config, options));
 
     addService(ServiceType.KNOXIDF_FEDERATED_IDENTITY_SERVICE, 
gatewayServiceFactory.create(this, 
ServiceType.KNOXIDF_FEDERATED_IDENTITY_SERVICE, config, options));
   }
diff --git 
a/gateway-server/src/main/java/org/apache/knox/gateway/services/factory/LdapServiceFactory.java
 
b/gateway-server/src/main/java/org/apache/knox/gateway/services/factory/LdapServiceFactory.java
new file mode 100644
index 000000000..a02aa2b53
--- /dev/null
+++ 
b/gateway-server/src/main/java/org/apache/knox/gateway/services/factory/LdapServiceFactory.java
@@ -0,0 +1,54 @@
+/*
+ * 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.knox.gateway.services.factory;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.knox.gateway.GatewayServer;
+import org.apache.knox.gateway.config.GatewayConfig;
+import org.apache.knox.gateway.services.GatewayServices;
+import org.apache.knox.gateway.services.Service;
+import org.apache.knox.gateway.services.ServiceLifecycleException;
+import org.apache.knox.gateway.services.ServiceType;
+import org.apache.knox.gateway.services.ldap.KnoxLDAPService;
+
+public class LdapServiceFactory extends AbstractServiceFactory {
+
+    @Override
+    protected Service createService(GatewayServices gatewayServices, 
ServiceType serviceType, GatewayConfig gatewayConfig, Map<String, String> 
options,
+                                    String implementation) throws 
ServiceLifecycleException {
+        Service service = null;
+        if (shouldCreateService(implementation)) {
+            service = new KnoxLDAPService();
+            GatewayServer.registerConfigChangeListener((KnoxLDAPService) 
service);
+        }
+        return service;
+    }
+
+    @Override
+    protected ServiceType getServiceType() {
+        return ServiceType.LDAP_SERVICE;
+    }
+
+    @Override
+    protected Collection<String> getKnownImplementations() {
+        return Collections.singleton(KnoxLDAPService.class.getName());
+    }
+}
diff --git 
a/gateway-server/src/main/resources/META-INF/services/org.apache.knox.gateway.services.ServiceFactory
 
b/gateway-server/src/main/resources/META-INF/services/org.apache.knox.gateway.services.ServiceFactory
index c48af4a58..8c8a4fb1b 100644
--- 
a/gateway-server/src/main/resources/META-INF/services/org.apache.knox.gateway.services.ServiceFactory
+++ 
b/gateway-server/src/main/resources/META-INF/services/org.apache.knox.gateway.services.ServiceFactory
@@ -35,4 +35,5 @@ 
org.apache.knox.gateway.services.factory.ServiceRegistryServiceFactory
 org.apache.knox.gateway.services.factory.SslServiceFactory
 org.apache.knox.gateway.services.factory.TokenStateServiceFactory
 org.apache.knox.gateway.services.factory.TopologyServiceFactory
-org.apache.knox.gateway.services.factory.TokenServiceFactory
\ No newline at end of file
+org.apache.knox.gateway.services.factory.TokenServiceFactory
+org.apache.knox.gateway.services.factory.LdapServiceFactory

Reply via email to