[java-identity-provider] 03/03: IDP-2113 Report missing dependency on update of other plugins
Rod Widdowson
rdw at steadingsoftware.com
Mon Aug 21 13:15:24 UTC 2023
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=6b95daa22d61de3d2bee7dd52d3e5166e636100f
commit 6b95daa22d61de3d2bee7dd52d3e5166e636100f
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon Aug 21 13:48:03 2023 +0100
IDP-2113 Report missing dependency on update of other plugins
https://shibboleth.atlassian.net/browse/IDP-2113
Check the plugins at boot time to see if they have all the modules
that they need.
---
.../idp/admin/impl/ReportModuleStatus.java | 98 ++++++++++++++++++++++
.../net/shibboleth/idp/conf/admin-system.xml | 7 ++
2 files changed, 105 insertions(+)
diff --git a/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/ReportModuleStatus.java b/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/ReportModuleStatus.java
new file mode 100644
index 000000000..9efb0f745
--- /dev/null
+++ b/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/ReportModuleStatus.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed 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 net.shibboleth.idp.admin.impl;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.ServiceLoader;
+import java.util.Set;
+
+import javax.annotation.Nonnull;
+
+import org.slf4j.Logger;
+
+import net.shibboleth.idp.module.IdPModule;
+import net.shibboleth.idp.plugin.IdPPlugin;
+import net.shibboleth.profile.module.ModuleContext;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
+import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
+
+/**
+ * Class to check that every {@link IdPPlugin} the required {@link IdPModule} available.
+ */
+public class ReportModuleStatus extends AbstractIdentifiableInitializableComponent {
+
+ /** Log. */
+ private final Logger log = LoggerFactory.getLogger(ReportModuleStatus.class);
+
+ /** The IdOP Home dir. */
+ @Nonnull private String idpHome="";
+
+ /** Where IdP Home is.
+ * @param input what to set.
+ */
+ public void setIdpHome(@Nonnull @NotEmpty String input) {
+ idpHome = Constraint.isNotNull(input, "IdpHome not set");
+ }
+
+ /** Return all the enabled modules.
+ * @return the module ids
+ */
+ @Nonnull private Set<String> getEnabledModules() {
+ final HashSet<String> result = new HashSet<>();
+ final ModuleContext mc = new ModuleContext(idpHome);
+ final Iterator<IdPModule> modules = ServiceLoader.load(IdPModule.class).iterator();
+ while (modules.hasNext()) {
+ final IdPModule module = modules.next();
+ if (module.isEnabled(mc)) {
+ log.trace("Found enabled Module {}", module.getId());
+ result.add(module.getId());
+ } else {
+ log.trace("Found disabled Module {}", module.getId());
+
+ }
+ }
+ return result;
+ }
+
+ /** Check whether any plugin required a non enabled plugin.
+ * @param enabledModules
+ */
+ private void checkPlugins(@Nonnull Set<String> enabledModules) {
+ final Iterator<IdPPlugin> plugins = ServiceLoader.load(IdPPlugin.class).iterator();
+ while (plugins.hasNext()) {
+ final IdPPlugin plugin = plugins.next();
+ log.debug("Checking required modules for plugin {}", plugin.getPluginId());
+ for (final String module : plugin.getRequiredModules()) {
+ if (enabledModules.contains(module)) {
+ log.debug("Found required module {}", module);
+ } else {
+ log.error("Module {} required by plugin {} not found", module, plugin.getPluginId());
+ }
+ }
+ }
+ }
+
+
+ /** {@inheritDoc} */
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
+ checkPlugins(getEnabledModules());
+ }
+
+}
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/admin-system.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/admin-system.xml
index 6fc786194..1d8bb305e 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/admin-system.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/admin-system.xml
@@ -361,4 +361,11 @@
p:httpClient-ref="%{idp.updateCheck.httpClient:shibboleth.InternalHttpClient}"
p:securityParams="#{ environment.containsProperty('idp.updateCheck.httpSecurityParameters') ? getObject('idp.updateCheck.httpSecurityParameters') :null}"/>
+ <!-- Used to check module enabled state -->
+ <bean id="shibboleth.CheckPluginModules"
+ class="net.shibboleth.idp.admin.impl.ReportModuleStatus"
+ lazy-init="false"
+ depends-on="shibboleth.LoggingService"
+ p:idpHome="%{idp.home}" />
+
</beans>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list