You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by sm...@apache.org on 2026/06/09 05:54:40 UTC
(knox) branch master updated: KNOX-3336: New LDAP Service Factory (#1250)
This is an automated email from the ASF dual-hosted git repository.
smolnar82 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git
The following commit(s) were added to refs/heads/master by this push:
new fafd793d7 KNOX-3336: New LDAP Service Factory (#1250)
fafd793d7 is described below
commit fafd793d74d061e4ad61a567dfb006873c8fccf1
Author: hanicz <ha...@users.noreply.github.com>
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 3f0359976..0afc0dfba 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));
}
@Override
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 4c015979f..5065ea7f1 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
@@ -32,4 +32,5 @@ org.apache.knox.gateway.services.factory.TokenServiceFactory
org.apache.knox.gateway.services.factory.TokenStateServiceFactory
org.apache.knox.gateway.services.factory.TopologyServiceFactory
org.apache.knox.gateway.services.factory.ConcurrentSessionVerifierFactory
-org.apache.knox.gateway.services.factory.GatewayStatusServiceFactory
\ No newline at end of file
+org.apache.knox.gateway.services.factory.GatewayStatusServiceFactory
+org.apache.knox.gateway.services.factory.LdapServiceFactory