[java-identity-provider] branch main updated: IDP-1830 Installer should check for outdated web.xml content

Rod Widdowson rdw at steadingsoftware.com
Tue Aug 24 12:49:05 UTC 2021


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=c3a91cb485f1f9b0f42ecce4bc9a31a66bab18d1

The following commit(s) were added to refs/heads/main by this push:
       new  c3a91cb48 IDP-1830 Installer should check for outdated web.xml content
c3a91cb48 is described below

commit c3a91cb485f1f9b0f42ecce4bc9a31a66bab18d1
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Aug 24 13:47:44 2021 +0100

    IDP-1830 Installer should check for outdated web.xml content
    
    https://shibboleth.atlassian.net/browse/IDP-1830
    
    Trivial implementation to start with tio look for exactly one string
    (anywhere) in web.xml
---
 .../net/shibboleth/idp/installer/V4Install.java    | 39 ++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/V4Install.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/V4Install.java
index cd1ada2f8..17ee8c52b 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/V4Install.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/V4Install.java
@@ -17,10 +17,12 @@
 
 package net.shibboleth.idp.installer;
 
+import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -33,6 +35,7 @@ import java.util.Properties;
 import java.util.ServiceConfigurationError;
 import java.util.ServiceLoader;
 import java.util.Set;
+import java.util.regex.Pattern;
 
 import javax.annotation.Nonnull;
 
@@ -47,8 +50,8 @@ import org.springframework.core.io.Resource;
 
 import net.shibboleth.ext.spring.util.ApplicationContextBuilder;
 import net.shibboleth.idp.Version;
-import net.shibboleth.idp.installer.plugin.impl.PluginState;
 import net.shibboleth.idp.installer.impl.InstallationLogger;
+import net.shibboleth.idp.installer.plugin.impl.PluginState;
 import net.shibboleth.idp.module.IdPModule;
 import net.shibboleth.idp.module.ModuleContext;
 import net.shibboleth.idp.module.ModuleException;
@@ -58,6 +61,8 @@ import net.shibboleth.idp.spring.IdPPropertiesApplicationContextInitializer;
 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.primitive.DeprecationSupport;
+import net.shibboleth.utilities.java.support.primitive.DeprecationSupport.ObjectType;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
 import net.shibboleth.utilities.java.support.security.BasicKeystoreKeyStrategyTool;
 import net.shibboleth.utilities.java.support.security.SelfSignedCertificateGenerator;
@@ -145,7 +150,8 @@ public class V4Install extends AbstractInitializableComponent {
                 throw new BuildException("Install failed: system will not work after V4 upgrade");
             }
         }
-        final PluginVersion idpVersion = new PluginVersion(Version.getVersion());
+        final String versionAsString = Version.getVersion();
+        final PluginVersion idpVersion = new PluginVersion(versionAsString!=null?versionAsString:"4.2.0");
         for (final IdPPlugin plugin: ServiceLoader.load(IdPPlugin.class, currentState.getInstalledPluginsLoader())) {
             final String pluginId = plugin.getPluginId();
             final PluginVersion pluginVersion = new PluginVersion(plugin);
@@ -370,6 +376,7 @@ public class V4Install extends AbstractInitializableComponent {
     protected void handleEditWebApp() throws BuildException {
         final Path editWebApp = installerProps.getTargetDir().resolve("edit-webapp");
         if (Files.exists(editWebApp)) {
+            checkWebXml(editWebApp.resolve("WEB-INF").resolve("web.xml"));
             return;
         }
         final Path suppliedInput = installerProps.getInitialEditWeb();
@@ -396,6 +403,34 @@ public class V4Install extends AbstractInitializableComponent {
         }
     }
 
+    /** If it exists check web.xml for deprecated content.
+     * @param webXml the path of the file
+     * We do this in a very simplistic fashion at first
+     * @throws BuildException if we have problems handling the web.xml file
+     */
+    private void checkWebXml(final Path webXml) throws BuildException {
+        if (Files.notExists(webXml)) {
+            return;
+        }
+        try (final BufferedReader in = new BufferedReader(new FileReader(webXml.toFile()))) {
+            final Pattern pat = Pattern.compile(".*net\\.shibboleth\\.ext\\.spring"+
+                    "\\.context\\.DeferPlaceholderFileSystemXmlWebApplicationContext.*");
+            String line = in.readLine();
+            while (line != null) {
+                if (pat.matcher(line).matches()) {
+                    DeprecationSupport.warn(ObjectType.CLASS,
+                            "net.shibboleth.ext.spring.context.DeferPlaceholderFileSystemXmlWebApplicationContext",
+                            "edit-webapp/WEB-INF/web.xml",
+                            "net.shibboleth.ext.spring.context.DelimiterAwareApplicationContext");
+                    break;
+                }
+                line = in.readLine();
+            }
+        } catch (final IOException e) {
+            throw new BuildException(e);
+        }
+    }
+
     /** Create and populate (if they not exist) the "user visible" folders.
      * (conf, flows, messages, views, logs)
      * @throws BuildException if badness occurs

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


More information about the commits mailing list