aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/tsl/TSLServiceFactory.java
diff options
context:
space:
mode:
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.java92
1 files changed, 56 insertions, 36 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 223361d..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
@@ -5,6 +5,7 @@ import at.gv.egovernment.moa.sig.tsl.api.ITslService;
import at.gv.egovernment.moa.sig.tsl.config.TslConfigurationImpl;
import at.gv.egovernment.moa.sig.tsl.exception.TslException;
import at.gv.egovernment.moa.sig.tsl.pki.chaining.ChainingTrustStoreHandler;
+import at.gv.egovernment.moa.spss.server.monitoring.ServiceStatusContainer;
import at.gv.egovernment.moa.spss.util.MessageProvider;
import at.gv.egovernment.moaspss.logging.LogMsg;
import at.gv.egovernment.moaspss.logging.Logger;
@@ -12,40 +13,59 @@ import iaik.pki.store.truststore.TrustStoreFactory;
public class TSLServiceFactory {
- private static ITslService tslClient = null;
-
-
- public static void initialize(TslConfigurationImpl config) {
- if (tslClient == null) {
- try {
- tslClient = TslClientFactory.buildTslService(config );
-
- TrustStoreFactory.addTrustStoreHandler(new ChainingTrustStoreHandler());
-
- } catch (TslException e) {
- Logger.fatal(new LogMsg(MessageProvider.getInstance().getMessage("init.05", new Object[]{e.getMessage()})), e);
-
- }
-
- } 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() {
- 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;
+
+ }
+
}