From f06839fb716ff61bf94a32f8e23e3f313245f7e7 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Sat, 26 Dec 2020 17:45:38 +0100 Subject: add jUnit test that simulates a full eIDAS authentication --- ...MsSpecificSpringBootApplicationContextInitializer.java | 2 +- .../connector/SpringBootApplicationInitializer.java | 15 ++++++++++++++- .../connector/provider/StatusMessageProvider.java | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'connector/src/main/java') diff --git a/connector/src/main/java/at/asitplus/eidas/specific/connector/MsSpecificSpringBootApplicationContextInitializer.java b/connector/src/main/java/at/asitplus/eidas/specific/connector/MsSpecificSpringBootApplicationContextInitializer.java index 5160bdf5..399d1286 100644 --- a/connector/src/main/java/at/asitplus/eidas/specific/connector/MsSpecificSpringBootApplicationContextInitializer.java +++ b/connector/src/main/java/at/asitplus/eidas/specific/connector/MsSpecificSpringBootApplicationContextInitializer.java @@ -41,7 +41,7 @@ public class MsSpecificSpringBootApplicationContextInitializer extends } super.initialize(applicationContext); - + } private void injectConfiguration(String configPath, ConfigurableApplicationContext applicationContext) { 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 0d3226bf..f0cf8698 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 @@ -4,8 +4,11 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; +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; @Slf4j @@ -18,8 +21,9 @@ public class SpringBootApplicationInitializer { * Starts MS-specific eIDAS-Implementation SpringBoot application. * * @param args Starting parameters + * @throws Throwable In case of a start-up error */ - public static void main(final String[] args) { + public static void main(final String[] args) throws Throwable { try { log.info("=============== Initializing Spring-Boot context! ==============="); LogMessageProviderFactory.setStatusMessager(new SimpleStatusMessager()); @@ -27,9 +31,18 @@ public class SpringBootApplicationInitializer { new SpringApplication(SpringBootApplicationInitializer.class); springApp.addInitializers(new MsSpecificSpringBootApplicationContextInitializer()); + log.info("Bootstrap openSAML .... "); + EaafOpenSaml3xInitializer.eaafInitialize(); + log.debug("Run SpringBoot initialization process ... "); ctx = springApp.run(args); + // 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."); } catch (final Throwable e) { diff --git a/connector/src/main/java/at/asitplus/eidas/specific/connector/provider/StatusMessageProvider.java b/connector/src/main/java/at/asitplus/eidas/specific/connector/provider/StatusMessageProvider.java index d38da6fe..073f7513 100644 --- a/connector/src/main/java/at/asitplus/eidas/specific/connector/provider/StatusMessageProvider.java +++ b/connector/src/main/java/at/asitplus/eidas/specific/connector/provider/StatusMessageProvider.java @@ -94,8 +94,8 @@ public class StatusMessageProvider implements IStatusMessenger { public String getResponseErrorCode(Throwable throwable) { String errorCode = IStatusMessenger.CODES_EXTERNAL_ERROR_GENERIC; if (throwable instanceof EaafException) { - errorCode = ((EaafException) throwable).getErrorId(); - + errorCode = mapInternalErrorToExternalError(((EaafException) throwable).getErrorId()); + } // TODO: maybe more internal switches are required -- cgit v1.2.3