diff options
Diffstat (limited to 'spss/server/serverlib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java')
-rw-r--r-- | spss/server/serverlib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java | 118 |
1 files changed, 82 insertions, 36 deletions
diff --git a/spss/server/serverlib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java b/spss/server/serverlib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java index b4b172c8a..c9b76dd7e 100644 --- a/spss/server/serverlib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java +++ b/spss/server/serverlib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java @@ -25,28 +25,35 @@ package at.gv.egovernment.moa.spss.server.init; import iaik.ixsil.init.IXSILInit; -import iaik.logging.TransactionId; import iaik.pki.store.certstore.CertStoreException; -import iaik.pki.store.certstore.CertStoreParameters; import iaik.pki.store.truststore.TrustStoreException; -import iaik.pki.store.truststore.TrustStoreProfile; -import iaik.pki.store.utils.StoreUpdater; import iaik.server.ConfigurationData; -import iaik.x509.X509Certificate; +import iaik.xml.crypto.tsl.ex.TSLEngineDiedException; +import iaik.xml.crypto.tsl.ex.TSLSearchException; +import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; +import java.security.cert.CertificateException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; import java.util.Iterator; -import java.util.Map; +import java.util.Timer; import at.gv.egovernment.moa.logging.LogMsg; import at.gv.egovernment.moa.logging.Logger; import at.gv.egovernment.moa.logging.LoggingContext; import at.gv.egovernment.moa.logging.LoggingContextManager; import at.gv.egovernment.moa.spss.MOAException; +import at.gv.egovernment.moa.spss.api.common.TSLConfiguration; import at.gv.egovernment.moa.spss.server.config.ConfigurationProvider; import at.gv.egovernment.moa.spss.server.iaik.config.IaikConfigurator; import at.gv.egovernment.moa.spss.server.logging.IaikLog; import at.gv.egovernment.moa.spss.server.service.RevocationArchiveCleaner; +import at.gv.egovernment.moa.spss.tsl.connector.TSLConnector; +import at.gv.egovernment.moa.spss.tsl.timer.TSLUpdaterTimerTask; import at.gv.egovernment.moa.spss.util.MessageProvider; import at.gv.egovernment.moa.util.Constants; import at.gv.egovernment.moa.util.DOMUtils; @@ -115,42 +122,45 @@ public class SystemInitializer { try { ConfigurationProvider config = ConfigurationProvider.getInstance(); ConfigurationData configData = new IaikConfigurator().configure(config); - - Map mapTrustProfiles = config.getTrustProfiles(); - - Iterator it = mapTrustProfiles.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry pairs = (Map.Entry)it.next(); - System.out.println(pairs.getKey() + " = " + pairs.getValue()); + + //initialize TSL module + TSLConfiguration tslconfig = config.getTSLConfiguration(); + TSLConnector tslconnector = new TSLConnector(); + if (tslconfig != null) { + //Logger.info(new LogMsg(msg.getMessage("init.01", null))); + Logger.info(new LogMsg(msg.getMessage("config.41", null))); + tslconnector.initialize(tslconfig.getEuTSLUrl(), tslconfig.getWorkingDirectory(), null, null); + } - //@TSL get parameters for StoreUpdater - CertStoreParameters[] certStoreParameters = configData.getPKIConfiguration().getCertStoreConfiguration().getParameters(); - TrustStoreProfile[] trustStoreProfiles = null; - TransactionId tid = null; - - - //@TSL Init TSL Module - X509Certificate[] removeCertificates = null; - X509Certificate[] addCertificates = null; - -// iaik.pki.store.utils.StoreUpdater storeUpdater = new StoreUpdater(certStoreParameters, trustStoreProfiles, tid); -// storeUpdater.removeCertificatesFromTrustStores(removeCertificates, tid); - - + //start TSL Update + TSLUpdaterTimerTask.tslconnector_ = tslconnector; + TSLUpdaterTimerTask.update(); + + //initialize TSL Update Task + initTSLUpdateTask(tslconfig); + Logger.info(new LogMsg(msg.getMessage("init.01", null))); } catch (MOAException e) { Logger.fatal(new LogMsg(msg.getMessage("init.00", null)), e); } -// catch (CertStoreException e) { -// //@TSL -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } catch (TrustStoreException e) { -// //@TSL -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } + catch (TSLEngineDiedException e) { + Logger.fatal(new LogMsg(msg.getMessage("init.00", null)), e); + } + catch (TSLSearchException e) { + Logger.fatal(new LogMsg(msg.getMessage("init.00", null)), e); + } + catch (CertStoreException e) { + Logger.fatal(new LogMsg(msg.getMessage("init.00", null)), e); + } catch (TrustStoreException e) { + Logger.fatal(new LogMsg(msg.getMessage("init.00", null)), e); + } catch (CertificateException e) { + Logger.fatal(new LogMsg(msg.getMessage("init.00", null)), e); + } catch (FileNotFoundException e) { + Logger.fatal(new LogMsg(msg.getMessage("init.00", null)), e); + } catch (IOException e) { + Logger.fatal(new LogMsg(msg.getMessage("init.00", null)), e); + } // set IXSIL debug output IXSILInit.setPrintDebugLog( @@ -167,5 +177,41 @@ public class SystemInitializer { // unset the startup logging context LoggingContextManager.getInstance().setLoggingContext(null); } + + private static void initTSLUpdateTask(TSLConfiguration tslconfig) { + MessageProvider msg = MessageProvider.getInstance(); + if (tslconfig != null) { + // get start time and period from config + long period = tslconfig.getUpdateSchedulePeriod(); + Date startConfig = tslconfig.getUpdateScheduleStartTime(); + + // get hh:mm:ss from config date + Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance + calendar.setTime(startConfig); // assigns calendar to given date + int hour = calendar.get(Calendar.HOUR_OF_DAY); + int min = calendar.get(Calendar.MINUTE); + int sec = calendar.get(Calendar.SECOND); + + // create date with today and time from config + Calendar cal = Calendar.getInstance(); + Date now = cal.getTime(); + cal.set(Calendar.HOUR_OF_DAY, hour); + cal.set(Calendar.MINUTE, min); + cal.set(Calendar.SECOND, sec); + + // proposed start time + Date start = cal.getTime(); + + // if start time has already passed today - add one day (86400000 milliseconds = 1 day) + if (start.before(now)) + start = new Date(start.getTime() + 86400000); + + Logger.debug(new LogMsg(msg.getMessage("config.46", new String[]{start.toString(), "" + period}))); + + // start TSL updater task + Timer timer = new Timer(); + timer.schedule(new TSLUpdaterTimerTask(), start, period); + } + } } |