/******************************************************************************* * Copyright 2014 Federal Chancellery Austria * MOA-ID has been developed in a cooperation between BRZ, the Federal * Chancellery Austria - ICT staff unit, and Graz University of Technology. * * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by * the European Commission - subsequent versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: * http://www.osor.eu/eupl/ * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Licence for the specific language governing permissions and * limitations under the Licence. * * This product combines work with different licenses. See the "NOTICE" text * file for details on the various modules and licenses. * The "NOTICE" text file is part of the distribution. Any derivative works * that you distribute must include a readable copy of the "NOTICE" text file. *******************************************************************************/ package at.gv.egovernment.moa.id.monitoring; import java.util.Arrays; 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.advancedlogging.IStatisticLogger; 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.storage.ITransactionStorage; import at.gv.egovernment.moa.logging.Logger; import at.gv.egovernment.moa.util.FileUtils; public class TestManager{ @Autowired private ITransactionStorage transactionStorage; @Autowired(required=false) private IStatisticLogger statisticLogDBUtils = null; @Autowired private AuthConfiguration authConfig; private Map tests = new HashMap(); public TestManager(){ } public List executeTests() { Logger.debug("Start MOA-ID-Auth testing"); List errors; for (TestModuleInterface test : tests.values()) { try { errors = test.performTests(); if (errors != null && errors.size() > 0) return errors; } catch (Exception e) { Logger.warn("General Testing Eception during Test " + test.getClass() + ": ", e); return Arrays.asList(e.getMessage()); } } return null; } public List executeTest(String testname) { TestModuleInterface test = tests.get(testname); if (test != null) { try { return test.performTests(); } catch (Exception e) { Logger.warn("General Testing Eception during Test " + test.getName() + ": ", e); return Arrays.asList(e.getMessage()); } } else { Logger.info("TestModule with Name " + testname + " is not implemented"); return null; } } 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.transactionStorage, this.statisticLogDBUtils); 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); } } }