aboutsummaryrefslogtreecommitdiff
path: root/id/server/modules/module-monitoring
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/modules/module-monitoring')
-rw-r--r--id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/auth/servlet/MonitoringController.java (renamed from id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/auth/servlet/MonitoringServlet.java)88
-rw-r--r--id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/DatabaseTestModule.java9
-rw-r--r--id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/MonitoringSpringResourceProvider.java29
-rw-r--r--id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java58
-rw-r--r--id/server/modules/module-monitoring/src/main/resources/META-INF/services/at.gv.egiz.components.spring.api.SpringResourceProvider1
-rw-r--r--id/server/modules/module-monitoring/src/main/resources/moaid_monitoring.beans.xml15
6 files changed, 122 insertions, 78 deletions
diff --git a/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/auth/servlet/MonitoringServlet.java b/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/auth/servlet/MonitoringController.java
index 70448ef09..8d324b535 100644
--- a/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/auth/servlet/MonitoringServlet.java
+++ b/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/auth/servlet/MonitoringController.java
@@ -24,7 +24,6 @@ package at.gv.egovernment.moa.id.auth.servlet;
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.Arrays;
import java.util.List;
import javax.servlet.ServletException;
@@ -37,39 +36,51 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import at.gv.egovernment.moa.id.commons.api.AuthConfiguration;
-import at.gv.egovernment.moa.id.commons.api.exceptions.ConfigurationException;
import at.gv.egovernment.moa.id.monitoring.TestManager;
import at.gv.egovernment.moa.logging.Logger;
import at.gv.egovernment.moa.util.MiscUtil;
@Controller
-public class MonitoringServlet {
+public class MonitoringController {
private static final String REQUEST_ATTR_MODULE = "module";
@Autowired private AuthConfiguration authConfig;
+ @Autowired private TestManager tests;
- public MonitoringServlet() {
+ public MonitoringController() {
super();
Logger.debug("Registering servlet " + getClass().getName() + " with mapping '/MonitoringServlet'.");
}
@RequestMapping(value = "/MonitoringServlet", method = RequestMethod.GET)
public void getStatusInformation(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
+ throws ServletException, IOException{
- try {
- if (authConfig.isMonitoringActive()) {
- Logger.debug("Monitoring Servlet received request");
+ if (authConfig.isMonitoringActive()) {
+ Logger.debug("Monitoring Servlet received request");
- TestManager tests = TestManager.getInstance();
-
- String modulename = req.getParameter(REQUEST_ATTR_MODULE);
- if (MiscUtil.isEmpty(modulename)) {
+
+
+ String modulename = req.getParameter(REQUEST_ATTR_MODULE);
+ if (MiscUtil.isEmpty(modulename)) {
+
+ List<String> error = tests.executeTests();
+ if (error != null && error.size() > 0) {
+ createErrorMessage(req, resp, error);
+
+ } else {
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentType("text/html;charset=UTF-8");
+ resp.getWriter().write(getHtml(authConfig.getMonitoringMessageSuccess()));
+ Logger.info("Monitoring Servlet finished without errors");
+ }
- List<String> error = tests.executeTests();
- if (error != null && error.size() > 0) {
- createErrorMessage(req, resp, error);
+ } else {
+ if (tests.existsModule(modulename)) {
+ List<String> errors = tests.executeTest(modulename);
+ if (errors != null && errors.size() > 0) {
+ createErrorMessage(req, resp, errors);
} else {
resp.setStatus(HttpServletResponse.SC_OK);
@@ -79,38 +90,21 @@ public class MonitoringServlet {
}
} else {
- if (tests.existsModule(modulename)) {
- List<String> errors = tests.executeTest(modulename);
- if (errors != null && errors.size() > 0) {
- createErrorMessage(req, resp, errors);
-
- } else {
- resp.setStatus(HttpServletResponse.SC_OK);
- resp.setContentType("text/html;charset=UTF-8");
- resp.getWriter().write(getHtml(authConfig.getMonitoringMessageSuccess()));
- Logger.info("Monitoring Servlet finished without errors");
- }
-
- } else {
- Logger.warn("NO Testmodule exists with modulename " + modulename);
- resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
- resp.setContentType("text/html;charset=UTF-8");
- PrintWriter out;
- try {
- out = new PrintWriter(resp.getOutputStream());
- out.write("NO Testmodule exists with modulename " + modulename);
- out.flush();
-
- } catch (IOException e) {
- Logger.warn("Internal Monitoring Servlet Error. ", e);
- }
- }
-
- }
- }
-
- } catch (ConfigurationException e) {
- createErrorMessage(req, resp, Arrays.asList(e.getMessage()));
+ Logger.warn("NO Testmodule exists with modulename " + modulename);
+ resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
+ resp.setContentType("text/html;charset=UTF-8");
+ PrintWriter out;
+ try {
+ out = new PrintWriter(resp.getOutputStream());
+ out.write("NO Testmodule exists with modulename " + modulename);
+ out.flush();
+
+ } catch (IOException e) {
+ Logger.warn("Internal Monitoring Servlet Error. ", e);
+ }
+ }
+
+ }
}
}
diff --git a/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/DatabaseTestModule.java b/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/DatabaseTestModule.java
index 5e4183146..b6d217e4c 100644
--- a/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/DatabaseTestModule.java
+++ b/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/DatabaseTestModule.java
@@ -40,6 +40,12 @@ import at.gv.egovernment.moa.util.MiscUtil;
public class DatabaseTestModule implements TestModuleInterface{
+ private MOASessionDBUtils dbUtils;
+
+ public DatabaseTestModule(MOASessionDBUtils dbUtils){
+ this.dbUtils = dbUtils;
+ }
+
public List<String> performTests() throws Exception {
Logger.trace("Start MOA-ID Database Test.");
@@ -70,9 +76,10 @@ public class DatabaseTestModule implements TestModuleInterface{
Date expioredate = new Date(new Date().getTime() - 120);
+
try {
List<AssertionStore> results;
- Session session = MOASessionDBUtils.getCurrentSession();
+ Session session = dbUtils.getCurrentSession();
synchronized (session) {
session.beginTransaction();
diff --git a/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/MonitoringSpringResourceProvider.java b/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/MonitoringSpringResourceProvider.java
new file mode 100644
index 000000000..0f7dfc7fe
--- /dev/null
+++ b/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/MonitoringSpringResourceProvider.java
@@ -0,0 +1,29 @@
+package at.gv.egovernment.moa.id.monitoring;
+
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+import at.gv.egiz.components.spring.api.SpringResourceProvider;
+
+public class MonitoringSpringResourceProvider implements SpringResourceProvider{
+
+ @Override
+ public String getName() {
+ // TODO Auto-generated method stub
+ return "MOA-ID Monitoring Module";
+ }
+
+ @Override
+ public String[] getPackagesToScan() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Resource[] getResourcesToLoad() {
+ ClassPathResource monitoringResource = new ClassPathResource("/moaid_monitoring.beans.xml", MonitoringSpringResourceProvider.class);
+
+ return new Resource[] {monitoringResource};
+ }
+
+}
diff --git a/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java b/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java
index b25eed520..b5ccd73f6 100644
--- a/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java
+++ b/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java
@@ -27,49 +27,27 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.springframework.beans.factory.annotation.Autowired;
+
import at.gv.egovernment.moa.id.commons.api.AuthConfiguration;
import at.gv.egovernment.moa.id.commons.api.exceptions.ConfigurationException;
-import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProviderFactory;
+import at.gv.egovernment.moa.id.commons.db.MOASessionDBUtils;
import at.gv.egovernment.moa.logging.Logger;
import at.gv.egovernment.moa.util.FileUtils;
-public class TestManager {
-
- private static TestManager instance;
+public class TestManager{
+ @Autowired private MOASessionDBUtils moaSessionDBUtils;
+ @Autowired private AuthConfiguration authConfig;
private Map<String, TestModuleInterface> tests = new HashMap<String, TestModuleInterface>();
- public static TestManager getInstance() throws ConfigurationException {
- if (instance == null)
- instance = new TestManager();
-
- return instance;
- }
-
- private TestManager() throws ConfigurationException {
-
- AuthConfiguration config = AuthConfigurationProviderFactory.getInstance();
-
- //add Database test
- DatabaseTestModule test1 = new DatabaseTestModule();
- tests.put(test1.getName(), test1);
-
- //add IdentityLink verification test
- IdentityLinkTestModule test2 = new IdentityLinkTestModule();
- String idlurl = FileUtils.makeAbsoluteURL(config.getMonitoringTestIdentityLinkURL(), config.getRootConfigFileDir());
- try {
- test2.initializeTest(0, idlurl);
- tests.put(test2.getName(), test2);;
-
- } catch (Exception e) {
- Logger.warn("MOA-ID IdentityLink Test can not performed without IdentityLink. Insert IdentityLink file to MOA-ID configuration", e);
- }
+ public TestManager(){
+
}
public List<String> executeTests() {
Logger.debug("Start MOA-ID-Auth testing");
-
List<String> errors;
for (TestModuleInterface test : tests.values()) {
@@ -109,4 +87,24 @@ public class TestManager {
public boolean existsModule(String modulename) {
return tests.containsKey(modulename);
}
+
+ public void init() throws ConfigurationException{
+ Logger.debug("Start initializing MOA-ID-Auth TestManager");
+
+ //add Database test
+ DatabaseTestModule test1 = new DatabaseTestModule(this.moaSessionDBUtils);
+ tests.put(test1.getName(), test1);
+
+ //add IdentityLink verification test
+ IdentityLinkTestModule test2 = new IdentityLinkTestModule();
+ String idlurl = FileUtils.makeAbsoluteURL(authConfig.getMonitoringTestIdentityLinkURL(), authConfig.getRootConfigFileDir());
+ try {
+ test2.initializeTest(0, idlurl);
+ tests.put(test2.getName(), test2);;
+
+ } catch (Exception e) {
+ Logger.warn("MOA-ID IdentityLink Test can not performed without IdentityLink. Insert IdentityLink file to MOA-ID configuration", e);
+ }
+ }
+
}
diff --git a/id/server/modules/module-monitoring/src/main/resources/META-INF/services/at.gv.egiz.components.spring.api.SpringResourceProvider b/id/server/modules/module-monitoring/src/main/resources/META-INF/services/at.gv.egiz.components.spring.api.SpringResourceProvider
new file mode 100644
index 000000000..b696bcdd7
--- /dev/null
+++ b/id/server/modules/module-monitoring/src/main/resources/META-INF/services/at.gv.egiz.components.spring.api.SpringResourceProvider
@@ -0,0 +1 @@
+at.gv.egovernment.moa.id.monitoring.MonitoringSpringResourceProvider \ No newline at end of file
diff --git a/id/server/modules/module-monitoring/src/main/resources/moaid_monitoring.beans.xml b/id/server/modules/module-monitoring/src/main/resources/moaid_monitoring.beans.xml
new file mode 100644
index 000000000..41fab4444
--- /dev/null
+++ b/id/server/modules/module-monitoring/src/main/resources/moaid_monitoring.beans.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
+
+ <bean id="testManager"
+ class="at.gv.egovernment.moa.id.monitoring.TestManager"
+ init-method="init"/>
+</beans> \ No newline at end of file