diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2017-01-02 16:35:43 +0100 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2017-01-02 16:35:43 +0100 |
commit | 8574f931c169248c67c3a5946351f9072628af46 (patch) | |
tree | 56ac39e631af4cd11058c4ba1193180af9d2e1fe /moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/timer | |
parent | aabb36836ebfca9fe8cdc70dff13c0be7e5e761c (diff) | |
download | moa-sig-8574f931c169248c67c3a5946351f9072628af46.tar.gz moa-sig-8574f931c169248c67c3a5946351f9072628af46.tar.bz2 moa-sig-8574f931c169248c67c3a5946351f9072628af46.zip |
first untested beta version with new TSL lib
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/timer')
-rw-r--r-- | moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/timer/TSLUpdaterTimerTask.java | 172 |
1 files changed, 10 insertions, 162 deletions
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/timer/TSLUpdaterTimerTask.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/timer/TSLUpdaterTimerTask.java index 61e305b..300bcae 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/timer/TSLUpdaterTimerTask.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/timer/TSLUpdaterTimerTask.java @@ -8,8 +8,6 @@ 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.FileInputStream;
@@ -22,6 +20,8 @@ import java.util.Iterator; import java.util.Map;
import java.util.TimerTask;
+import at.gv.egovernment.moa.sig.tsl.exception.TslException;
+import at.gv.egovernment.moa.sig.tsl.exception.TslUpdateException;
import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.api.common.TSLConfiguration;
import at.gv.egovernment.moa.spss.server.config.ConfigurationException;
@@ -30,7 +30,7 @@ import at.gv.egovernment.moa.spss.server.config.TrustProfile; import at.gv.egovernment.moa.spss.server.iaik.config.IaikConfigurator;
import at.gv.egovernment.moa.spss.server.iaik.pki.store.truststore.TrustStoreProfileImpl;
import at.gv.egovernment.moa.spss.server.logging.TransactionId;
-import at.gv.egovernment.moa.spss.tsl.connector.TSLConnector;
+import at.gv.egovernment.moa.spss.tsl.TSLServiceFactory;
import at.gv.egovernment.moa.spss.util.MessageProvider;
import at.gv.egovernment.moaspss.logging.LogMsg;
import at.gv.egovernment.moaspss.logging.Logger;
@@ -38,177 +38,25 @@ import at.gv.egovernment.moaspss.util.StringUtils; public class TSLUpdaterTimerTask extends TimerTask {
-
- public static TSLConnector tslconnector_;
-
- public static ConfigurationData configData_ = null;
-
+
@Override
public void run() {
try {
Logger.info("Start TSL Update");
- update();
+ TSLServiceFactory.getTSLServiceClient().updateTSLInformation();
Logger.info("Finished TSL Update");
- } catch (TSLEngineDiedException e) {
- MessageProvider msg = MessageProvider.getInstance();
- Logger.error(new LogMsg(msg.getMessage("tsl.00", null)), e);
- } catch (TSLSearchException e) {
- MessageProvider msg = MessageProvider.getInstance();
- Logger.error(new LogMsg(msg.getMessage("tsl.00", null)), e);
- } catch (ConfigurationException e) {
- MessageProvider msg = MessageProvider.getInstance();
- Logger.error(new LogMsg(msg.getMessage("tsl.00", null)), e);
- } catch (MOAApplicationException e) {
- MessageProvider msg = MessageProvider.getInstance();
- Logger.error(new LogMsg(msg.getMessage("tsl.00", null)), e);
- } catch (CertStoreException e) {
- MessageProvider msg = MessageProvider.getInstance();
- Logger.error(new LogMsg(msg.getMessage("tsl.00", null)), e);
- } catch (TrustStoreException e) {
- MessageProvider msg = MessageProvider.getInstance();
- Logger.error(new LogMsg(msg.getMessage("tsl.00", null)), e);
- } catch (FileNotFoundException e) {
- MessageProvider msg = MessageProvider.getInstance();
- Logger.error(new LogMsg(msg.getMessage("tsl.00", null)), e);
- } catch (IOException e) {
+
+ } catch (TslUpdateException e) {
MessageProvider msg = MessageProvider.getInstance();
Logger.error(new LogMsg(msg.getMessage("tsl.00", null)), e);
- } catch (CertificateException e) {
+
+ } catch (TslException e) {
MessageProvider msg = MessageProvider.getInstance();
Logger.error(new LogMsg(msg.getMessage("tsl.00", null)), e);
- }
-
- }
-
- public static void update() throws TSLEngineDiedException, TSLSearchException, ConfigurationException, MOAApplicationException, CertStoreException, TrustStoreException, CertificateException, IOException {
- MessageProvider msg = MessageProvider.getInstance();
-
- //TrustProfile tp = null;
- TrustStoreProfile tsp = null;
- StoreUpdater storeUpdater = null;
- TransactionId tid = null;
-
- //get TSl configuration
- ConfigurationProvider config = ConfigurationProvider.getInstance();
- if (configData_ == null)
- configData_ = new IaikConfigurator().configure(config);
- TSLConfiguration tslconfig = config.getTSLConfiguration();
- if (tslconfig != null) {
-
- tslconnector_.updateTSLs(new Date(), new String[]{"granted","recognisedatnationallevel"});
-
- Logger.info(new LogMsg(msg.getMessage("config.42", null)));
-
- // get certstore parameters
- CertStoreParameters[] certStoreParameters = configData_.getPKIConfiguration().getCertStoreConfiguration().getParameters();
-
- // iterate over all truststores
- Map mapTrustProfiles = config.getTrustProfiles();
- Iterator it = mapTrustProfiles.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pairs = (Map.Entry)it.next();
- TrustProfile tp = (TrustProfile) pairs.getValue();
- if (tp.isTSLEnabled()) {
- tsp = new TrustStoreProfileImpl(config, tp.getId());
- TrustStoreProfile[] trustStoreProfiles = new TrustStoreProfile[1];
- trustStoreProfiles[0] = tsp;
-
-
- Logger.debug(new LogMsg(msg.getMessage("config.43", new String[]{tp.getId()})));
-
- tid = new TransactionId("TSLConfigurator-" + tp.getId());
- ArrayList tsl_certs = null;
- if (StringUtils.isEmpty(tp.getCountries())) {
- Logger.debug(new LogMsg(msg.getMessage("config.44", null)));
-
- // get certificates from TSL from all countries
- tsl_certs = tslconnector_.getQualifiedCACertificates(new Date(), new String[]{"granted","recognisedatnationallevel"});
- }
- else {
- Logger.debug(new LogMsg(msg.getMessage("config.44", null)));
- // get selected countries as array
- String countries = tp.getCountries();
- String[] array = countries.split(",");
- for (int i = 0; i < array.length; i++)
- array[i] = array[i].trim();
-
- // get certificates from TSL from given countries
- tsl_certs = tslconnector_.getQualifiedCACertificates(new Date(), array, new String[]{"granted","recognisedatnationallevel"});
- }
-
- // create store updater for each TSL enabled truststore
- Logger.debug(new LogMsg(msg.getMessage("config.45", null)));
- storeUpdater = new StoreUpdater(certStoreParameters, trustStoreProfiles, tid);
-
- // delete files in trustprofile
-
- File ftp = new File(tp.getUri());
- File[] files = ftp.listFiles();
- X509Certificate[] removeCertificates = new X509Certificate[files.length];
- int i = 0;
- for (File file : files) {
- FileInputStream fis = new FileInputStream(file);
- removeCertificates[i] = new X509Certificate(fis);
- i++;
- fis.close();
- //file.delete();
- }
-
- // remove all certificates
- storeUpdater.removeCertificatesFromTrustStores(removeCertificates, tid);
- storeUpdater.removeCertificatesFromCertStores(removeCertificates, tid);
-
-
- // copy files from original trustAnchorsLocURI into tslworking trust profile
- File src = new File(tp.getUriOrig());
- files = src.listFiles();
- X509Certificate[] addCertificates = new X509Certificate[files.length];
- i = 0;
- for (File file : files) {
- FileInputStream fis = new FileInputStream(file);
- addCertificates[i] = new X509Certificate(fis);
- //FileUtils.copyFile(file, new File(tp.getUri(), file.getName()));
- i++;
- fis.close();
- }
-
- // convert ArrayList<File> to X509Certificate[]
- if (tsl_certs == null) {
- Logger.warn("No certificates from TSL imported.");
- //throw new TSLSearchException("No certificates from TSL imported.");
- }
- else {
-
- X509Certificate[] addCertificatesTSL = new X509Certificate[tsl_certs.size()];
- Iterator itcert = tsl_certs.iterator();
- i = 0;
- File f = null;
- while(itcert.hasNext()) {
- f = (File)itcert.next();
- FileInputStream fis = new FileInputStream(f);
- X509Certificate cert = new X509Certificate(fis);
- addCertificatesTSL[i] = cert;
-
- i++;
- fis.close();
- }
-
- Logger.info(new LogMsg("Add " + addCertificatesTSL.length + " certificates to " + tp.getId() + " from TSL."));
- storeUpdater.addCertificatesToTrustStores(addCertificatesTSL, tid);
- storeUpdater.addCertificatesToCertStores(addCertificatesTSL, tid);
-
- Logger.info(new LogMsg("Add " + addCertificates.length + " certificates to " + tp.getId() + "."));
- storeUpdater.addCertificatesToTrustStores(addCertificates, tid);
- storeUpdater.addCertificatesToCertStores(addCertificates, tid);
- }
- }
- }
- }
-
+ }
-
}
}
|