From 1bcc269ff8f16b2a4dee4f393e4259f4768ca3a0 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Sat, 9 Jan 2021 18:56:32 +0100 Subject: extend SpringBoot application-initializer to support deployment in Apache Tomcat application-services --- .../SpringBootApplicationInitializer.java | 39 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'connector/src') diff --git a/connector/src/main/java/at/asitplus/eidas/specific/connector/SpringBootApplicationInitializer.java b/connector/src/main/java/at/asitplus/eidas/specific/connector/SpringBootApplicationInitializer.java index 1e84cbb0..428f5f56 100644 --- a/connector/src/main/java/at/asitplus/eidas/specific/connector/SpringBootApplicationInitializer.java +++ b/connector/src/main/java/at/asitplus/eidas/specific/connector/SpringBootApplicationInitializer.java @@ -1,22 +1,26 @@ package at.asitplus.eidas.specific.connector; +import org.opensaml.core.config.InitializationException; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.web.context.WebApplicationContext; import at.gv.egiz.eaaf.core.api.IStatusMessenger; import at.gv.egiz.eaaf.core.impl.logging.LogMessageProviderFactory; import at.gv.egiz.eaaf.core.impl.logging.SimpleStatusMessager; -import at.gv.egiz.eaaf.core.impl.utils.Random; import at.gv.egiz.eaaf.modules.pvp2.impl.opensaml.initialize.EaafOpenSaml3xInitializer; import lombok.extern.slf4j.Slf4j; +import net.shibboleth.utilities.java.support.component.ComponentInitializationException; @Slf4j @SpringBootApplication(scanBasePackages = { "at.asitplus.eidas.specific.connector", "at.gv.egiz.eaaf.utils.springboot.ajp" }) -public class SpringBootApplicationInitializer { +public class SpringBootApplicationInitializer extends SpringBootServletInitializer { private static ConfigurableApplicationContext ctx; @@ -42,9 +46,6 @@ public class SpringBootApplicationInitializer { // initialize status messenger LogMessageProviderFactory.setStatusMessager(ctx.getBean(IStatusMessenger.class)); - - log.info("Seed random number generator ... "); - Random.seedRandom(); log.info("Initialization of MS-specific eIDAS-Implementation finished."); @@ -56,6 +57,34 @@ public class SpringBootApplicationInitializer { } + + protected SpringApplicationBuilder createSpringApplicationBuilder() { + try { + log.info("Bootstrap openSAML .... "); + EaafOpenSaml3xInitializer.eaafInitialize(); + + } catch (InitializationException | ComponentInitializationException e) { + throw new RuntimeException(e); + + } + + SpringApplicationBuilder builder = new SpringApplicationBuilder(); + builder.initializers(new MsSpecificSpringBootApplicationContextInitializer()); + return builder; + + } + + protected WebApplicationContext run(SpringApplication application) { + WebApplicationContext internalContext = (WebApplicationContext) application.run(); + + // initialize status messenger + LogMessageProviderFactory.setStatusMessager(internalContext.getBean(IStatusMessenger.class)); + + log.info("Initialization of MS-specific eIDAS-Implementation finished."); + + return internalContext; + } + /** * Stops SpringBoot application of MS-specific eIDAS-Implementation. * -- cgit v1.2.3