summaryrefslogtreecommitdiff
path: root/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-12-28 16:15:06 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-12-28 16:15:06 +0100
commit07dcace901880965ea4b25816500f256f17899c0 (patch)
tree6797d9af002bbf384597ea016f9c7afa021692a3 /eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf
parent1aafdf3bbae55b09e6d28e97281797ba9e53aad0 (diff)
parent495403c917a39fdeb3906f10ac8b997f68eb3875 (diff)
downloadEAAF-Components-07dcace901880965ea4b25816500f256f17899c0.tar.gz
EAAF-Components-07dcace901880965ea4b25816500f256f17899c0.tar.bz2
EAAF-Components-07dcace901880965ea4b25816500f256f17899c0.zip
Merge branch 'feature/hsm_facade_update_and_healthcheck' into 'nightlyBuild'
update to HSM-Facade v0.6.0 and add HealthCheck functionality See merge request egiz/eaaf_components!11
Diffstat (limited to 'eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf')
-rw-r--r--eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/actuator/HsmFacadeProviderHealthCheck.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/actuator/HsmFacadeProviderHealthCheck.java b/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/actuator/HsmFacadeProviderHealthCheck.java
new file mode 100644
index 00000000..d2406552
--- /dev/null
+++ b/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/actuator/HsmFacadeProviderHealthCheck.java
@@ -0,0 +1,54 @@
+package at.gv.egiz.eaaf.utils.springboot.actuator;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.actuate.health.Health;
+import org.springframework.boot.actuate.health.HealthIndicator;
+import org.springframework.stereotype.Service;
+
+import at.gv.egiz.eaaf.core.impl.credential.EaafKeyStoreFactory;
+import at.gv.egiz.eaaf.core.impl.credential.EaafKeyStoreFactory.HsmFacadeStatus;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * Implements a Spring-Actuator HealthCheck for HSM-Facade from A-SIT+.
+ *
+ * @author tlenz
+ *
+ */
+@Slf4j
+@Service("HsmFacadeProvider")
+public class HsmFacadeProviderHealthCheck implements HealthIndicator {
+
+ @Autowired(required = false) EaafKeyStoreFactory factory;
+
+ @Override
+ public Health health() {
+ if (factory != null && factory.isHsmFacadeInitialized()) {
+ try {
+ HsmFacadeStatus status = factory.checkHsmFacadeStatus();
+ log.trace("Current HSM-Facade status: {}", status);
+ if (HsmFacadeStatus.UP.equals(status)) {
+ return Health.up().build();
+
+ } else if (HsmFacadeStatus.DOWN.equals(status)) {
+ return Health.down().build();
+
+ }
+
+ } catch (Exception e) {
+ log.warn("HSM-Facaden Health-Check has an error", e);
+ return Health.down(e).build();
+
+ }
+
+ } else {
+ log.trace("No {} or HSM-Facade is not initialized. Skipping healthCheck ...",
+ EaafKeyStoreFactory.class.getName());
+
+ }
+
+ return Health.unknown().build();
+
+ }
+
+}