aboutsummaryrefslogtreecommitdiff
path: root/connector/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'connector/src/main/java/at')
-rw-r--r--connector/src/main/java/at/asitplus/eidas/specific/connector/controller/MonitoringController.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/connector/src/main/java/at/asitplus/eidas/specific/connector/controller/MonitoringController.java b/connector/src/main/java/at/asitplus/eidas/specific/connector/controller/MonitoringController.java
index a0df9631..ede992c1 100644
--- a/connector/src/main/java/at/asitplus/eidas/specific/connector/controller/MonitoringController.java
+++ b/connector/src/main/java/at/asitplus/eidas/specific/connector/controller/MonitoringController.java
@@ -28,6 +28,10 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.TransformerFactoryConfigurationError;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.slf4j.Logger;
@@ -43,6 +47,7 @@ import at.gv.egiz.eaaf.core.api.data.EAAFConstants;
import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
import at.gv.egiz.eaaf.core.api.storage.ITransactionStorage;
import at.gv.egiz.eaaf.core.exceptions.EAAFException;
+import at.gv.egiz.eaaf.core.impl.utils.DOMUtils;
import at.gv.egiz.eaaf.core.impl.utils.Random;
import at.gv.egiz.eaaf.modules.pvp2.api.metadata.IPVPMetadataBuilderConfiguration;
import at.gv.egiz.eaaf.modules.pvp2.api.metadata.IPVPMetadataConfigurationFactory;
@@ -55,10 +60,12 @@ public class MonitoringController {
private static final String MESSAGE_OK = "OK";
private static final String MESSAGE_ERROR = "ERROR";
+ private static final String MESSAGE_SKIPPED = "SKIPPED";
private static final String TEST_STORAGE = "Storage: ";
private static final String TEST_CONFIG = "Config: ";
private static final String TEST_PVPMETADATA = "PVP_metadata: ";
+ private static final String TEST_EIDASNODEMETADATA = "eIDASNode_metadata: ";
@Autowired private ITransactionStorage storage;
@Autowired private IConfiguration config;
@@ -96,6 +103,7 @@ public class MonitoringController {
testConfig();
testStorage();
testPVPMetadata();
+ testEidasNodeMetadata();
resp.setStatus(HttpServletResponse.SC_OK);
resp.getWriter().write(MESSAGE_OK);
@@ -131,6 +139,12 @@ public class MonitoringController {
result += e.getMessage() + "<br>";
}
+ try {
+ result += testEidasNodeMetadata() + "<br>";
+ } catch (Exception e) {
+ result += e.getMessage() + "<br>";
+ }
+
resp.setContentType(EAAFConstants.CONTENTTYPE_HTML_UTF8);
resp.setStatus(HttpServletResponse.SC_OK);
resp.getWriter().write(result);
@@ -195,4 +209,44 @@ public class MonitoringController {
}
+ private String testEidasNodeMetadata() throws Exception {
+ try {
+ String urlString = config.getBasicConfiguration(MSeIDASNodeConstants.PROP_CONFIG_MONITORING_EIDASNODE_METADATAURL);
+ if (StringUtils.isEmpty(urlString)) {
+ log.debug("No eIDASNode metadata URL. Skipping test ... ");
+ return TEST_EIDASNODEMETADATA + MESSAGE_SKIPPED;
+
+ }
+
+ //create HTTP client
+ //TODO: update if we switch to openSAML3
+ HttpClient httpClient = new HttpClient();
+
+ //set parameters
+ HttpClientParams params = new HttpClientParams();
+ params.setSoTimeout(5*1000);
+ httpClient.setParams(params );
+
+ //request URL
+ HttpMethod method = new GetMethod(urlString);
+ int respCode = httpClient.executeMethod(method);
+ if (respCode != 200) {
+ log.warn("Monitoring: Has an error in '" + TEST_EIDASNODEMETADATA + "': " + " HTTP responsecode: " + respCode);
+ throw new Exception(TEST_EIDASNODEMETADATA + MESSAGE_ERROR);
+
+ }
+
+ //parse metadata
+ DOMUtils.parseXmlNonValidating(method.getResponseBodyAsStream());
+
+ return TEST_EIDASNODEMETADATA + MESSAGE_OK;
+
+ } catch (Exception | TransformerFactoryConfigurationError e) {
+ log.warn("Monitoring: Has an error in '" + TEST_EIDASNODEMETADATA + "': " + e.getMessage(), e);
+ throw new Exception(TEST_EIDASNODEMETADATA + MESSAGE_ERROR, e);
+
+ }
+
+ }
+
}