diff --git a/base/ca/src/main/java/com/netscape/cms/servlet/admin/PublisherAdminServlet.java b/base/ca/src/main/java/com/netscape/cms/servlet/admin/PublisherAdminServlet.java index ce1a88340c4..057d26cad7a 100644 --- a/base/ca/src/main/java/com/netscape/cms/servlet/admin/PublisherAdminServlet.java +++ b/base/ca/src/main/java/com/netscape/cms/servlet/admin/PublisherAdminServlet.java @@ -61,6 +61,7 @@ import com.netscape.cmscore.apps.CMS; import com.netscape.cmscore.base.ConfigStore; import com.netscape.cmscore.ldap.CAPublisherProcessor; +import com.netscape.cmscore.ldap.LDAPPublishingConfig; import com.netscape.cmscore.ldap.LdapRule; import com.netscape.cmscore.ldap.PublisherProcessor; import com.netscape.cmscore.ldap.PublishingConfig; @@ -449,8 +450,8 @@ private void getLDAPDest(HttpServletRequest req, CAEngine engine = CAEngine.getInstance(); CAConfig config = engine.getConfig().getCAConfig(); PublishingConfig publishcfg = config.getPublishingConfig(); - ConfigStore ldapcfg = publishcfg.getSubStore(PublisherProcessor.PROP_LDAP_PUBLISH_SUBSTORE, ConfigStore.class); - ConfigStore ldap = ldapcfg.getSubStore(PublisherProcessor.PROP_LDAP, ConfigStore.class); + LDAPPublishingConfig ldapcfg = publishcfg.getLDAPPublishingConfig(); + LDAPConfig ldap = ldapcfg.getLDAPConfig(); Enumeration e = req.getParameterNames(); @@ -507,8 +508,7 @@ private void getLDAPDest(HttpServletRequest req, publishcfg.getString(Constants.PR_PUBLISHING_QUEUE_PRIORITY, "0")); params.put(Constants.PR_PUBLISHING_QUEUE_STATUS, publishcfg.getString(Constants.PR_PUBLISHING_QUEUE_STATUS, "200")); - params.put(Constants.PR_ENABLE, - ldapcfg.getString(PublisherProcessor.PROP_ENABLE, Constants.FALSE)); + params.put(Constants.PR_ENABLE, ldapcfg.getEnable()); sendResponse(SUCCESS, null, params, resp); } @@ -520,14 +520,14 @@ private void setLDAPDest(HttpServletRequest req, HttpServletResponse resp) //Save New Settings to the config file PublishingConfig publishcfg = config.getPublishingConfig(); - ConfigStore ldapcfg = publishcfg.getSubStore(PublisherProcessor.PROP_LDAP_PUBLISH_SUBSTORE, ConfigStore.class); - ConfigStore ldap = ldapcfg.getSubStore(PublisherProcessor.PROP_LDAP, ConfigStore.class); + LDAPPublishingConfig ldapcfg = publishcfg.getLDAPPublishingConfig(); + LDAPConfig ldap = ldapcfg.getLDAPConfig(); //set enable flag publishcfg.putString(PublisherProcessor.PROP_ENABLE, req.getParameter(Constants.PR_PUBLISHING_ENABLE)); String enable = req.getParameter(Constants.PR_ENABLE); - ldapcfg.putString(PublisherProcessor.PROP_ENABLE, enable); + ldapcfg.setEnable(enable); if (enable.equals("false")) { // need to disable the ldap module here mProcessor.setLdapConnModule(null); @@ -645,8 +645,8 @@ private void testSetLDAPDest(HttpServletRequest req, HttpServletResponse resp) //Save New Settings to the config file PublishingConfig publishcfg = config.getPublishingConfig(); - ConfigStore ldapcfg = publishcfg.getSubStore(PublisherProcessor.PROP_LDAP_PUBLISH_SUBSTORE, ConfigStore.class); - LDAPConfig ldap = ldapcfg.getSubStore(PublisherProcessor.PROP_LDAP, LDAPConfig.class); + LDAPPublishingConfig ldapcfg = publishcfg.getLDAPPublishingConfig(); + LDAPConfig ldap = ldapcfg.getLDAPConfig(); LDAPAuthenticationConfig authConfig = ldap.getAuthenticationConfig(); //set enable flag @@ -654,7 +654,7 @@ private void testSetLDAPDest(HttpServletRequest req, HttpServletResponse resp) req.getParameter(Constants.PR_PUBLISHING_ENABLE)); String ldapPublish = req.getParameter(Constants.PR_ENABLE); - ldapcfg.putString(PublisherProcessor.PROP_ENABLE, ldapPublish); + ldapcfg.setEnable(ldapPublish); if (ldapPublish.equals("false")) { // need to disable the ldap module here mProcessor.setLdapConnModule(null); @@ -711,7 +711,7 @@ private void testSetLDAPDest(HttpServletRequest req, HttpServletResponse resp) // test before commit if (publishcfg.getBoolean(PublisherProcessor.PROP_ENABLE) && - ldapcfg.getBoolean(PublisherProcessor.PROP_ENABLE)) { + ldapcfg.isEnabled()) { params.put("title", "You've attempted to configure CMS to connect" + " to a LDAP directory. The connection status is" + @@ -908,8 +908,7 @@ private void testSetLDAPDest(HttpServletRequest req, HttpServletResponse resp) } //commit(true); - if (ldapcfg.getBoolean(PublisherProcessor.PROP_ENABLE) && - pwd != null) { + if (ldapcfg.isEnabled() && pwd != null) { /* Do a "PUT" of the new pw to the watchdog" ** do not remove - cfu @@ -952,7 +951,7 @@ private void testSetLDAPDest(HttpServletRequest req, HttpServletResponse resp) mProcessor.startup(); //params.add("restarted", "Publishing is restarted."); - if (ldapcfg.getBoolean(PublisherProcessor.PROP_ENABLE)) { + if (ldapcfg.isEnabled()) { CertificateAuthority ca = mProcessor.getAuthority(); // publish ca cert diff --git a/base/ca/src/main/java/com/netscape/cmscore/ldap/LDAPPublishingConfig.java b/base/ca/src/main/java/com/netscape/cmscore/ldap/LDAPPublishingConfig.java new file mode 100644 index 00000000000..a28199c7ae3 --- /dev/null +++ b/base/ca/src/main/java/com/netscape/cmscore/ldap/LDAPPublishingConfig.java @@ -0,0 +1,52 @@ +// +// Copyright Red Hat, Inc. +// +// SPDX-License-Identifier: GPL-2.0-or-later +// +package com.netscape.cmscore.ldap; + +import com.netscape.certsrv.base.EBaseException; +import com.netscape.certsrv.common.Constants; +import com.netscape.cmscore.base.ConfigStorage; +import com.netscape.cmscore.base.ConfigStore; +import com.netscape.cmscore.base.SimpleProperties; +import com.netscape.cmscore.ldapconn.LDAPConfig; + +/** + * Provides ca.publish.ldappublish.* parameters. + */ +public class LDAPPublishingConfig extends ConfigStore { + + public LDAPPublishingConfig() { + } + + public LDAPPublishingConfig(ConfigStorage storage) { + super(storage); + } + + public LDAPPublishingConfig(String name, SimpleProperties source) { + super(name, source); + } + + /** + * Returns ca.publish.ldappublish.enable parameter. + */ + public boolean isEnabled() throws EBaseException { + return getBoolean("enable", false); + } + + public String getEnable() throws EBaseException { + return getString("enable", Constants.FALSE); + } + + public void setEnable(String enable) throws EBaseException { + putString("enable", enable); + } + + /** + * Returns ca.publish.ldappublish.ldap.* parameters. + */ + public LDAPConfig getLDAPConfig() throws EBaseException { + return getSubStore("ldap", LDAPConfig.class); + } +} diff --git a/base/ca/src/main/java/com/netscape/cmscore/ldap/PublisherProcessor.java b/base/ca/src/main/java/com/netscape/cmscore/ldap/PublisherProcessor.java index 9e66916193e..6955825ee25 100644 --- a/base/ca/src/main/java/com/netscape/cmscore/ldap/PublisherProcessor.java +++ b/base/ca/src/main/java/com/netscape/cmscore/ldap/PublisherProcessor.java @@ -44,8 +44,6 @@ public abstract class PublisherProcessor { public static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PublisherProcessor.class); - public final static String PROP_LDAP_PUBLISH_SUBSTORE = "ldappublish"; - public final static String PROP_CLASS = "class"; public final static String PROP_IMPL = "impl"; public final static String PROP_PLUGIN = "pluginName"; @@ -66,7 +64,7 @@ public abstract class PublisherProcessor { protected LdapConnModule mLdapConnModule; protected PublishingConfig mConfig; - protected ConfigStore mLdapConfig; + protected LDAPPublishingConfig mLdapConfig; protected String mId; protected RequestListener requestListener; @@ -355,8 +353,8 @@ private void initLdapConn(ConfigStore ldapConfig) public void startup() throws EBaseException { logger.debug("PublisherProcessor: startup()"); - mLdapConfig = mConfig.getSubStore(PROP_LDAP_PUBLISH_SUBSTORE, ConfigStore.class); - if (mLdapConfig.getBoolean(PROP_ENABLE, false)) { + mLdapConfig = mConfig.getLDAPPublishingConfig(); + if (mLdapConfig.isEnabled()) { logger.debug("PublisherProcessor: about to initLdapConn"); initLdapConn(mLdapConfig); } else { @@ -813,7 +811,7 @@ public Vector getRuleInstanceParams(String implName) throws */ public boolean ldapEnabled() { try { - return mInited && mLdapConfig.getBoolean(PROP_ENABLE, false); + return mInited && mLdapConfig.isEnabled(); } catch (EBaseException e) { return false; } diff --git a/base/ca/src/main/java/com/netscape/cmscore/ldap/PublishingConfig.java b/base/ca/src/main/java/com/netscape/cmscore/ldap/PublishingConfig.java index 6a7bb8ecb7c..d2483f29233 100644 --- a/base/ca/src/main/java/com/netscape/cmscore/ldap/PublishingConfig.java +++ b/base/ca/src/main/java/com/netscape/cmscore/ldap/PublishingConfig.java @@ -81,4 +81,11 @@ public PublishingRuleConfig getRuleConfig() { public PublishingQueueConfig getQueueConfig() { return getSubStore("queue", PublishingQueueConfig.class); } + + /** + * Returns ca.publish.ldappublish.* parameters. + */ + public LDAPPublishingConfig getLDAPPublishingConfig() { + return getSubStore("ldappublish", LDAPPublishingConfig.class); + } }