aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/main/java')
-rw-r--r--modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/provider/IdAustriaClientAuthHealthCheck.java32
1 files changed, 28 insertions, 4 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/provider/IdAustriaClientAuthHealthCheck.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/provider/IdAustriaClientAuthHealthCheck.java
index b54b501d..32bbfa54 100644
--- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/provider/IdAustriaClientAuthHealthCheck.java
+++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/provider/IdAustriaClientAuthHealthCheck.java
@@ -1,5 +1,11 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.provider;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
import org.apache.commons.lang3.StringUtils;
import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +27,8 @@ import net.shibboleth.utilities.java.support.resolver.ResolverException;
@Slf4j
public class IdAustriaClientAuthHealthCheck implements HealthIndicator {
+ private static final int DEADLINE = 3;
+
@Autowired IConfiguration authConfig;
@Autowired IdAustriaClientAuthMetadataProvider metadataService;
@@ -35,19 +43,35 @@ public class IdAustriaClientAuthHealthCheck implements HealthIndicator {
}
+ CompletableFuture<Health> asynchTestOperation = new CompletableFuture<>();
+ Executors.newCachedThreadPool().submit(() -> runConnectionTest(asynchTestOperation, msNodeEntityID));
+ try {
+ return asynchTestOperation.get(DEADLINE, TimeUnit.SECONDS);
+
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ log.warn("Receive no respose from Health-Check after {} seconds.", DEADLINE, e);
+ return Health.outOfService().withException(e).build();
+
+ }
+
+
+ }
+
+
+ private void runConnectionTest(CompletableFuture<Health> completableFuture, String entityId) {
try {
EntityDescriptor connectorMetadata =
- metadataService.getEntityDescriptor(msNodeEntityID);
+ metadataService.getEntityDescriptor(entityId);
if (connectorMetadata != null) {
- return Health.up().build();
+ completableFuture.complete(Health.up().build());
} else {
- return Health.outOfService().withDetail("Reason", "No SAML2 metadata").build();
+ completableFuture.complete(Health.outOfService().withDetail("Reason", "No SAML2 metadata").build());
}
} catch (ResolverException e) {
- return Health.down(e).build();
+ completableFuture.complete(Health.down(e).build());
}