diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2021-03-24 11:08:57 +0000 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2021-03-24 11:08:57 +0000 |
commit | 666d8c9f8cec7573e60a14ab039c0874f6a9ec53 (patch) | |
tree | d9b2506506cf544ea3758322fd5488c913073427 /moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/TSLServiceFactory.java | |
parent | d003a873fdeec22b1dd57d61590a12a1691ae137 (diff) | |
parent | cd65b47cc30e7119593bbb05afa48d4f896a4859 (diff) | |
download | moa-sig-666d8c9f8cec7573e60a14ab039c0874f6a9ec53.tar.gz moa-sig-666d8c9f8cec7573e60a14ab039c0874f6a9ec53.tar.bz2 moa-sig-666d8c9f8cec7573e60a14ab039c0874f6a9ec53.zip |
Merge branch 'feature/codestyle_and_gitlab_ci' into 'master'
Feature/codestyle and gitlab ci
See merge request egiz/moa-sig!1
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/TSLServiceFactory.java')
-rw-r--r-- | moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/TSLServiceFactory.java | 106 |
1 files changed, 55 insertions, 51 deletions
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/TSLServiceFactory.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/TSLServiceFactory.java index bc902f2..d75240e 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/TSLServiceFactory.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/TSLServiceFactory.java @@ -13,55 +13,59 @@ import iaik.pki.store.truststore.TrustStoreFactory; public class TSLServiceFactory { - private static ITslService tslClient = null; - private static TslConfigurationImpl interalConfig; - - public static void initialize(TslConfigurationImpl config) { - if (tslClient == null) { - try { - interalConfig = config; - tslClient = TslClientFactory.buildTslService(interalConfig); - - TrustStoreFactory.addTrustStoreHandler(new ChainingTrustStoreHandler()); - - //set global TSL client status - ServiceStatusContainer.setStatus(true); - ServiceStatusContainer.setStatusMsg(ServiceStatusContainer.STATUS_OK); - - } catch (TslException e) { - Logger.fatal(new LogMsg(MessageProvider.getInstance().getMessage("init.05", new Object[]{e.getMessage()})), e); - - //set global TSL client status - ServiceStatusContainer.setStatus(false); - ServiceStatusContainer.setStatusMsg( - new LogMsg(MessageProvider.getInstance().getMessage("init.05", new Object[]{e.getMessage()})).toString()); - - } - - } else { - Logger.error("TSL-Service client can only be initialized once."); - throw new IllegalStateException("TSL-Service client can only be initialized once."); - - } - - } - - public static boolean isInitialized() { - if (tslClient == null) - return false; - else - return true; - - } - - public static ITslService getTSLServiceClient() { - if (!isInitialized()) { - Logger.warn("TSL client is not initialized but config is available. Starting new initialization process ..."); - initialize(interalConfig); - } - - return tslClient; - - } - + private static ITslService tslClient = null; + private static TslConfigurationImpl interalConfig; + + public static void initialize(TslConfigurationImpl config) { + if (tslClient == null) { + try { + interalConfig = config; + tslClient = TslClientFactory.buildTslService(interalConfig); + + TrustStoreFactory.addTrustStoreHandler(new ChainingTrustStoreHandler()); + + // set global TSL client status + ServiceStatusContainer.setStatus(true); + ServiceStatusContainer.setStatusMsg(ServiceStatusContainer.STATUS_OK); + + } catch (final TslException e) { + Logger.fatal(new LogMsg(MessageProvider.getInstance().getMessage("init.05", new Object[] { e + .getMessage() })), e); + + // set global TSL client status + ServiceStatusContainer.setStatus(false); + ServiceStatusContainer.setStatusMsg( + new LogMsg(MessageProvider.getInstance().getMessage("init.05", new Object[] { e.getMessage() })) + .toString()); + + } + + } else { + Logger.error("TSL-Service client can only be initialized once."); + throw new IllegalStateException("TSL-Service client can only be initialized once."); + + } + + } + + public static boolean isInitialized() { + if (tslClient == null) { + return false; + } else { + return true; + } + + } + + public static ITslService getTSLServiceClient() { + if (!isInitialized()) { + Logger.warn( + "TSL client is not initialized but config is available. Starting new initialization process ..."); + initialize(interalConfig); + } + + return tslClient; + + } + } |