[java-identity-provider] branch master updated: IDP-1595 <pve plugin support classes to idp-admin

Rod Widdowson rdw at steadingsoftware.com
Wed Jul 15 14:19:08 UTC 2020


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

rdw pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=0a3e2f8e85e38e950c7929a2bb3690e4d031fbcc

The following commit(s) were added to refs/heads/master by this push:
       new  0a3e2f8e8 IDP-1595 <pve plugin support classes to idp-admin
0a3e2f8e8 is described below

commit 0a3e2f8e85e38e950c7929a2bb3690e4d031fbcc
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Jul 15 15:17:04 2020 +0100

    IDP-1595 <pve plugin support classes to idp-admin
    
    https://issues.shibboleth.net/jira/browse/IDP-1595
    
    Leaving the bare minimum back in idp-installer to allow
    old style plugins to continue to exist as we make the transition.
---
 idp-admin-api/pom.xml                              |   5 +
 .../idp/plugin/AbstractPluginDescription.java      |  53 ++-
 .../shibboleth/idp/plugin/PluginDescription.java   | 129 +++++++
 .../net/shibboleth/idp}/plugin/PluginSupport.java  |   2 +-
 .../net/shibboleth/idp}/plugin/PluginVersion.java  |   2 +-
 .../net/shibboleth/idp}/plugin/package-info.java   |   4 +-
 .../shibboleth/idp}/plugin/PluginVersionTest.java  |   2 +-
 .../shibboleth/idp}/plugin/impl/PluginState.java   |  11 +-
 .../shibboleth/idp/plugin/impl}/package-info.java  |   4 +-
 ...ializeAdministrativeProfileContextTreeTest.java |   1 +
 .../shibboleth/idp/plugin}/PluginStateTest.java    |   5 +-
 .../net/shibboleth/idp/plugin}/TestPlugin.java     |   6 +-
 .../1.2.3/version.details.properties               |   0
 .../1.2.4/version.details.properties               |   0
 .../2.0.0/version.details.properties               |   0
 .../net.shibboleth.plugin.test/versions.properties |   0
 idp-installer/pom.xml                              |  10 +
 .../idp/installer/plugin/impl/PluginInstaller.java |   2 +-
 .../idp/installer/plugin/impl/PluginState.java     | 391 ++-------------------
 .../installer/plugin/impl/PluginInstallerTest.java |   4 +-
 20 files changed, 221 insertions(+), 410 deletions(-)

diff --git a/idp-admin-api/pom.xml b/idp-admin-api/pom.xml
index de6a9f5d0..9e8e8aa58 100644
--- a/idp-admin-api/pom.xml
+++ b/idp-admin-api/pom.xml
@@ -27,6 +27,11 @@
             <artifactId>idp-profile-api</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>idp-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>idp-authn-api</artifactId>
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/TestPlugin.java b/idp-admin-api/src/main/java/net/shibboleth/idp/plugin/AbstractPluginDescription.java
similarity index 54%
copy from idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/TestPlugin.java
copy to idp-admin-api/src/main/java/net/shibboleth/idp/plugin/AbstractPluginDescription.java
index fd7506394..5f761dd19 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/TestPlugin.java
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/plugin/AbstractPluginDescription.java
@@ -15,56 +15,49 @@
  * limitations under the License.
  */
 
-package net.shibboleth.idp.installer.plugin.impl;
+package net.shibboleth.idp.plugin;
 
 import java.io.IOException;
 import java.net.URL;
+import java.nio.file.Path;
 import java.util.Collections;
 import java.util.List;
 
-import org.springframework.core.io.ClassPathResource;
+import javax.annotation.Nonnegative;
+import javax.annotation.Nonnull;
 
-import net.shibboleth.utilities.java.support.plugin.AbstractPluginDescription;
+import com.google.common.annotations.Beta;
+
+import net.shibboleth.utilities.java.support.collection.Pair;
 
 /**
- *
+ * A base class {@link PluginDescription} which defaults many common settings.
  */
-public class TestPlugin extends AbstractPluginDescription {
-
+ at Beta
+public abstract class AbstractPluginDescription implements PluginDescription {
+    
     /** {@inheritDoc} */
-    @Override
-    public String getPluginId() {
-        // TODO Auto-generated method stub
-        return "net.shibboleth.plugin.test";
+    @Nonnull public List<String> getAdditionalPropertyFiles() {
+        return Collections.emptyList();
     }
-
+    
     /** {@inheritDoc} */
-    @Override
-    public List<URL> getUpdateURLs() {
-        ClassPathResource resource = new ClassPathResource("/net/shibboleth/idp/installer/plugin/");
-        try {
-            return Collections.singletonList(resource.getURL());
-        } catch (IOException e) {
-            return Collections.EMPTY_LIST;
-        }
+    @Nonnull public List<Path> getFilePathsToCopy() {
+        return Collections.emptyList();
     }
-
+    
     /** {@inheritDoc} */
-    @Override
-    public int getMajorVersion() {
-        return 1;
+    @Nonnull public List<Pair<URL, Path>> getExternalFilePathsToCopy() throws IOException {
+        return Collections.emptyList();
     }
 
     /** {@inheritDoc} */
-    @Override
-    public int getMinorVersion() {
-        return 2;
+    @Nonnull public List<Pair<Path, List<String>>> getPropertyMerges() {
+        return Collections.emptyList();
     }
     
-
     /** {@inheritDoc} */
-    @Override
-    public int getPatchVersion() {
-        return 3;
+    @Nonnegative public int getPatchVersion() {
+        return 0;
     }
 }
diff --git a/idp-admin-api/src/main/java/net/shibboleth/idp/plugin/PluginDescription.java b/idp-admin-api/src/main/java/net/shibboleth/idp/plugin/PluginDescription.java
new file mode 100644
index 000000000..34848b2a4
--- /dev/null
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/plugin/PluginDescription.java
@@ -0,0 +1,129 @@
+/*
+ * 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.plugin;
+
+import java.io.IOException;
+import java.net.URL;
+import java.nio.file.Path;
+import java.util.List;
+
+import javax.annotation.Nonnegative;
+import javax.annotation.Nonnull;
+
+import com.google.common.annotations.Beta;
+
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.annotation.constraint.Positive;
+import net.shibboleth.utilities.java.support.collection.Pair;
+
+/**
+ * This interface is exported (via the service API) by every IdP plugin.
+ */
+ at Beta
+public interface PluginDescription {
+    
+    /** 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 public String getPluginId();
+
+    /** Return the list of file names to be appended to
+     * <code>idp.additional.properties</code>.
+     * @return The list of names, potentially empty.
+     */
+    @Nonnull public List<String> getAdditionalPropertyFiles();
+    
+    /** Return the list of (idp.home) relative paths (of files, <em>not directories </em>) 
+     * to copy from the distribution into the IdP installation.
+     *
+     * <em>Not currently supported</em>
+     * 
+     * <p>These files are copied non-destructively (if the file already exists
+     * then it is not copied).  Some paths are disallowed (for instance dist and system).
+     * Directories are created if needed</p>
+     * <p>
+     * The dist folder is always copied, so no files from it should be included.</p>
+     *
+     * @return The list of paths.
+     */
+    @Nonnull public List<Path> getFilePathsToCopy();
+    
+    /** <p>Return the list of files <em>not directories </em> to get from 'external'
+     * sources. This allows external content to be downloaded during installation.</p>
+     *
+     * <p>The first part of the pair is the source URL,
+     * the second is a path relative to idp.home.  These can include files
+     * going to dist\edit-webapp in which case the path is expected to have the
+     * plugin id appended. Sub directories are created if needed</p>
+     *
+     * @return The list.
+     * @throws IOException if the resource construction failed.
+     */
+    @Nonnull public List<Pair<URL, Path>> getExternalFilePathsToCopy() throws IOException;
+
+    /** Return the places to look for updates for this plugin package.
+     * The format of the paths below this point is fixed.
+     * 
+     * @return Zero or more URLs
+     * @throws IOException if the resource construction failed.
+     */
+    @Nonnull @NonnullElements public List<URL> getUpdateURLs() throws IOException;
+    
+    /** Return this properties that require list merging.  
+     * 
+     * <em>Not currently supported</em>
+     * 
+     * <p>Given
+     * an property called (say) <code>idp.service.foo</code> in file <code>services.property</code>
+     * and an init setting of <code>idp.service.foo.bar</code>, the output would be:</p>
+     * <pre> idp.service.foo = BEAN.idp.service.foo.plugin-id.net.shibboleth.foo
+     * idp.service.foo.OLD.plugin-id = shibboleth.AttributeFilterResources</pre>
+     *
+     * @return A list of pairs, the first element of the pair is the (relative) path of the property file
+     * and the second is a list of property names to edit within that file.
+     */
+    @Nonnull public List<Pair<Path, List<String>>> getPropertyMerges();
+    
+    /** 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.
+     */
+    @Positive public 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 public 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 public int getPatchVersion();
+}
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/PluginSupport.java b/idp-admin-api/src/main/java/net/shibboleth/idp/plugin/PluginSupport.java
similarity index 98%
rename from idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/PluginSupport.java
rename to idp-admin-api/src/main/java/net/shibboleth/idp/plugin/PluginSupport.java
index 3066947ca..19566d1e8 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/PluginSupport.java
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/plugin/PluginSupport.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package net.shibboleth.idp.installer.plugin;
+package net.shibboleth.idp.plugin;
 
 import javax.annotation.Nonnull;
 
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/PluginVersion.java b/idp-admin-api/src/main/java/net/shibboleth/idp/plugin/PluginVersion.java
similarity index 99%
rename from idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/PluginVersion.java
rename to idp-admin-api/src/main/java/net/shibboleth/idp/plugin/PluginVersion.java
index 152ba986c..1430b60ba 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/PluginVersion.java
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/plugin/PluginVersion.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package net.shibboleth.idp.installer.plugin;
+package net.shibboleth.idp.plugin;
 
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
 
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/package-info.java b/idp-admin-api/src/main/java/net/shibboleth/idp/plugin/package-info.java
similarity index 90%
copy from idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/package-info.java
copy to idp-admin-api/src/main/java/net/shibboleth/idp/plugin/package-info.java
index a5a053ca1..47cbcce07 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/package-info.java
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/plugin/package-info.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 /**
- * Publuc information for handling plugins.
+ * A set of APIs of general use in building IdP plugins.
  */
 
-package net.shibboleth.idp.installer.plugin;
\ No newline at end of file
+package net.shibboleth.idp.plugin;
\ No newline at end of file
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/PluginVersionTest.java b/idp-admin-api/src/test/java/net/shibboleth/idp/plugin/PluginVersionTest.java
similarity index 98%
rename from idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/PluginVersionTest.java
rename to idp-admin-api/src/test/java/net/shibboleth/idp/plugin/PluginVersionTest.java
index d666f867a..0cbd666f3 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/PluginVersionTest.java
+++ b/idp-admin-api/src/test/java/net/shibboleth/idp/plugin/PluginVersionTest.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package net.shibboleth.idp.installer.plugin;
+package net.shibboleth.idp.plugin;
 
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginState.java b/idp-admin-impl/src/main/java/net/shibboleth/idp/plugin/impl/PluginState.java
similarity index 98%
copy from idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginState.java
copy to idp-admin-impl/src/main/java/net/shibboleth/idp/plugin/impl/PluginState.java
index 60480fc25..b619f3739 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginState.java
+++ b/idp-admin-impl/src/main/java/net/shibboleth/idp/plugin/impl/PluginState.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package net.shibboleth.idp.installer.plugin.impl;
+package net.shibboleth.idp.plugin.impl;
 
 import java.io.IOException;
 import java.net.URL;
@@ -34,8 +34,9 @@ import org.springframework.core.io.FileSystemResource;
 import org.springframework.core.io.Resource;
 
 import net.shibboleth.ext.spring.resource.HTTPResource;
-import net.shibboleth.idp.installer.plugin.PluginSupport;
-import net.shibboleth.idp.installer.plugin.PluginVersion;
+import net.shibboleth.idp.plugin.PluginDescription;
+import net.shibboleth.idp.plugin.PluginSupport;
+import net.shibboleth.idp.plugin.PluginVersion;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
@@ -43,14 +44,13 @@ import net.shibboleth.utilities.java.support.component.ComponentInitializationEx
 import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.httpclient.HttpClientBuilder;
 import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.plugin.PluginDescription;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
 
 /**
  * A class which will answer questions about a plugin state as of now
  * (by querying the information Resources for the current published state). 
  */
-public final class PluginState extends AbstractInitializableComponent {
+public class PluginState extends AbstractInitializableComponent {
 
     /** regexp for spaces. */
     private static final Pattern SPACE_CONTAINING = Pattern.compile("\\s+");
@@ -84,6 +84,7 @@ public final class PluginState extends AbstractInitializableComponent {
                 plugin.getMinorVersion(), plugin.getPatchVersion());
     }
     
+    
     /** Set the client.
      * @param what what to set.
      */
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/package-info.java b/idp-admin-impl/src/main/java/net/shibboleth/idp/plugin/impl/package-info.java
similarity index 90%
rename from idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/package-info.java
rename to idp-admin-impl/src/main/java/net/shibboleth/idp/plugin/impl/package-info.java
index a5a053ca1..7df4a807e 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/package-info.java
+++ b/idp-admin-impl/src/main/java/net/shibboleth/idp/plugin/impl/package-info.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 /**
- * Publuc information for handling plugins.
+ * Implementation classes for handling plugins.
  */
 
-package net.shibboleth.idp.installer.plugin;
\ No newline at end of file
+package net.shibboleth.idp.plugin.impl;
\ No newline at end of file
diff --git a/idp-admin-impl/src/test/java/net/shibboleth/idp/admin/impl/InitializeAdministrativeProfileContextTreeTest.java b/idp-admin-impl/src/test/java/net/shibboleth/idp/admin/impl/InitializeAdministrativeProfileContextTreeTest.java
index 68731a5f6..082875fd9 100644
--- a/idp-admin-impl/src/test/java/net/shibboleth/idp/admin/impl/InitializeAdministrativeProfileContextTreeTest.java
+++ b/idp-admin-impl/src/test/java/net/shibboleth/idp/admin/impl/InitializeAdministrativeProfileContextTreeTest.java
@@ -42,6 +42,7 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 /** {@link InitializeAdministrativeProfileContextTree} unit test. */
+ at SuppressWarnings("javadoc")
 public class InitializeAdministrativeProfileContextTreeTest extends OpenSAMLInitBaseTestCase {
 
     private RequestContext src;
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginStateTest.java b/idp-admin-impl/src/test/java/net/shibboleth/idp/plugin/PluginStateTest.java
similarity index 95%
rename from idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginStateTest.java
rename to idp-admin-impl/src/test/java/net/shibboleth/idp/plugin/PluginStateTest.java
index 09ec97478..e4a0a5c1d 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginStateTest.java
+++ b/idp-admin-impl/src/test/java/net/shibboleth/idp/plugin/PluginStateTest.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package net.shibboleth.idp.installer.plugin.impl;
+package net.shibboleth.idp.plugin;
 
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
@@ -29,9 +29,8 @@ import java.util.List;
 
 import org.testng.annotations.Test;
 
-import net.shibboleth.idp.installer.plugin.PluginVersion;
+import net.shibboleth.idp.plugin.impl.PluginState;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.plugin.PluginDescription;
 
 /**
  * Tests for {@link PluginState}.
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/TestPlugin.java b/idp-admin-impl/src/test/java/net/shibboleth/idp/plugin/TestPlugin.java
similarity index 91%
rename from idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/TestPlugin.java
rename to idp-admin-impl/src/test/java/net/shibboleth/idp/plugin/TestPlugin.java
index fd7506394..f90779f9c 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/TestPlugin.java
+++ b/idp-admin-impl/src/test/java/net/shibboleth/idp/plugin/TestPlugin.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package net.shibboleth.idp.installer.plugin.impl;
+package net.shibboleth.idp.plugin;
 
 import java.io.IOException;
 import java.net.URL;
@@ -24,8 +24,6 @@ import java.util.List;
 
 import org.springframework.core.io.ClassPathResource;
 
-import net.shibboleth.utilities.java.support.plugin.AbstractPluginDescription;
-
 /**
  *
  */
@@ -41,7 +39,7 @@ public class TestPlugin extends AbstractPluginDescription {
     /** {@inheritDoc} */
     @Override
     public List<URL> getUpdateURLs() {
-        ClassPathResource resource = new ClassPathResource("/net/shibboleth/idp/installer/plugin/");
+        ClassPathResource resource = new ClassPathResource("/net/shibboleth/idp/plugin/");
         try {
             return Collections.singletonList(resource.getURL());
         } catch (IOException e) {
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/installer/plugin/net.shibboleth.plugin.test/1.2.3/version.details.properties b/idp-admin-impl/src/test/resources/net/shibboleth/idp/plugin/net.shibboleth.plugin.test/1.2.3/version.details.properties
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/installer/plugin/net.shibboleth.plugin.test/1.2.3/version.details.properties
rename to idp-admin-impl/src/test/resources/net/shibboleth/idp/plugin/net.shibboleth.plugin.test/1.2.3/version.details.properties
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/installer/plugin/net.shibboleth.plugin.test/1.2.4/version.details.properties b/idp-admin-impl/src/test/resources/net/shibboleth/idp/plugin/net.shibboleth.plugin.test/1.2.4/version.details.properties
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/installer/plugin/net.shibboleth.plugin.test/1.2.4/version.details.properties
rename to idp-admin-impl/src/test/resources/net/shibboleth/idp/plugin/net.shibboleth.plugin.test/1.2.4/version.details.properties
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/installer/plugin/net.shibboleth.plugin.test/2.0.0/version.details.properties b/idp-admin-impl/src/test/resources/net/shibboleth/idp/plugin/net.shibboleth.plugin.test/2.0.0/version.details.properties
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/installer/plugin/net.shibboleth.plugin.test/2.0.0/version.details.properties
rename to idp-admin-impl/src/test/resources/net/shibboleth/idp/plugin/net.shibboleth.plugin.test/2.0.0/version.details.properties
diff --git a/idp-installer/src/test/resources/net/shibboleth/idp/installer/plugin/net.shibboleth.plugin.test/versions.properties b/idp-admin-impl/src/test/resources/net/shibboleth/idp/plugin/net.shibboleth.plugin.test/versions.properties
similarity index 100%
rename from idp-installer/src/test/resources/net/shibboleth/idp/installer/plugin/net.shibboleth.plugin.test/versions.properties
rename to idp-admin-impl/src/test/resources/net/shibboleth/idp/plugin/net.shibboleth.plugin.test/versions.properties
diff --git a/idp-installer/pom.xml b/idp-installer/pom.xml
index 42323fca6..f36378999 100644
--- a/idp-installer/pom.xml
+++ b/idp-installer/pom.xml
@@ -33,6 +33,16 @@
             <artifactId>idp-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>idp-admin-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>idp-admin-impl</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         
         <dependency>
             <groupId>${project.groupId}</groupId>
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
index 7c3802967..98c9582d4 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
@@ -61,6 +61,7 @@ import net.shibboleth.ext.spring.resource.HTTPResource;
 import net.shibboleth.idp.installer.BuildWar;
 import net.shibboleth.idp.installer.InstallerSupport;
 import net.shibboleth.idp.installer.plugin.impl.TrustStore.Signature;
+import net.shibboleth.idp.plugin.PluginDescription;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.collection.Pair;
@@ -68,7 +69,6 @@ import net.shibboleth.utilities.java.support.component.AbstractInitializableComp
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 import net.shibboleth.utilities.java.support.httpclient.HttpClientBuilder;
 import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.plugin.PluginDescription;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
 import net.shibboleth.utilities.java.support.resource.Resource;
 
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginState.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginState.java
index 60480fc25..b0c9853dc 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginState.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginState.java
@@ -19,380 +19,55 @@ package net.shibboleth.idp.installer.plugin.impl;
 
 import java.io.IOException;
 import java.net.URL;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Pattern;
+import java.nio.file.Path;
+import java.util.List;
 
 import javax.annotation.Nonnull;
 
-import org.apache.http.client.HttpClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.io.FileSystemResource;
-import org.springframework.core.io.Resource;
-
-import net.shibboleth.ext.spring.resource.HTTPResource;
-import net.shibboleth.idp.installer.plugin.PluginSupport;
-import net.shibboleth.idp.installer.plugin.PluginVersion;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.httpclient.HttpClientBuilder;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.plugin.PluginDescription;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
+import net.shibboleth.idp.plugin.PluginDescription;
+import net.shibboleth.utilities.java.support.collection.Pair;
 
 /**
  * A class which will answer questions about a plugin state as of now
  * (by querying the information Resources for the current published state). 
  */
-public final class PluginState extends AbstractInitializableComponent {
-
-    /** regexp for spaces. */
-    private static final Pattern SPACE_CONTAINING = Pattern.compile("\\s+");
-
-    /** The plug in in question. */
-    @Nonnull private final PluginDescription plugin;
-    
-    /** The version of this plugin. */
-    @Nonnull private final PluginVersion myPluginVersion;
-    
-    /** The support information. */
-    @Nonnull private final Map<PluginVersion, VersionInfo> versionInfo = new HashMap<>();
-
-    /** My support information. */
-    @NonnullAfterInit private VersionInfo myVersionInfo;
-    
-    /** Class logger. */
-    @Nonnull private final Logger log = LoggerFactory.getLogger(PluginState.class);
-    
-    /** The HttpClient to use.*/
-    @NonnullAfterInit private HttpClient httpClient;
+ at Deprecated public final class PluginState extends net.shibboleth.idp.plugin.impl.PluginState {
 
     /**
      * Constructor.
      *
-     * @param description what we are talking about.
-     */
-    public PluginState(@Nonnull final PluginDescription description) {
-        plugin = Constraint.isNotNull(description, "Plugin must not be null");
-        myPluginVersion = new PluginVersion(plugin.getMajorVersion(), 
-                plugin.getMinorVersion(), plugin.getPatchVersion());
-    }
-    
-    /** Set the client.
-     * @param what what to set.
-     */
-    public void setHttpClient(@Nonnull final HttpClient what) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-        httpClient = Constraint.isNotNull(what, "HttpClient must be non null");
-    }
-
-    /** Given a version find out more.
-     * @param parentResource the root we are looking at
-     * @param version the version in question.
-     * @return true if we processed everything OK.
-     */
-    // Checkstyle: CyclomaticComplexity OFF
-    private boolean handleAvailableVersion(final Resource parentResource, final String version) {
-        final Properties detailsProps = new Properties(3);
-        final PluginVersion theVersion = new PluginVersion(version);
-        if (theVersion.getMajor() == 0 && theVersion.getMinor() == 0 && theVersion.getPatch() == 0) {
-            log.warn("Plugin {}: improbable version {}", plugin.getPluginId(), version);
-        }
-        if (versionInfo.containsKey(theVersion)) {
-            log.warn("Plugin {}: Duplicate version {}", plugin.getPluginId(), version);
-        }
-        
-        try {
-            final Resource details = parentResource.createRelative(version + "/")
-                    .createRelative(PluginSupport.VERSION_INFO_PATH);
-            detailsProps.load(details.getInputStream());
-        } catch (final IOException e) {
-            log.warn("Could not find details description {}, version {} ", plugin.getPluginId(), version, e);
-            return false;
-        }
-        log.debug("Plugin {}: Version details : {}", plugin.getPluginId(), detailsProps);
-        final String maxVersionInfo = StringSupport.trimOrNull(detailsProps.getProperty(PluginSupport.MAX_IDP_VERSION));
-        if (maxVersionInfo == null) {
-            log.warn("Plugin {}: Could not find max idp version for version {} ", plugin.getPluginId(), version);
-            return false;
-        }
-        final String minVersionInfo = StringSupport.trimOrNull(detailsProps.getProperty(PluginSupport.MIN_IDP_VERSION));
-        if (minVersionInfo == null) {
-            log.warn("Plugin {}: Could not find min idp version for version {} ", plugin.getPluginId(), version);
-            return false;
-        }
-        final String supportLevel = StringSupport.trimOrNull(detailsProps.getProperty(PluginSupport.SUPPORT_LEVEL));
-        if (supportLevel == null) {
-            log.warn("Plugin {}: Could not find support level for {}, version {} ", plugin.getPluginId(), version);
-            return false;
-        }
-        log.debug("Plugin {}: MaxIdP {}, MinIdP {}, Support Level {}", 
-                plugin.getPluginId(), maxVersionInfo, minVersionInfo, supportLevel);
-        final VersionInfo info; 
-        try {
-            info = new VersionInfo(
-                new PluginVersion(maxVersionInfo),
-                new PluginVersion(minVersionInfo),
-                Integer.parseInt(supportLevel));
-        } catch (final NumberFormatException e) {
-            log.warn("Plugin {}: version {}: Could not parse version info",
-                    plugin.getPluginId(), version, e);
-            return false;
-        }
-        versionInfo.put(theVersion, info);
-        if (myPluginVersion.equals(theVersion)) {
-            myVersionInfo = info;
-        }
-        return true;
-    }
-    // Checkstyle: CyclomaticComplexity ON
-
-    /** Given a list of versions find out more.
-     * @param parentResource the root we are looking at
-     * @param availableVersions a space delimited array of versions
-     * @return true if we processed everything OK.
+     * @param description old style description
      */
-    private boolean handleAvailableVersions(final Resource parentResource, final String availableVersions) {
-        final String[] versions = SPACE_CONTAINING.split(availableVersions, 0);
-
-        log.debug("Plugin {}: available versions : {} ", plugin.getPluginId(), availableVersions);
-        for (final String version:versions) {
-            log.debug("Plugin {} : considering {}", plugin.getPluginId(), version);
-            if (!handleAvailableVersion(parentResource, version)) {
-                return false;
-           }
-        }
-        return true;
-    }
-    
-    /** (try to) populate the information about this plugin.
-     * @param parentResource where to start looking
-     * @return whether it worked
-     */
-    protected boolean populate(@Nonnull final Resource parentResource) {
-        
-        final Resource pluginIdResource;
-        try {
-            pluginIdResource = 
-                    parentResource.createRelative(plugin.getPluginId() + "/");
-            if (!pluginIdResource.exists()) {
-                log.debug("Plugin {}: directory at {} could not be found",
-                        plugin.getPluginId(), parentResource.getDescription());
-                return false;
+    @Deprecated
+    public PluginState(@Nonnull final net.shibboleth.utilities.java.support.plugin.PluginDescription description) {
+        super(new PluginDescription() {            
+            public List<URL> getUpdateURLs() throws IOException {
+                return description.getUpdateURLs();
             }
-        } catch (final IOException e) {
-            log.info("Plugin{}: problems open directory at {}",
-                        plugin.getPluginId(), parentResource.getDescription(), e);
-            return false;
-        }
-        try {
-            final Resource versionsResource =
-                    pluginIdResource.createRelative(PluginSupport.AVAILABLE_VERSIONS_PATH);
-            final Properties versionsProps = new Properties(1);
-            versionsProps.load(versionsResource.getInputStream());
-            final String name = plugin.getPluginId() + PluginSupport.AVAILABLE_VERSIONS_PROPERTY_SUFFIX;
-            final String availableVersions = StringSupport.trim(versionsProps.getProperty(name));
-            if (availableVersions.length() == 0) {
-                log.warn("Plugin {}: Could not find {} property in {}", 
-                        plugin.getPluginId(), name, parentResource.getDescription());
-                return false;
+            public List<Pair<Path, List<String>>> getPropertyMerges() {
+                return description.getPropertyMerges();
             }
-            return handleAvailableVersions(pluginIdResource, availableVersions);
-        } catch (final IOException e) {
-            // INFO - not being there is not a failure
-            log.info("Plugin {}: Could not find description {}", 
-                    plugin.getPluginId(), parentResource.getDescription(), e);
-            return false;
-        }
-    }
-        
-    /** {@inheritDoc} */
-    protected void doInitialize() throws ComponentInitializationException {
-        
-        try {
-            if (httpClient == null) {
-                httpClient = new HttpClientBuilder().buildClient();
+            public String getPluginId() {
+                return description.getPluginId();
             }
-            for (final URL url: plugin.getUpdateURLs()) {
-                final Resource parentResource;
-                if ("file".equals(url.getProtocol())) {
-                    // Kludge to allow classpath backed files
-                    parentResource = new FileSystemResource(url.getPath());
-                } else {
-                    parentResource = new HTTPResource(httpClient, url);
-                }
-
-                log.debug("Plugin {}: Looking for update at {}", plugin.getPluginId(),
-                        parentResource.getDescription());
-                if (!parentResource.exists()) {
-                    log.info("Plugin {}: {} could not be located", plugin.getPluginId(),
-                            parentResource.getDescription());
-                    continue;
-                }
-                
-                if (populate(parentResource)) {
-                    log.debug("Plugin {}: PluginState populated from {}",
-                            plugin.getPluginId(), parentResource.getDescription());
-                    if (myVersionInfo == null) {
-                        log.error("Plugin {} : Could not find version {} in descriptions at {}",
-                                plugin.getPluginId(), myPluginVersion, parentResource.getDescription());
-                    }
-                    return;
-                }
+            public int getPatchVersion() {
+                return description.getPatchVersion();
             }
-            log.error("Plugin {}: No available servers found.");
-            throw new ComponentInitializationException("Could not locate information for " + plugin.getPluginId());
-
-        } catch (final IOException e) {
-            throw new ComponentInitializationException("Could not locate Update Resource for "
-                        + plugin.getPluginId(), e);
-        } catch (final Exception e) {
-            throw new ComponentInitializationException("Could not initialize http client for "
-                    + plugin.getPluginId(), e);
-        } finally {
-            super.doInitialize();
-        }
-    }
-    
-    /** Get the current support level for this version.
-     * @return the level
-     */
-    public int getSupportLevel() {
-        ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
-        return myVersionInfo.getSupportLevel();
-    }
-
-    /** Is this plugin supported with the current IdP?
-     * @return whether it is supported.
-     */
-    public boolean isSupportedWithIdPVersion() {
-        return isSupportedWithIdPVersion(PluginSupport.getIdPVersion());
-    }
-    
-    /** Is this plugin supported with this IdP version.
-     * @param idPVersion the version as a {@link String}
-     * @return whether it is supported.
-     */
-    public boolean isSupportedWithIdPVersion(final String idPVersion) {
-        return isSupportedWithIdPVersion(new PluginVersion(idPVersion));
-    }
-    
-    /** Is this plugin supported with this IdP version.
-     * @param idPVersion the version as a {@link PluginVersion}
-     * @return whether it is supported.
-     */
-    public boolean isSupportedWithIdPVersion(final PluginVersion idPVersion) {
-        return isSupportedWithIdPVersion(myVersionInfo, idPVersion);
-    }
-    
-    /** Is the specified plugin supported with this IdP version.
-     * @param pluginVersion the version if the plugin as a {@link PluginVersion}
-     * @param idPVersion the version if the IDP as a {@link PluginVersion}
-     * @return whether it is supported.
-     */
-    public boolean isSupportedWithIdPVersion(final PluginVersion pluginVersion, final PluginVersion idPVersion) {
-        final VersionInfo info = versionInfo.get(pluginVersion);
-        
-        if (info == null) {
-            log.error("Plugin: {} Non existant version {} supplied.", plugin.getPluginId(), pluginVersion);
-            log.debug("Plugin: {} available {}", plugin.getPluginId(), versionInfo.keySet());
-            return false;
-        }
-        
-        return isSupportedWithIdPVersion(info, idPVersion);
-    }
-    
-    /** Is the specified plugin supported with this IdP version.
-     * @param pluginVersion the version if the plugin as a {@link PluginVersion}
-     * @param idPVersion the version if the IDP as a {@link String}
-     * @return whether it is supported.
-     */
-    public boolean isSupportedWithIdPVersion(final PluginVersion pluginVersion, final String idPVersion) {
-        return isSupportedWithIdPVersion(pluginVersion, new PluginVersion(idPVersion));
-    }
-        
-    /** Is the specified plugin supported with this IdP version.
-     * Worker method for all 'isSupportedWith' classes.
-     * @param pluginVersionInfo the version info to consider
-     * @param idPVersion the version as a {@link PluginVersion}
-     * @return whether it is supported.
-     */
-    protected static boolean isSupportedWithIdPVersion(final VersionInfo pluginVersionInfo,
-            final PluginVersion idPVersion) {
-        final int maxCompare = idPVersion.compareTo(pluginVersionInfo.getMaxSupported()); 
-        
-        if (maxCompare >= 0) {
-            // Exclusive:
-            // IdP (test against) Version is GREATER THAN OR EQUAL to our Max
-            return false;
-        }
-        final int minCompare = idPVersion.compareTo(pluginVersionInfo.getMinSupported());
-        if (minCompare >= 0) {
-            // Inclusive:
-            // IdP (test against) version is GREATER THAN OR EQUAL to our Min
-            return true;
-        }
-        return false;
-    }
-    
-    /** Return all announced versions.
-     * @return the versions.
-     */
-    @Nonnull @NotEmpty public Collection<PluginVersion> getAvailableVersions() {
-        ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
-        return versionInfo.keySet();
-    }
-    
-    /** Encapsulation of the information about a given IdP version. */
-    protected static class VersionInfo {
-        
-        /** Maximum version - this version is NOT SUPPORTED. */ 
-        private final PluginVersion maxSupported; 
-
-        /** Minimum version - this version IS supported. */ 
-        private final PluginVersion minSupported; 
-        
-        /** support level. */
-        private final int supportLevel;
-
-        /**
-         * Constructor.
-         *
-         * @param max support level
-         * @param min support level
-         * @param support support level
-         */
-        VersionInfo(final PluginVersion max, final PluginVersion min, final int support) {
-            maxSupported = max;
-            minSupported = min;
-            supportLevel = support;
-        }
-
-        /** get Maximum version - this version is NOT SUPPORTED.
-         * @return Returns the maxSupported.
-         */
-        public PluginVersion getMaxSupported() {
-            return maxSupported;
-        }
-
-        /** get Minimum (IdP) version - this version IS supported.
-         * @return Returns the minSupported.
-         */
-        public PluginVersion getMinSupported() {
-            return minSupported;
-        }
-
-        /** get support level.
-         * @return Returns the supportLevel.
-         */
-        public int getSupportLevel() {
-            return supportLevel;
-        }
+            public int getMinorVersion() {
+                return description.getMinorVersion();
+            }
+            public int getMajorVersion() {
+                return description.getMajorVersion();
+            }
+            public List<Path> getFilePathsToCopy() {
+                return description.getFilePathsToCopy();
+            }
+            public List<Pair<URL, Path>> getExternalFilePathsToCopy() throws IOException {
+                return description.getExternalFilePathsToCopy();
+            }
+            public List<String> getAdditionalPropertyFiles() {
+                return description.getAdditionalPropertyFiles();
+            }
+        });
     }
 }
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
index 4d86be1e9..264765230 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
@@ -34,10 +34,10 @@ import org.springframework.core.io.ClassPathResource;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import net.shibboleth.idp.plugin.AbstractPluginDescription;
+import net.shibboleth.idp.plugin.PluginDescription;
 import net.shibboleth.utilities.java.support.collection.Pair;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.plugin.AbstractPluginDescription;
-import net.shibboleth.utilities.java.support.plugin.PluginDescription;
 
 @SuppressWarnings("javadoc")
 public class PluginInstallerTest {

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


More information about the commits mailing list