[java-identity-provider] branch main updated: IDP-2015 - Review web.xml for improvements via code or annotations
Scott Cantor
cantor.2 at osu.edu
Tue Oct 4 17:50:19 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor 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=a9a7e89dda653e4d208cbdd559230b149594cc43
The following commit(s) were added to refs/heads/main by this push:
new a9a7e89dd IDP-2015 - Review web.xml for improvements via code or annotations
a9a7e89dd is described below
commit a9a7e89dda653e4d208cbdd559230b149594cc43
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Oct 4 13:50:16 2022 -0400
IDP-2015 - Review web.xml for improvements via code or annotations
https://shibboleth.atlassian.net/browse/IDP-2015
Move Spring listener into existing initializer and adjust enablement.
---
.../SpringConfigServletContextInitializer.java | 40 +++++++++-------------
idp-war/src/main/webapp/WEB-INF/web.xml | 18 +++++++---
2 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/idp-conf-impl/src/main/java/net/shibboleth/idp/conf/impl/SpringConfigServletContextInitializer.java b/idp-conf-impl/src/main/java/net/shibboleth/idp/conf/impl/SpringConfigServletContextInitializer.java
index 4e196f580..597ae3cb5 100644
--- a/idp-conf-impl/src/main/java/net/shibboleth/idp/conf/impl/SpringConfigServletContextInitializer.java
+++ b/idp-conf-impl/src/main/java/net/shibboleth/idp/conf/impl/SpringConfigServletContextInitializer.java
@@ -23,11 +23,13 @@ import javax.annotation.Nonnull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.web.context.ContextLoaderListener;
import jakarta.servlet.ServletContainerInitializer;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import net.shibboleth.idp.spring.IdPPropertiesApplicationContextInitializer;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.spring.context.DelimiterAwareApplicationContext;
/**
@@ -38,35 +40,27 @@ public class SpringConfigServletContextInitializer implements ServletContainerIn
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(SpringConfigServletContextInitializer.class);
-
+
+ /** System property name for the activation of this class. */
+ @Nonnull @NotEmpty public static final String INIT_PARAMETER_ACTIVATION = "net.shibboleth.idp.registerSpringConfig";
+
/** {@inheritDoc} */
@Override
public void onStartup(final Set<Class<?>> c, final ServletContext ctx) throws ServletException {
- String param = ctx.getInitParameter("contextClass");
- if (param == null) {
- log.info("Setting init parameter contextClass");
- ctx.setInitParameter("contextClass", DelimiterAwareApplicationContext.class.getName());
- } else {
- log.info("Init parameter contextClass already set to {}", param);
+ final String flag = ctx.getInitParameter(INIT_PARAMETER_ACTIVATION);
+ if (!"true".equalsIgnoreCase(flag)) {
+ log.info("Spring config registration is disabled");
+ return;
}
- param = ctx.getInitParameter("contextInitializerClasses");
- if (param == null) {
- log.info("Setting init parameter contextInitializerClasses");
- ctx.setInitParameter("contextInitializerClasses", IdPPropertiesApplicationContextInitializer.class.getName());
- } else {
- log.info("Init parameter contextInitializerClasses already set to {}", param);
- }
-
- param = ctx.getInitParameter("contextConfigLocation");
- if (param == null) {
- log.info("Setting init parameter contextConfigLocation");
- ctx.setInitParameter("contextConfigLocation",
- "classpath*:/META-INF/net.shibboleth.idp/preconfig.xml,classpath:/net/shibboleth/idp/conf/global-system.xml,classpath*:/META-INF/net.shibboleth.idp/postconfig.xml");
- } else {
- log.info("Init parameter contextConfigLocation already set to {}", param);
- }
+ log.info("Setting init parameters and installing Spring listener");
+ ctx.setInitParameter("contextClass", DelimiterAwareApplicationContext.class.getName());
+ ctx.setInitParameter("contextInitializerClasses", IdPPropertiesApplicationContextInitializer.class.getName());
+ ctx.setInitParameter("contextConfigLocation",
+ "classpath*:/META-INF/net.shibboleth.idp/preconfig.xml,classpath:/net/shibboleth/idp/conf/global-system.xml,classpath*:/META-INF/net.shibboleth.idp/postconfig.xml");
+
+ ctx.addListener(ContextLoaderListener.class.getName());
}
}
\ No newline at end of file
diff --git a/idp-war/src/main/webapp/WEB-INF/web.xml b/idp-war/src/main/webapp/WEB-INF/web.xml
index 40b171e5d..1eddfd9e4 100644
--- a/idp-war/src/main/webapp/WEB-INF/web.xml
+++ b/idp-war/src/main/webapp/WEB-INF/web.xml
@@ -4,6 +4,19 @@
<display-name>Shibboleth Identity Provider</display-name>
+ <!--
+ The context parameters below control V5+ auto-registration support.
+ Those desiring complete control over all of these steps can disable them
+ but this is not generally recommended, apart from toggling the optional
+ servlets that may not be needed.
+ -->
+
+ <!-- Registers Spring support. -->
+ <context-param>
+ <param-name>net.shibboleth.idp.registerSpringConfig</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
<!-- Auto-registers Java filter chain required by IdP. -->
<context-param>
<param-name>net.shibboleth.idp.registerFilterChain</param-name>
@@ -31,11 +44,6 @@
<param-name>net.shibboleth.idp.registerMetadataServlet</param-name>
<param-value>true</param-value>
</context-param>
-
- <!-- Spring listener used to load up the configuration -->
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
<!-- Send servlet errors through the IdP's MVC error handling. -->
<error-page>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list