From 3f2032efba5469589d5317b1796a0aec74457847 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 16 Mar 2021 15:13:22 +0100 Subject: update MOA-SPSS initialization to mitigate suspect behavior in EAAF-Components module --- .../gv/egovernment/moa/spss/api/Configurator.java | 16 +++++++-- .../moa/spss/server/init/ConfiguratorImpl.java | 31 ++++++++++++---- .../server/init/StartupConfigurationHolder.java | 42 ++++++++++++++++++++++ .../moa/spss/server/init/SystemInitializer.java | 34 +++++++++++++----- 4 files changed, 105 insertions(+), 18 deletions(-) create mode 100644 moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/StartupConfigurationHolder.java (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv') diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/Configurator.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/Configurator.java index 59db7b5..bc0acbe 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/Configurator.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/Configurator.java @@ -26,6 +26,7 @@ package at.gv.egovernment.moa.spss.api; import at.gv.egovernment.moa.spss.MOAException; import at.gv.egovernment.moa.spss.server.init.ConfiguratorImpl; +import at.gv.egovernment.moa.spss.server.init.StartupConfigurationHolder; /** * Configures the SP/SS API. @@ -61,15 +62,24 @@ public abstract class Configurator { return instance; } + /** + * Get current configuration object. + * + * @return Configuration or null if it was not initialized yet + */ + public abstract StartupConfigurationHolder getCurrentConfiguration(); + /** * Initialize the SP/SS configuration. * * Only a single call to this method will have an effect. Use * update() for reflecting changes in the configuration instead. * + * @return Configuration holder + * * @throws MOAException An error occurred updating the SP/SS configuration. */ - public abstract void init() throws MOAException; + public abstract StartupConfigurationHolder init() throws MOAException; /** * Update the SP/SS configuration. @@ -77,8 +87,10 @@ public abstract class Configurator { * This will only have an effect after the system has been initialized once * using init(). * + * @return Updated Configuration holder, or null if it was not initialized + * * @throws MOAException An error occurred updating the SP/SS configuration. */ - public abstract void update() throws MOAException; + public abstract StartupConfigurationHolder update() throws MOAException; } diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/ConfiguratorImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/ConfiguratorImpl.java index 8ab01d6..32654d4 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/ConfiguratorImpl.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/ConfiguratorImpl.java @@ -29,6 +29,7 @@ import at.gv.egovernment.moa.spss.api.Configurator; import at.gv.egovernment.moa.spss.server.config.ConfigurationException; import at.gv.egovernment.moa.spss.server.config.ConfigurationProvider; import at.gv.egovernment.moa.spss.server.iaik.config.IaikConfigurator; +import iaik.server.ConfigurationData; /** * Default implementation of Configurator. @@ -40,26 +41,42 @@ public class ConfiguratorImpl extends Configurator { /** whether the configuration has been initialized */ private boolean initialized = false; - public void init() throws MOAException { + StartupConfigurationHolder result; + + public StartupConfigurationHolder getCurrentConfiguration() { + return result; + + } + + public StartupConfigurationHolder init() throws MOAException { if (!initialized) { - SystemInitializer.init(); + result = SystemInitializer.init(); initialized = true; + } + + return result; + } - public void update() throws MOAException { + public StartupConfigurationHolder update() throws MOAException { if (!initialized) { - return; + return null; } - try { + try { // reconfigure the system ConfigurationProvider config = ConfigurationProvider.reload(); - new IaikConfigurator().configure(config); + ConfigurationData iaikConfig = new IaikConfigurator().configure(config); + result = new StartupConfigurationHolder(config, iaikConfig); + return result; + } catch (MOAException e) { throw e; + } catch (Throwable t) { - throw new ConfigurationException("", null, t); + throw new ConfigurationException("MOA-SPSS initialization FAILED with a generic error", null, t); + } } diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/StartupConfigurationHolder.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/StartupConfigurationHolder.java new file mode 100644 index 0000000..229a8b2 --- /dev/null +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/StartupConfigurationHolder.java @@ -0,0 +1,42 @@ +package at.gv.egovernment.moa.spss.server.init; + +import at.gv.egovernment.moa.spss.server.config.ConfigurationProvider; +import iaik.server.ConfigurationData; + +public class StartupConfigurationHolder { + + private final ConfigurationProvider moaSpssConfig; + private final ConfigurationData iaikConfiguration; + + /** + * Holder for IAIK and MOA-SPSS related configuration object. + * + * @param config MOA-SPSS specific configuration + * @param iaikConfig Internal IAIK module configuration + */ + public StartupConfigurationHolder(ConfigurationProvider config, ConfigurationData iaikConfig) { + this.moaSpssConfig = config; + this.iaikConfiguration = iaikConfig; + } + + /** + * Get MOA-SPSS configuration object from start-up process. + * + * @return MOA-SPSS configuration + */ + public ConfigurationProvider getMoaSpssConfig() { + return moaSpssConfig; + } + + /** + * Get configuration object for IAIK modules from start-up process. + * + * @return IAIK module configuration + */ + public ConfigurationData getIaikConfiguration() { + return iaikConfiguration; + } + + + +} diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java index 6ef9c57..25bb6d9 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java @@ -51,6 +51,7 @@ import at.gv.egovernment.moaspss.logging.LoggingContextManager; import at.gv.egovernment.moaspss.util.Constants; import at.gv.egovernment.moaspss.util.DOMUtils; import iaik.asn1.ObjectID; +import iaik.server.ConfigurationData; import iaik.utils.RFC2253NameParser; /** @@ -71,6 +72,8 @@ public class SystemInitializer { private static ServiceLoader initializerServices = ServiceLoader.load(ExternalInitializer.class); + private static ConfigurationData iaikConfiguration; + private static ConfigurationProvider config; private static void runInitializer(ConfigurationProvider configurationProvider) { @@ -84,8 +87,9 @@ public class SystemInitializer { /** * Initialize the MOA SP/SS webservice. + * @return */ - public static void init() { + public static StartupConfigurationHolder init() { logger.info("##############################################################################"); logger.info("##############################################################################"); @@ -141,7 +145,7 @@ public class SystemInitializer { // initialize configuration try { Logger.info("Initialize MOA-SP/SS configuration ... "); - ConfigurationProvider config = ConfigurationProvider.getInstance(); + config = ConfigurationProvider.getInstance(); //initialize TSL module TSLConfiguration moaSPTslConfig = config.getTSLConfiguration(); @@ -168,25 +172,23 @@ public class SystemInitializer { Logger.info("Building IAIK-MOA configuration ... "); - new IaikConfigurator().configure(config); + iaikConfiguration = new IaikConfigurator().configure(config); runInitializer(config); Logger.info(new LogMsg(msg.getMessage("init.01", null))); + } catch (MOAException e) { Logger.fatal(new LogMsg(msg.getMessage("init.00", null)), e); + throw new RuntimeException(e); } catch (Throwable e) { Logger.fatal(new LogMsg(msg.getMessage("init.00", null)), e); throw new RuntimeException(e); - } finally { - logger.info("Configuration initialized"); - } - - - + } + // CHANGE IXSIL to XSECT // set IXSIL debug output //IXSILInit.setPrintDebugLog( @@ -207,6 +209,20 @@ public class SystemInitializer { logger.info("=============================================================================="); logger.info("=== CONFIGURATION DONE ==="); logger.info("=============================================================================="); + + + return new StartupConfigurationHolder(config, iaikConfiguration); + + } + + /** + * Get configuration object from IAIK modules. + * + * @return Configuration or null of it was not configurated yet + */ + public static ConfigurationData getIaikConfiguration() { + return iaikConfiguration; + } private static void initTSLUpdateTask(TSLConfiguration tslconfig) { -- cgit v1.2.3