[java-identity-provider] 01/05: IDP-2121 Future Proofing the Module Plugin infrastructure for Future SP use

Rod Widdowson rdw at steadingsoftware.com
Fri Jun 9 09:36:59 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=9760c89f630a2ed087d7558c179ea9bfc43a750e

commit 9760c89f630a2ed087d7558c179ea9bfc43a750e
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Jun 8 17:04:17 2023 +0100

    IDP-2121 Future Proofing the Module Plugin infrastructure for Future SP use
    
    https://shibboleth.atlassian.net/browse/IDP-2121
    
    Move the save and new extensions into the Module Interface.
    Default it for IdP Module.
    Get rid of AbstractIdPModule
---
 .../shibboleth/idp/module/AbstractIdPModule.java   | 44 ----------------------
 .../java/net/shibboleth/idp/module/IdPModule.java  | 24 +++++++++++-
 .../idp/module/PropertyDrivenIdPModule.java        | 18 ++++++++-
 .../net/shibboleth/idp/module/IdPModuleTest.java   |  4 +-
 4 files changed, 42 insertions(+), 48 deletions(-)

diff --git a/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java b/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java
deleted file mode 100644
index a8aefd4b4..000000000
--- a/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.idp.module;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.Version;
-import net.shibboleth.profile.module.AbstractModule;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-
-/**
- * {@link IdPModule} base class implementing basic file management.
- * 
- * @since 4.1.0
- */
-public abstract class AbstractIdPModule extends AbstractModule implements IdPModule {
-
-    /** Extension for preserving user files. */
-    @Nonnull @NotEmpty public static final String IDPSAVE_EXT = ".idpsave";
-
-    /** Base extension for adding new default files. */
-    @Nonnull @NotEmpty public static final String IDPNEW_EXT_BASE = ".idpnew";
-
-    /** Constructor. */
-    public AbstractIdPModule() {
-        super(Version.getVersion(), IDPNEW_EXT_BASE, IDPSAVE_EXT);
-    }
-    
-}
\ No newline at end of file
diff --git a/idp-admin-api/src/main/java/net/shibboleth/idp/module/IdPModule.java b/idp-admin-api/src/main/java/net/shibboleth/idp/module/IdPModule.java
index 6fcce6131..373f01b9a 100644
--- a/idp-admin-api/src/main/java/net/shibboleth/idp/module/IdPModule.java
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/module/IdPModule.java
@@ -17,11 +17,33 @@
 
 package net.shibboleth.idp.module;
 
+import javax.annotation.Nonnull;
+
 import net.shibboleth.profile.module.Module;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
 
 /**
  * This interface is exported (via the service API) by every IdP module.
  * 
  * @since 4.1.0
  */
-public interface IdPModule extends Module {}
+public interface IdPModule extends Module {
+
+    /** Extension for preserving user files. */
+    @Nonnull @NotEmpty public static final String IDPSAVE_EXT = ".idpsave";
+
+    /** Base extension for adding new default files. */
+    @Nonnull @NotEmpty public static final String IDPNEW_EXT_BASE = ".idpnew";
+
+    /** {@inheritDoc} */
+    @Override
+    @Nonnull default String getSaveExtension() {
+        return IDPSAVE_EXT;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    @Nonnull default String getNewExtension() {
+        return IDPNEW_EXT_BASE;
+    }
+}
diff --git a/idp-admin-api/src/main/java/net/shibboleth/idp/module/PropertyDrivenIdPModule.java b/idp-admin-api/src/main/java/net/shibboleth/idp/module/PropertyDrivenIdPModule.java
index bff03880a..2ba392925 100644
--- a/idp-admin-api/src/main/java/net/shibboleth/idp/module/PropertyDrivenIdPModule.java
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/module/PropertyDrivenIdPModule.java
@@ -35,6 +35,8 @@ import org.slf4j.Logger;
 
 import com.google.common.base.Strings;
 
+import net.shibboleth.idp.Version;
+import net.shibboleth.profile.module.AbstractModule;
 import net.shibboleth.profile.module.ModuleContext;
 import net.shibboleth.profile.module.ModuleException;
 import net.shibboleth.shared.annotation.constraint.NonnullElements;
@@ -50,7 +52,7 @@ import net.shibboleth.shared.primitive.StringSupport;
  * 
  * @since 4.1.0
  */
-public class PropertyDrivenIdPModule extends AbstractIdPModule {
+public class PropertyDrivenIdPModule extends AbstractModule implements IdPModule {
 
     /** Default name of module properties resource. */
     @Nonnull @NotEmpty public static final String DEFAULT_RESOURCE = "module.properties";
@@ -143,6 +145,7 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
      */
     public PropertyDrivenIdPModule(@Nonnull final InputStream inputStream)
             throws IOException, ModuleException {
+        super(Version.getVersion());
         locales = CollectionSupport.emptyList();
         moduleProperties = new Properties();
         moduleProperties.load(inputStream);
@@ -159,6 +162,7 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
      * @throws ModuleException if the module is not in a valid state
      */
     public PropertyDrivenIdPModule(@Nonnull final Properties properties) throws ModuleException {
+        super(Version.getVersion());
         locales = CollectionSupport.emptyList();
         moduleProperties = Constraint.isNotNull(properties, "Properties cannot be null");
         moduleId = "";
@@ -351,4 +355,16 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
         return results;
     }
 
+    /** {@inheritDoc} */
+    @Override @Nonnull
+    public String getSaveExtension() {
+        return IdPModule.IDPSAVE_EXT;
+    }
+
+    /** {@inheritDoc} */
+    @Override @Nonnull
+    public String getNewExtension() {
+        return IdPModule.IDPNEW_EXT_BASE;
+    }
+
 }
\ No newline at end of file
diff --git a/idp-admin-api/src/test/java/net/shibboleth/idp/module/IdPModuleTest.java b/idp-admin-api/src/test/java/net/shibboleth/idp/module/IdPModuleTest.java
index 8968c176d..1262ae9f7 100644
--- a/idp-admin-api/src/test/java/net/shibboleth/idp/module/IdPModuleTest.java
+++ b/idp-admin-api/src/test/java/net/shibboleth/idp/module/IdPModuleTest.java
@@ -300,9 +300,9 @@ public class IdPModuleTest {
         final String ver = Version.getVersion();
         final String idpNewExt;
         if (ver != null) {
-            idpNewExt = AbstractIdPModule.IDPNEW_EXT_BASE + "-" + ver.replace(".", "");
+            idpNewExt = IdPModule.IDPNEW_EXT_BASE + "-" + ver.replace(".", "");
         } else {
-            idpNewExt = AbstractIdPModule.IDPNEW_EXT_BASE;
+            idpNewExt = IdPModule.IDPNEW_EXT_BASE;
         }
         vel = Files.readString(testHome.resolve("views/test.vm" + idpNewExt));
         Assert.assertEquals(vel, VEL_DATA);

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


More information about the commits mailing list