diff options
author | Thomas <> | 2023-06-23 08:03:37 +0200 |
---|---|---|
committer | Thomas <> | 2023-06-23 08:03:37 +0200 |
commit | c644aa3f1e05ee8d640d928ce9672dd393a56b24 (patch) | |
tree | e60e7a097bb55c994e8a912ee9c88728a74bce97 /moaSig/moa-sig-lib | |
parent | d855cc609099b72a0bb20fafb87da79a5478068d (diff) | |
download | moa-sig-c644aa3f1e05ee8d640d928ce9672dd393a56b24.tar.gz moa-sig-c644aa3f1e05ee8d640d928ce9672dd393a56b24.tar.bz2 moa-sig-c644aa3f1e05ee8d640d928ce9672dd393a56b24.zip |
refact(core): clean-up and optimize MOA-Sig initializer
Diffstat (limited to 'moaSig/moa-sig-lib')
-rw-r--r-- | moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java | 160 |
1 files changed, 76 insertions, 84 deletions
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 3d935df..9ba731d 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 @@ -59,22 +59,20 @@ import iaik.utils.RFC2253NameParser; * @version $Id$ */ public class SystemInitializer { - + + private static final org.slf4j.Logger logger = LoggerFactory.getLogger(SystemInitializer.class); + /** * 15 min TSL reload scheduler interval. */ private static final long TSL_SCHEDULE_INTERVAL = 5*60*1000; - - - + /** Interval between archive cleanups in seconds */ private static final long ARCHIVE_CLEANUP_INTERVAL = 60 * 60; // 1h - /** The MOA SP/SS logging hierarchy. */ - private static final String LOGGING_HIERARCHY = "moa.spss.server"; + /** Whether XML schema grammars have been initialized. */ private static boolean grammarsInitialized = false; - private static final org.slf4j.Logger logger = LoggerFactory.getLogger(SystemInitializer.class); private static ServiceLoader<ExternalInitializer> initializerServices = ServiceLoader.load(ExternalInitializer.class); @@ -106,50 +104,54 @@ public class SystemInitializer { logger.info("##############################################################################"); logger.info("##############################################################################"); - final MessageProvider msg = MessageProvider.getInstance(); - - Thread archiveCleaner; - - // set up the MOA SPSS logging hierarchy - Logger.setHierarchy(LOGGING_HIERARCHY); - // set up a logging context for logging the startup LoggingContextManager.getInstance().setLoggingContext( new LoggingContext("startup")); -// AxisProperties.setProperty("enableNamespacePrefixOptimization","false"); -// AxisProperties.setProperty("disablePrettyXML", "true"); -// AxisProperties.setProperty("axis.doAutoTypes", "true"); - // initialize preparsed Xerces grammar pool for faster XML - // parsing/validating - try { - if (!grammarsInitialized) { - final Class clazz = SystemInitializer.class; - // preparse XML schema - DOMUtils.addSchemaToPool( - clazz.getResourceAsStream(Constants.XML_SCHEMA_LOCATION), - Constants.XML_NS_URI); - // preparse XMLDsig Filter2 schema - DOMUtils.addSchemaToPool( - clazz.getResourceAsStream(Constants.DSIG_FILTER2_SCHEMA_LOCATION), - Constants.DSIG_FILTER2_NS_URI); - // preparse XMLDsig schema - DOMUtils.addSchemaToPool( - clazz.getResourceAsStream(Constants.DSIG_SCHEMA_LOCATION), - Constants.DSIG_NS_URI); - // preparse MOA schema - DOMUtils.addSchemaToPool( - clazz.getResourceAsStream(Constants.MOA_SCHEMA_LOCATION), - Constants.MOA_NS_URI); - grammarsInitialized = true; - } - } catch (final IOException e) { - Logger.warn(new LogMsg(msg.getMessage("init.04", null)), e); - } + loadXsdSchemaIntoXmlParser(); + Logger.info("Register additional RFC2253 Object identifier"); + RFC2253NameParser.register( + "organizationIdentifier", + new ObjectID("2.5.4.97", "organizationIdentifier", (String) null, false)); + // initialize configuration + initializeMoaSigConfiguraion(); + + // start the archive cleanup thread + Thread archiveCleaner = + new Thread(new RevocationArchiveCleaner(ARCHIVE_CLEANUP_INTERVAL)); + archiveCleaner.setName("RevocationArchiveCleaner"); + archiveCleaner.setDaemon(true); + archiveCleaner.setPriority(Thread.MIN_PRIORITY); + archiveCleaner.start(); + + // unset the startup logging context + LoggingContextManager.getInstance().setLoggingContext(null); + logger.info("=============================================================================="); + logger.info("=== CONFIGURATION DONE ==="); + logger.info("=============================================================================="); + + return new StartupConfigurationHolder(config, iaikConfiguration); + + } + + /** + * Get configuration object from IAIK modules. + * + * @return Configuration or <code>null</code> of it was not configurated yet + */ + public static ConfigurationData getIaikConfiguration() { + return iaikConfiguration; + + } + + private static void initializeMoaSigConfiguraion() { + final MessageProvider msg = MessageProvider.getInstance(); + try { + Logger.info("Initialize MOA-SP/SS configuration ... "); config = ConfigurationProvider.getInstance(); @@ -171,11 +173,6 @@ public class SystemInitializer { } - Logger.info("Register additional RFC2253 Object identifier"); - RFC2253NameParser.register( - "organizationIdentifier", - new ObjectID("2.5.4.97", "organizationIdentifier", (String) null, false)); - Logger.info("Building IAIK-MOA configuration ... "); iaikConfiguration = IaikConfigurator.configure(config); @@ -196,43 +193,38 @@ public class SystemInitializer { Logger.fatal(new LogMsg(msg.getMessage("init.00", null)), e); throw new RuntimeException(e); - } - - // CHANGE IXSIL to XSECT - // set IXSIL debug output - // IXSILInit.setPrintDebugLog( - // Logger.isDebugEnabled(IaikLog.IAIK_LOG_HIERARCHY)); - // Logger.info("Registering XSECT"); - // XSecProvider.addAsProvider(true); - - // start the archive cleanup thread - archiveCleaner = - new Thread(new RevocationArchiveCleaner(ARCHIVE_CLEANUP_INTERVAL)); - archiveCleaner.setName("RevocationArchiveCleaner"); - archiveCleaner.setDaemon(true); - archiveCleaner.setPriority(Thread.MIN_PRIORITY); - archiveCleaner.start(); - - // unset the startup logging context - LoggingContextManager.getInstance().setLoggingContext(null); - logger.info("=============================================================================="); - logger.info("=== CONFIGURATION DONE ==="); - logger.info("=============================================================================="); - - return new StartupConfigurationHolder(config, iaikConfiguration); - - } - - /** - * Get configuration object from IAIK modules. - * - * @return Configuration or <code>null</code> of it was not configurated yet - */ - public static ConfigurationData getIaikConfiguration() { - return iaikConfiguration; - + } } - + + private static void loadXsdSchemaIntoXmlParser() { + // parsing/validating + try { + if (!grammarsInitialized) { + final Class clazz = SystemInitializer.class; + // preparse XML schema + DOMUtils.addSchemaToPool( + clazz.getResourceAsStream(Constants.XML_SCHEMA_LOCATION), + Constants.XML_NS_URI); + // preparse XMLDsig Filter2 schema + DOMUtils.addSchemaToPool( + clazz.getResourceAsStream(Constants.DSIG_FILTER2_SCHEMA_LOCATION), + Constants.DSIG_FILTER2_NS_URI); + // preparse XMLDsig schema + DOMUtils.addSchemaToPool( + clazz.getResourceAsStream(Constants.DSIG_SCHEMA_LOCATION), + Constants.DSIG_NS_URI); + // preparse MOA schema + DOMUtils.addSchemaToPool( + clazz.getResourceAsStream(Constants.MOA_SCHEMA_LOCATION), + Constants.MOA_NS_URI); + grammarsInitialized = true; + } + } catch (final IOException e) { + Logger.warn(new LogMsg(MessageProvider.getInstance().getMessage("init.04", null)), e); + + } + } + private static void initTSLUpdateTask(TSLConfiguration tslconfig) { final MessageProvider msg = MessageProvider.getInstance(); if (tslconfig != null) { |