[java-shib-profile] branch main updated: IDP-2121 Future Proofing the Module Plugin infrastructure for Future SP use

Rod Widdowson rdw at steadingsoftware.com
Thu Jun 8 13:33:49 UTC 2023


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository java-shib-profile.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-profile.git;a=commit;h=8572cec2d440218c1c16e5146e76030fbb4a1a23

The following commit(s) were added to refs/heads/main by this push:
     new 8572cec  IDP-2121 Future Proofing the Module Plugin infrastructure for Future SP use
8572cec is described below

commit 8572cec2d440218c1c16e5146e76030fbb4a1a23
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Jun 8 14:25:25 2023 +0100

    IDP-2121 Future Proofing the Module Plugin infrastructure for Future SP use
    
    https://shibboleth.atlassian.net/browse/IDP-2121
    
    Introduce net.shibboleth.profile.plugin.Plugin and
    net.shibboleth.profile.plugin.AbstractPlugin
---
 .../shibboleth/profile/plugin/AbstractPlugin.java  | 121 +++++++++++++++++++++
 .../java/net/shibboleth/profile/plugin/Plugin.java | 108 ++++++++++++++++++
 .../shibboleth/profile/plugin/package-info.java    |  24 ++++
 3 files changed, 253 insertions(+)

diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/plugin/AbstractPlugin.java b/shib-profile-api/src/main/java/net/shibboleth/profile/plugin/AbstractPlugin.java
new file mode 100644
index 0000000..9d30ecf
--- /dev/null
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/plugin/AbstractPlugin.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID 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 net.shibboleth.profile.plugin;
+
+import java.util.Set;
+
+import javax.annotation.Nonnegative;
+import javax.annotation.Nonnull;
+
+import net.shibboleth.profile.module.Module;
+import net.shibboleth.shared.annotation.constraint.NonnullElements;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.annotation.constraint.NotLive;
+import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.collection.CollectionSupport;
+
+/**
+ * A base class implementing {@link Plugin} that defaults common settings.
+ * 
+ * @param <T> What sort of module this could implement
+ * @since 9.0.0
+ */
+public abstract class AbstractPlugin<T extends Module> implements Plugin<T> {
+    
+    /** Modules to enable on install. */
+    @Nonnull @NonnullElements private Set<T> enableModules;
+
+    /** Modules to disable on removal. */
+    @Nonnull @NonnullElements private Set<T> disableModules;
+
+    /** Constructor. */
+    public AbstractPlugin() {
+        enableModules = CollectionSupport.emptySet();
+        disableModules = CollectionSupport.emptySet();
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull @NotEmpty public String getPluginId() {
+        final String result = getClass().getPackageName();
+        assert result != null;
+        return result;
+    }
+
+    /** {@inheritDoc} */
+    @Nonnegative public int getPatchVersion() {
+        return 0;
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull @Unmodifiable @NotLive public Set<String> getRequiredModules() {
+        return CollectionSupport.emptySet();
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull @Unmodifiable @NotLive public Set<T> getEnableOnInstall() {
+        return enableModules;
+    }
+
+    /** {@inheritDoc} */
+    public String getLicenseFileLocation() {
+        return null;
+    }
+
+    /**
+     * Set the modules to enable on install.
+     * 
+     * @param modules modules to enable
+     */
+    protected void setEnableOnInstall(@Nonnull @NonnullElements final Set<T> modules) {
+        enableModules = CollectionSupport.copyToSet(modules);
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull @Unmodifiable @NotLive public Set<T> getDisableOnRemoval() {
+        return disableModules;
+    }
+
+    /**
+     * Set the modules to disable on removal.
+     * 
+     * @param modules modules to disable
+     */
+    protected void setDisableOnRemoval(@Nonnull @NonnullElements final Set<T> modules) {
+        disableModules = CollectionSupport.copyToSet(modules);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean equals(final Object obj) {
+        return obj instanceof Plugin && getPluginId().equals(((Plugin<?>) obj).getPluginId());
+    }
+
+
+    /** {@inheritDoc} */
+    @Override
+    public int hashCode() {
+        return getPluginId().hashCode();
+    }
+    
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return "Plugin " + getPluginId();
+    }
+
+}
\ No newline at end of file
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/plugin/Plugin.java b/shib-profile-api/src/main/java/net/shibboleth/profile/plugin/Plugin.java
new file mode 100644
index 0000000..9de86fa
--- /dev/null
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/plugin/Plugin.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID 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 net.shibboleth.profile.plugin;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.Nonnegative;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import net.shibboleth.profile.module.Module;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.annotation.constraint.NotLive;
+import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+
+/**
+ * The base interface for plugins into the IdP and SP.
+ * 
+ * @since 9.0.0
+ */
+public interface Plugin<T extends Module> {
+    
+    /** Return the unique identifier for the plugin.  This name <em>MUST</em> be
+     * <ul>
+     * <li> renderable in all file systems (for instance alphanumerics, '-' and '.' only)</li>
+     * <li> unique.  This is best done using java module guidance</li>
+     * </ul>
+     * For instance <code>org.example.plugins.myplugin</code>
+     *
+     * @return The id of this plugin.
+     */
+    @Nonnull @NotEmpty String getPluginId();
+
+    /** Return the places to look for information for this plugin package.
+     * The format of the (property) file at this location is fixed.
+     * 
+     * @return Zero or more URLs
+     * @throws IOException if the resource construction failed.
+     */
+    @Nonnull @Unmodifiable @NotLive List<URL> getUpdateURLs() throws IOException;
+    
+    /** Return the major version, (as defined by the 
+     * <a href="https://wiki.shibboleth.net/confluence/display/DEV/Java+Product+Version+Policy">
+     * Java Product Version Policy</a>.
+     * @return The major version.
+     */
+    @Nonnegative int getMajorVersion();
+
+    /** Return the minor version, (as defined by the 
+     * <a href="https://wiki.shibboleth.net/confluence/display/DEV/Java+Product+Version+Policy">
+     * Java Product Version Policy</a>.
+     * @return The minor version.
+     */
+    @Nonnegative int getMinorVersion();
+    
+    /** Return The patch version, (as defined by the 
+     * <a href="https://wiki.shibboleth.net/confluence/display/DEV/Java+Product+Version+Policy">
+     * Java Product Version Policy</a>.
+     * @return The patch version.
+     */
+    @Nonnegative int getPatchVersion();
+    
+    /** Return the classpath location of the license file to emit
+     * when --license is specified.
+     * @return the location
+     */
+    @Nullable String getLicenseFileLocation();
+
+    /**
+     * Get the IDs of any {@link Module}s required for installation of this plugin.
+     * 
+     * @return module IDs that are required
+     */
+    @Nonnull @Unmodifiable @NotLive Set<String> getRequiredModules();
+
+    /**
+     * Get the modules to enable after plugin installation or upgrade.
+     * 
+     * @return modules to enable
+     */
+    @Nonnull @Unmodifiable @NotLive Set<T> getEnableOnInstall();
+
+    /**
+     * Get the modules to disable after plugin removal.
+     * 
+     * @return modules to disable
+     */
+    @Nonnull @Unmodifiable @NotLive Set<T> getDisableOnRemoval();
+
+}
\ No newline at end of file
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/plugin/package-info.java b/shib-profile-api/src/main/java/net/shibboleth/profile/plugin/package-info.java
new file mode 100644
index 0000000..89aec5a
--- /dev/null
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/plugin/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID 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.
+ */
+
+/**
+ * Classes for plugins.
+ */
+ at NonnullElements
+package net.shibboleth.profile.plugin;
+
+import net.shibboleth.shared.annotation.constraint.NonnullElements;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list