aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--id/server/data/deploy/conf/moa-id/moa-id.properties17
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/DummyStatisticLogger.java49
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/IStatisticLogger.java37
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/StatisticLogger.java11
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/AbstractController.java5
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/ConfigurationProviderImpl.java38
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/DBTransactionStorage.java2
-rw-r--r--id/server/idserverlib/src/main/resources/moaid.authentication.beans.xml17
-rw-r--r--id/server/idserverlib/src/main/resources/session.common.beans.xml27
-rw-r--r--id/server/idserverlib/src/main/resources/session.db.beans.xml23
-rw-r--r--id/server/idserverlib/src/main/resources/session.redis.beans.xml3
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/SpringProfileConstants.java8
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/MOASessionDBUtils.java4
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/StatisticLogDBUtils.java184
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AssertionStore.java2
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/statistic/StatisticLog.java2
-rw-r--r--id/server/moa-id-commons/src/main/resources/META-INF/persistence.xml24
-rw-r--r--id/server/moa-id-commons/src/main/resources/configuration.beans.xml1
-rw-r--r--id/server/moa-id-commons/src/main/resources/hibernate_moasession.cfg.xml15
-rw-r--r--id/server/moa-id-commons/src/main/resources/hibernate_statistic.cfg.xml11
-rw-r--r--id/server/moa-id-commons/src/main/resources/statistic.logging.beans.xml75
-rw-r--r--id/server/moa-id-spring-initializer/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthSpringInitializer.java29
-rw-r--r--id/server/moa-id-spring-initializer/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthSpringResourceProvider.java5
-rw-r--r--id/server/modules/moa-id-module-openID/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/json/OAuth20SignatureUtil.java4
-rw-r--r--id/server/modules/moa-id-module-openID/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/CertTest.java6
-rw-r--r--id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/DatabaseTestModule.java6
-rw-r--r--id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java4
-rw-r--r--id/server/modules/module-monitoring/src/main/resources/moaid_monitoring.beans.xml3
28 files changed, 350 insertions, 262 deletions
diff --git a/id/server/data/deploy/conf/moa-id/moa-id.properties b/id/server/data/deploy/conf/moa-id/moa-id.properties
index 5e8bfa567..554d0b522 100644
--- a/id/server/data/deploy/conf/moa-id/moa-id.properties
+++ b/id/server/data/deploy/conf/moa-id/moa-id.properties
@@ -129,7 +129,19 @@ advancedlogging.hibernate.current_session_context_class=thread
advancedlogging.hibernate.transaction.auto_close_session=true
advancedlogging.hibernate.show_sql=false
advancedlogging.hibernate.format_sql=true
-
+advancedlogging.hibernate.transaction.flush_before_completion=true
+
+advancedlogging.dbcp.connectionProperties=
+advancedlogging.dbcp.initialSize=3
+advancedlogging.dbcp.maxActive=20
+advancedlogging.dbcp.maxIdle=8
+advancedlogging.dbcp.minIdle=3
+advancedlogging.dbcp.maxWaitMillis=-1
+advancedlogging.dbcp.testOnBorrow=true
+advancedlogging.dbcp.testOnReturn=false
+advancedlogging.dbcp.testWhileIdle=false
+advancedlogging.dbcp.validationQuery=select 1
+advancedlogging.jpaVendorAdapter.generateDdl=true
################ Additonal eID-modul configuration ####################################
## This additional eID moduls add special functionality to MOA-ID-Auth.
@@ -166,7 +178,8 @@ modules.federatedAuth.response.encryption.alias=pvp_assertion
modules.federatedAuth.response.encryption.password=password
#Redis Settings, if Redis is used as a backend for session data.
-#has to be enabled with a start parameter for tomcat -Dspring.profiles.active=redis
+#has to be enabled with the following parameter
+#redis.active=true
redis.use-pool=true
redis.host-name=localhost
redis.port=6379
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/DummyStatisticLogger.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/DummyStatisticLogger.java
new file mode 100644
index 000000000..5a1b7205d
--- /dev/null
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/DummyStatisticLogger.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.advancedlogging;
+
+
+import org.springframework.stereotype.Service;
+
+import at.gv.egovernment.moa.id.commons.api.IRequest;
+import at.gv.egovernment.moa.id.data.IAuthData;
+import at.gv.egovernment.moa.logging.Logger;
+
+@Service("StatisticLogger")
+public class DummyStatisticLogger implements IStatisticLogger{
+
+ @Override
+ public void logSuccessOperation(IRequest protocolRequest,
+ IAuthData authData, boolean isSSOSession) {
+ Logger.trace("Dummy-logSuccessOperation");
+ }
+
+ @Override
+ public void logErrorOperation(Throwable throwable) {
+ Logger.trace("Dummy-logErrorOperation");
+ }
+
+ @Override
+ public void logErrorOperation(Throwable throwable, IRequest errorRequest) {
+ Logger.trace("Dummy-logErrorOperation");
+ }}
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/IStatisticLogger.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/IStatisticLogger.java
new file mode 100644
index 000000000..2d97d7258
--- /dev/null
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/IStatisticLogger.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.advancedlogging;
+
+import at.gv.egovernment.moa.id.commons.api.IRequest;
+import at.gv.egovernment.moa.id.data.IAuthData;
+
+
+public interface IStatisticLogger {
+
+ public void logSuccessOperation(IRequest protocolRequest, IAuthData authData, boolean isSSOSession);
+
+ public void logErrorOperation(Throwable throwable);
+
+ public void logErrorOperation(Throwable throwable, IRequest errorRequest);
+
+}
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/StatisticLogger.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/StatisticLogger.java
index 0171f9d90..34bdd350b 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/StatisticLogger.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/StatisticLogger.java
@@ -33,6 +33,7 @@ import javax.xml.bind.Unmarshaller;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate;
@@ -48,6 +49,7 @@ import at.gv.egovernment.moa.id.commons.api.IOAAuthParameters;
import at.gv.egovernment.moa.id.commons.api.IRequest;
import at.gv.egovernment.moa.id.commons.api.exceptions.ConfigurationException;
import at.gv.egovernment.moa.id.commons.api.exceptions.MOAIDException;
+import at.gv.egovernment.moa.id.commons.config.SpringProfileConstants;
import at.gv.egovernment.moa.id.commons.db.StatisticLogDBUtils;
import at.gv.egovernment.moa.id.commons.db.dao.statistic.StatisticLog;
import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException;
@@ -60,7 +62,7 @@ import at.gv.egovernment.moa.logging.Logger;
import at.gv.egovernment.moa.util.MiscUtil;
@Service("StatisticLogger")
-public class StatisticLogger {
+public class StatisticLogger implements IStatisticLogger{
private static final String GENERIC_LOCALBKU = ":3496/https-security-layer-request";
private static final String GENERIC_HANDYBKU = "https://www.handy-signatur.at/";
@@ -79,6 +81,7 @@ public class StatisticLogger {
@Autowired AuthConfiguration authConfig;
@Autowired IAuthenticationSessionStoreage authenticatedSessionStorage;
+ @Autowired StatisticLogDBUtils statisticLogDBUtils;
public void logSuccessOperation(IRequest protocolRequest, IAuthData authData, boolean isSSOSession) {
@@ -191,7 +194,7 @@ public class StatisticLogger {
try {
- StatisticLogDBUtils.saveOrUpdate(dblog);
+ statisticLogDBUtils.saveOrUpdate(dblog);
} catch (MOADatabaseException e) {
Logger.warn("Statistic Log can not be stored into Database", e);
@@ -217,7 +220,7 @@ public class StatisticLogger {
try {
- StatisticLogDBUtils.saveOrUpdate(dblog);
+ statisticLogDBUtils.saveOrUpdate(dblog);
} catch (MOADatabaseException e) {
Logger.warn("Statistic Log can not be stored into Database", e);
@@ -268,7 +271,7 @@ public class StatisticLogger {
try {
- StatisticLogDBUtils.saveOrUpdate(dblog);
+ statisticLogDBUtils.saveOrUpdate(dblog);
} catch (MOADatabaseException e) {
Logger.warn("Statistic Log can not be stored into Database", e);
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/AbstractController.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/AbstractController.java
index 09e9edb7b..1431911a3 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/AbstractController.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/AbstractController.java
@@ -33,10 +33,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ExceptionHandler;
import com.google.common.net.MediaType;
-
+import at.gv.egovernment.moa.id.advancedlogging.IStatisticLogger;
import at.gv.egovernment.moa.id.advancedlogging.MOAIDEventConstants;
import at.gv.egovernment.moa.id.advancedlogging.MOAReversionLogger;
-import at.gv.egovernment.moa.id.advancedlogging.StatisticLogger;
import at.gv.egovernment.moa.id.auth.exception.InvalidProtocolRequestException;
import at.gv.egovernment.moa.id.auth.exception.ProtocolNotActiveException;
import at.gv.egovernment.moa.id.auth.frontend.builder.DefaultGUIFormBuilderConfiguration;
@@ -71,7 +70,7 @@ public abstract class AbstractController extends MOAIDAuthConstants {
public static final String ERROR_CODE_PARAM = "errorid";
- @Autowired protected StatisticLogger statisticLogger;
+ @Autowired protected IStatisticLogger statisticLogger;
@Autowired protected IRequestStorage requestStorage;
@Autowired protected ITransactionStorage transactionStorage;
@Autowired protected MOAReversionLogger revisionsLogger;
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/ConfigurationProviderImpl.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/ConfigurationProviderImpl.java
index a07099a93..67ad4762c 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/ConfigurationProviderImpl.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/ConfigurationProviderImpl.java
@@ -46,6 +46,7 @@
package at.gv.egovernment.moa.id.config;
+import java.util.ArrayList;
import java.util.Map;
import java.util.Properties;
@@ -53,6 +54,7 @@ import org.hibernate.cfg.Configuration;
import at.gv.egovernment.moa.id.commons.api.ConfigurationProvider;
import at.gv.egovernment.moa.id.commons.api.exceptions.ConfigurationException;
+import at.gv.egovernment.moa.id.commons.config.SpringProfileConstants;
import at.gv.egovernment.moa.id.commons.db.MOASessionDBUtils;
import at.gv.egovernment.moa.id.commons.db.StatisticLogDBUtils;
import at.gv.egovernment.moa.id.commons.db.dao.session.AssertionStore;
@@ -229,14 +231,14 @@ public abstract class ConfigurationProviderImpl implements ConfigurationProvider
//MOASessionDBUtils.initHibernate(config, moaSessionProp);
//initial advanced logging
- if (Boolean.valueOf(props.getProperty("configuration.advancedlogging.active", "false"))) {
- Logger.info("Advanced statistic log is activated, starting initialization process ...");
- Configuration statisticconfig = new Configuration();
- statisticconfig.addAnnotatedClass(StatisticLog.class);
- statisticconfig.addProperties(statisticProps);
- StatisticLogDBUtils.initHibernate(statisticconfig, statisticProps);
- Logger.info("Advanced statistic log is initialized.");
- }
+// if (Boolean.valueOf(props.getProperty("configuration.advancedlogging.active", "false"))) {
+// Logger.info("Advanced statistic log is activated, starting initialization process ...");
+// Configuration statisticconfig = new Configuration();
+// statisticconfig.addAnnotatedClass(StatisticLog.class);
+// statisticconfig.addProperties(statisticProps);
+// StatisticLogDBUtils.initHibernate(statisticconfig, statisticProps);
+// Logger.info("Advanced statistic log is initialized.");
+// }
}
Logger.trace("Hibernate initialization finished.");
@@ -271,6 +273,7 @@ public abstract class ConfigurationProviderImpl implements ConfigurationProvider
eGovUtilsConfig =
new EgovUtilPropertiesConfiguration(eGovUtilsConfigProp, rootConfigFileDir);
}
+ this.generateActiveProfiles(props);
}
@@ -281,5 +284,24 @@ public abstract class ConfigurationProviderImpl implements ConfigurationProvider
public EgovUtilPropertiesConfiguration geteGovUtilsConfig() {
return eGovUtilsConfig;
}
+
+ private ArrayList<String> activeProfiles = new ArrayList<String>();
+
+ public void generateActiveProfiles(Properties props){
+ if (Boolean.valueOf(props.getProperty("configuration.advancedlogging.active", "false"))) {
+ activeProfiles.add(SpringProfileConstants.ADVANCED_LOG);
+ }else{
+ activeProfiles.add("advancedLogOff");
+ }
+ if (Boolean.valueOf(props.getProperty("redis.active", "false"))) {
+ activeProfiles.add(SpringProfileConstants.REDIS_BACKEND);
+ }else{
+ activeProfiles.add(SpringProfileConstants.DB_BACKEND);
+ }
+ }
+
+ public String[] getActiveProfiles(){
+ return activeProfiles.toArray(new String[0]);
+ }
}
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/DBTransactionStorage.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/DBTransactionStorage.java
index fa8ca8547..f17e4a99a 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/DBTransactionStorage.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/DBTransactionStorage.java
@@ -252,7 +252,7 @@ public class DBTransactionStorage implements ITransactionStorage {
//store AssertionStore element to Database
//try {
- entityManager.merge(element);
+ entityManager.persist(element);
//MOASessionDBUtils.saveOrUpdate(element);
Logger.debug(value.getClass().getName() + " with ID: " + key + " is stored in Database");
//
diff --git a/id/server/idserverlib/src/main/resources/moaid.authentication.beans.xml b/id/server/idserverlib/src/main/resources/moaid.authentication.beans.xml
index 4201d31b1..ba8c47304 100644
--- a/id/server/idserverlib/src/main/resources/moaid.authentication.beans.xml
+++ b/id/server/idserverlib/src/main/resources/moaid.authentication.beans.xml
@@ -53,9 +53,6 @@
<bean id="ProcessInstanceStoreage"
class="at.gv.egovernment.moa.id.process.dao.ProcessInstanceStoreDAOImpl"/>
- <bean id="StatisticLogger"
- class="at.gv.egovernment.moa.id.advancedlogging.StatisticLogger"/>
-
<bean id="MOAReversionLogger"
class="at.gv.egovernment.moa.id.advancedlogging.MOAReversionLogger"/>
@@ -95,7 +92,17 @@
<bean id="EvaluateSSOConsentsTaskImpl"
class="at.gv.egovernment.moa.id.auth.modules.internal.tasks.EvaluateSSOConsentsTaskImpl"
scope="prototype"/>
+
+ <beans profile="advancedLogOn">
+ <bean id="StatisticLogger"
+ class="at.gv.egovernment.moa.id.advancedlogging.StatisticLogger"/>
+ </beans>
+ <beans profile="advancedLogOff">
+ <bean id="StatisticLogger"
+ class="at.gv.egovernment.moa.id.advancedlogging.DummyStatisticLogger"/>
+ </beans>
-
-</beans> \ No newline at end of file
+</beans>
+
+
diff --git a/id/server/idserverlib/src/main/resources/session.common.beans.xml b/id/server/idserverlib/src/main/resources/session.common.beans.xml
index 10c1320cc..defa47ec0 100644
--- a/id/server/idserverlib/src/main/resources/session.common.beans.xml
+++ b/id/server/idserverlib/src/main/resources/session.common.beans.xml
@@ -10,7 +10,8 @@
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">
-
+
+ <context:property-placeholder location="${moa.id.configuration}"/>
<context:annotation-config/>
<bean id="sessionDataSource" class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true" destroy-method="close">
@@ -32,9 +33,9 @@
<property name="validationQuery" value="${moasession.dbcp.validationQuery}" />
</bean>
- <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
+ <bean id="sessionSessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="sessionDataSource"/>
- <property name="packagesToScan" value="at.gv.egovernment.moa.id.commons.db" />
+ <property name="packagesToScan" value="at.gv.egovernment.moa.id.commons.db.dao.session" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${moasession.hibernate.dialect}</prop>
@@ -47,9 +48,27 @@
</property>
</bean>
+ <!-- MYSQL Conector -->
+ <tx:annotation-driven transaction-manager="sessionTransactionManager"/>
+
+ <bean id="sessionJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
+ <property name="showSql" value="${moasession.hibernate.show_sql}" />
+ <property name="generateDdl" value="${moasession.jpaVendorAdapter.generateDdl}" />
+ <property name="databasePlatform" value="${moasession.hibernate.dialect}" />
+ </bean>
+
+ <bean name="session" id="session" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" depends-on="sessionDataSource">
+ <property name="dataSource" ref="sessionDataSource" />
+ <property name="jpaVendorAdapter" ref="sessionJpaVendorAdapter" />
+ <property name="packagesToScan" value="at.gv.egovernment.moa.id.commons.db.dao.session" />
+ <property name="persistenceUnitName" value="session" />
+ </bean>
+
+ <bean name="sessionTransactionManager" id="sessionTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
+ <property name="entityManagerFactory" ref="session" />
+ </bean>
<bean id="moaSessionDBUtils" class="at.gv.egovernment.moa.id.commons.db.MOASessionDBUtils">
</bean>
-
</beans> \ No newline at end of file
diff --git a/id/server/idserverlib/src/main/resources/session.db.beans.xml b/id/server/idserverlib/src/main/resources/session.db.beans.xml
index 18849c3f1..5ed390ffe 100644
--- a/id/server/idserverlib/src/main/resources/session.db.beans.xml
+++ b/id/server/idserverlib/src/main/resources/session.db.beans.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<beans profile="default"
+<beans profile="dbBackend"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
@@ -11,29 +11,10 @@
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">
-
+ <context:property-placeholder location="${moa.id.configuration}"/>
<bean id="TransactionStorage"
class="at.gv.egovernment.moa.id.storage.DBTransactionStorage"
/>
- <!-- MYSQL Conector -->
- <tx:annotation-driven transaction-manager="sessionTransactionManager"/>
-
- <bean id="sessionJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
- <property name="showSql" value="${moasession.hibernate.show_sql}" />
- <property name="generateDdl" value="${moasession.jpaVendorAdapter.generateDdl}" />
- <property name="databasePlatform" value="${moasession.hibernate.dialect}" />
- </bean>
-
- <bean name="session" id="session" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" depends-on="sessionDataSource">
- <property name="dataSource" ref="sessionDataSource" />
- <property name="jpaVendorAdapter" ref="sessionJpaVendorAdapter" />
- <property name="persistenceUnitName" value="session" />
- </bean>
-
- <bean name="sessionTransactionManager" id="sessionTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
- <property name="entityManagerFactory" ref="session" />
- </bean>
-
</beans> \ No newline at end of file
diff --git a/id/server/idserverlib/src/main/resources/session.redis.beans.xml b/id/server/idserverlib/src/main/resources/session.redis.beans.xml
index 9caf5fc6a..feda9b273 100644
--- a/id/server/idserverlib/src/main/resources/session.redis.beans.xml
+++ b/id/server/idserverlib/src/main/resources/session.redis.beans.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<beans profile="redis"
+<beans profile="redisBackend"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
@@ -11,6 +11,7 @@
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">
+ <context:property-placeholder location="${moa.id.configuration}"/>
<bean id="TransactionStorage"
class="at.gv.egovernment.moa.id.storage.RedisTransactionStorage"/>
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/SpringProfileConstants.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/SpringProfileConstants.java
new file mode 100644
index 000000000..14824b1f8
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/SpringProfileConstants.java
@@ -0,0 +1,8 @@
+package at.gv.egovernment.moa.id.commons.config;
+
+public final class SpringProfileConstants {
+
+ public static final String ADVANCED_LOG = "advancedLogOn";
+ public static final String REDIS_BACKEND = "redisBackend";
+ public static final String DB_BACKEND = "dbBackend";
+}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/MOASessionDBUtils.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/MOASessionDBUtils.java
index fbbaf9476..5cdd607ac 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/MOASessionDBUtils.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/MOASessionDBUtils.java
@@ -30,19 +30,21 @@ import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException;
import at.gv.egovernment.moa.logging.Logger;
-@Transactional
+@Transactional("sessionTransactionManager")
public class MOASessionDBUtils {
private SessionFactory sessionFactory;
@Autowired
+ @Qualifier("sessionSessionFactory")
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/StatisticLogDBUtils.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/StatisticLogDBUtils.java
index 7e031cc76..51bb0eb6d 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/StatisticLogDBUtils.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/StatisticLogDBUtils.java
@@ -24,169 +24,65 @@ package at.gv.egovernment.moa.id.commons.db;
import java.util.Properties;
-import org.apache.commons.lang3.StringUtils;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
-import org.hibernate.service.ServiceRegistry;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.transaction.annotation.Transactional;
import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException;
import at.gv.egovernment.moa.logging.Logger;
-public final class StatisticLogDBUtils {
+@Transactional("statisticLogTransactionManager")
+public class StatisticLogDBUtils {
+
+ private SessionFactory sessionFactory;
- private static SessionFactory sessionFactory;
- private static ServiceRegistry serviceRegistry;
-
- @SuppressWarnings("rawtypes")
- private static final ThreadLocal THREAD_LOCAL_STATISTIC = new ThreadLocal();
- private static boolean automaticSessionHandling = false;
+ @Autowired
+ @Qualifier("statisticLogSessionFactory")
+ public void setstatisticLogSessionFactory(SessionFactory sessionFactory) {
+ this.sessionFactory = sessionFactory;
+ }
- private static final String[] AUTOMATIC_SESSION_HANDLING_VALUES = new String[] { "jta", "thread" };
- private static final String SESSION_HANDLING_KEY = "hibernate.current_session_context_class";
-
- protected StatisticLogDBUtils() { }
public static void initHibernate(Configuration config, Properties hibernateProperties) {
- String scm = StringUtils.trimToNull(hibernateProperties.getProperty(SESSION_HANDLING_KEY));
- if (scm != null) {
- automaticSessionHandling = scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[0]) != -1 || scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[1]) != -1;
- }
- Logger.debug("Evaluating hibernate property \"" + SESSION_HANDLING_KEY + "\".");
- if (automaticSessionHandling) {
- Logger.info("Hibernate is automatically handling session context management.");
- } else {
- Logger.info("Hibernate is NOT automatically handling session context management. Using build-in ThreadLocal session handling.");
- }
- try {
- //Create the SessionFactory
- Logger.debug("Creating initial StatisicLogger session factory...");
-
- config.configure("hibernate_statistic.cfg.xml");
- //serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
-
- serviceRegistry = new StandardServiceRegistryBuilder().
- applySettings(config.getProperties()).build();
-
- sessionFactory = config.buildSessionFactory(serviceRegistry);
- Logger.debug("Initial StatisicLogger session factory successfully created.");
-
- } catch (Throwable ex) {
- Logger.error("Initial StatisicLogger session factory creation failed: " + ex.getMessage());
- throw new ExceptionInInitializerError(ex);
- }
- }
-
- /**
- * Checks if a session factory is currently available. If necessary a new
- * session factory is created.
- *
- * @return current (or new) session factory
- * @throws HibernateException
- * thrown if a hibernate error occurs
- */
- public static Session getCurrentSession() {
- if (automaticSessionHandling) {
- return sessionFactory.getCurrentSession();
- }
- Session session = (Session) THREAD_LOCAL_STATISTIC.get();
- // Open a new Session, if this Thread has none yet
- if (session == null || !session.isConnected()) {
- session = getNewSession();
- }
- return session;
}
- @SuppressWarnings("unchecked")
- public static Session getNewSession() {
- if (automaticSessionHandling) {
- Logger.warn("Session is being automatically handled by hibernate. Therefore this session maybe not being newly created. Use HibernateUtil.getCurrentSession() instead.");
- return sessionFactory.getCurrentSession();
- }
- Session session = (Session) THREAD_LOCAL_STATISTIC.get();
- if (session != null) {
- Logger.warn("Previous StatisicLogger session has not been closed; closing session now.");
- closeSession();
- }
- Logger.debug("Opening new StatisicLogger hibernate session...");
- try {
- session = sessionFactory.openSession();
- THREAD_LOCAL_STATISTIC.set(session);
- } catch (HibernateException hex) {
- Logger.error(hex.getMessage());
- }
- return session;
- }
-
- /**
- * Closes the current session.
- *
- * @throws HibernateException
- * thrown if session is already closed or a hibernate error
- * occurs.
- */
- @SuppressWarnings("unchecked")
- public static void closeSession() {
- if (automaticSessionHandling) {
- Logger.warn("Session is being automatically handled by hibernate. Therefore the current session cannot be closed on demand.");
- return;
- }
- Logger.debug("Closing current StatisicLogger hibernate session...");
- Session session = (Session) THREAD_LOCAL_STATISTIC.get();
- THREAD_LOCAL_STATISTIC.set(null);
- if (session != null) {
- try {
- session.close();
-
- } catch (HibernateException hex) {
- Logger.error(hex.getMessage());
- }
- }
- }
-
- public static boolean saveOrUpdate(Object dbo) throws MOADatabaseException {
- Transaction tx = null;
- try {
- Session session = StatisticLogDBUtils.getCurrentSession();
-
- synchronized (session) {
- tx = session.beginTransaction();
- session.saveOrUpdate(dbo);
- tx.commit();
- }
-
- Logger.info("Insert advanced statistic log entry into database");
- return true;
-
- } catch(HibernateException e) {
- Logger.warn("Error during StatisicLogger database saveOrUpdate. Rollback.", e);
- tx.rollback();
- throw new MOADatabaseException(e);
- }
- }
+ public boolean saveOrUpdate(Object dbo) throws MOADatabaseException {
- public static boolean delete(Object dbo) {
- Transaction tx = null;
- try {
- Session session = StatisticLogDBUtils.getCurrentSession();
-
- synchronized (session) {
- tx = session.beginTransaction();
- session.delete(dbo);
- tx.commit();
- }
-
- return true;
+ try {
+ Session session = sessionFactory.getCurrentSession();
+ session.saveOrUpdate(dbo);
+ //session.persist(dbo);
+ return true;
} catch(HibernateException e) {
- Logger.warn("Error during StatisicLogger database delete. Rollback.", e);
- tx.rollback();
- return false;
+ Logger.warn("Error during StatisicLogger database saveOrUpdate.", e);
+
+ throw new MOADatabaseException(e);
}
+
}
+
+ public boolean delete(Object dbo) {
+ try {
+ Session session = sessionFactory.getCurrentSession();
+ session.delete(dbo);
+ return true;
+
+ } catch(HibernateException e) {
+ Logger.warn("Error during StatisicLogger database delete. Rollback.");
+ return false;
+ }
+ }
+
+
+ public Session getCurrentSession() {
+ // TODO Auto-generated method stub
+ return sessionFactory.getCurrentSession();
+ }
}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AssertionStore.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AssertionStore.java
index d9528cbed..4c6cd16c0 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AssertionStore.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AssertionStore.java
@@ -65,7 +65,7 @@ public class AssertionStore implements Serializable{
@Id
- @GeneratedValue(strategy = GenerationType.AUTO)
+ @GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", unique=true, nullable=false)
private long id;
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/statistic/StatisticLog.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/statistic/StatisticLog.java
index 97f26812f..ba48f8caf 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/statistic/StatisticLog.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/statistic/StatisticLog.java
@@ -39,7 +39,7 @@ import org.hibernate.annotations.DynamicUpdate;
@Entity
-@DynamicUpdate(value=true)
+//@DynamicUpdate(value=true)
@Table(name = "statisticlog")
@NamedQueries({
@NamedQuery(name="getAllEntriesNotBeforeTimeStamp", query = "select statisiclog from StatisticLog statisiclog where statisiclog.timestamp > :timeout")
diff --git a/id/server/moa-id-commons/src/main/resources/META-INF/persistence.xml b/id/server/moa-id-commons/src/main/resources/META-INF/persistence.xml
deleted file mode 100644
index 5c1558507..000000000
--- a/id/server/moa-id-commons/src/main/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<persistence xmlns="http://java.sun.com/xml/ns/persistence"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
-http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
- version="2.0">
-
- <persistence-unit name="config" transaction-type="RESOURCE_LOCAL">
- <provider>org.hibernate.ejb.HibernatePersistence</provider>
- <class>at.gv.egovernment.moa.id.commons.db.dao.config.ConfigProperty</class>
- <!-- <class>at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase</class> -->
- <properties>
- </properties>
- </persistence-unit>
-
- <persistence-unit name="session" transaction-type="RESOURCE_LOCAL">
- <provider>org.hibernate.ejb.HibernatePersistence</provider>
- <class>at.gv.egovernment.moa.id.commons.db.dao.session.AssertionStore</class>
- <!-- <class>at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase</class> -->
- <properties>
- </properties>
- </persistence-unit>
-
-</persistence> \ No newline at end of file
diff --git a/id/server/moa-id-commons/src/main/resources/configuration.beans.xml b/id/server/moa-id-commons/src/main/resources/configuration.beans.xml
index 4d3caea8c..b97b1c88b 100644
--- a/id/server/moa-id-commons/src/main/resources/configuration.beans.xml
+++ b/id/server/moa-id-commons/src/main/resources/configuration.beans.xml
@@ -17,6 +17,7 @@
<bean id="moaidconfig" class="at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfigurationImpl" />
<bean name="config" id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
+ <property name="packagesToScan" value="at.gv.egovernment.moa.id.commons.db.dao.config" />
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
<property name="persistenceUnitName" value="config" />
diff --git a/id/server/moa-id-commons/src/main/resources/hibernate_moasession.cfg.xml b/id/server/moa-id-commons/src/main/resources/hibernate_moasession.cfg.xml
deleted file mode 100644
index e40c8b8a9..000000000
--- a/id/server/moa-id-commons/src/main/resources/hibernate_moasession.cfg.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!DOCTYPE hibernate-configuration PUBLIC
-"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
-"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
-
-<hibernate-configuration>
- <session-factory>
- <!-- MOA Session handling mapping files -->
- <mapping class="at.gv.egovernment.moa.id.commons.db.dao.session.AssertionStore"/>
- <mapping class="at.gv.egovernment.moa.id.commons.db.dao.session.AuthenticatedSessionStore"/>
- <mapping class="at.gv.egovernment.moa.id.commons.db.dao.session.OASessionStore"/>
- <mapping class="at.gv.egovernment.moa.id.commons.db.dao.session.OldSSOSessionIDStore"/>
- <mapping class="at.gv.egovernment.moa.id.commons.db.dao.session.ExceptionStore"/>
- </session-factory>
-</hibernate-configuration> \ No newline at end of file
diff --git a/id/server/moa-id-commons/src/main/resources/hibernate_statistic.cfg.xml b/id/server/moa-id-commons/src/main/resources/hibernate_statistic.cfg.xml
deleted file mode 100644
index aa77a9c67..000000000
--- a/id/server/moa-id-commons/src/main/resources/hibernate_statistic.cfg.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!DOCTYPE hibernate-configuration PUBLIC
-"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
-"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
-
-<hibernate-configuration>
- <session-factory>
- <!-- MOA advanced statistic handling mapping files -->
- <mapping class="at.gv.egovernment.moa.id.commons.db.dao.statistic.StatisticLog"/>
- </session-factory>
-</hibernate-configuration> \ No newline at end of file
diff --git a/id/server/moa-id-commons/src/main/resources/statistic.logging.beans.xml b/id/server/moa-id-commons/src/main/resources/statistic.logging.beans.xml
new file mode 100644
index 000000000..5f80c6439
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/resources/statistic.logging.beans.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans profile="advancedLogOn"
+ 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"
+ xmlns:p="http://www.springframework.org/schema/p"
+ 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">
+
+ <context:annotation-config></context:annotation-config>
+ <tx:annotation-driven transaction-manager="statisticLogTransactionManager"/>
+
+ <bean id="statisticLogDataSource" class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true" destroy-method="close">
+ <aop:scoped-proxy/>
+ <property name="driverClassName" value="${advancedlogging.hibernate.connection.driver_class}" />
+ <property name="url" value="${advancedlogging.hibernate.connection.url}"/>
+ <property name="username" value="${advancedlogging.hibernate.connection.username}" />
+ <property name="password" value="${advancedlogging.hibernate.connection.password}" />
+
+ <property name="connectionProperties" value="${advancedlogging.dbcp.connectionProperties}" />
+ <property name="initialSize" value="${advancedlogging.dbcp.initialSize}" />
+ <property name="maxTotal" value="${advancedlogging.dbcp.maxActive}" />
+ <property name="maxIdle" value="${advancedlogging.dbcp.maxIdle}" />
+ <property name="minIdle" value="${advancedlogging.dbcp.minIdle}" />
+ <!-- property name="maxWait" value="${moasession.dbcp.maxWaitMillis}" / -->
+ <property name="testOnBorrow" value="${advancedlogging.dbcp.testOnBorrow}" />
+ <property name="testOnReturn" value="${advancedlogging.dbcp.testOnReturn}" />
+ <property name="testWhileIdle" value="${advancedlogging.dbcp.testWhileIdle}" />
+ <property name="validationQuery" value="${advancedlogging.dbcp.validationQuery}" />
+ </bean>
+
+ <bean id="statisticLogSessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
+ <property name="dataSource" ref="statisticLogDataSource"/>
+ <property name="packagesToScan" value="at.gv.egovernment.moa.id.commons.db.dao.statistic" />
+ <property name="hibernateProperties">
+
+ <props>
+ <prop key="hibernate.dialect">${advancedlogging.hibernate.dialect}</prop>
+ <prop key="hibernate.show_sql">${advancedlogging.hibernate.show_sql}</prop>
+ <prop key="hibernate.hbm2ddl.auto">${advancedlogging.hibernate.hbm2ddl.auto}</prop>
+ <prop key="current_session_context_class">${advancedlogging.hibernate.current_session_context_class}</prop>
+ <prop key="hibernate.transaction.flush_before_completion">${advancedlogging.hibernate.transaction.flush_before_completion}</prop>
+ <prop key="hibernate.transaction.auto_close_session">${advancedlogging.hibernate.transaction.auto_close_session}</prop>
+ </props>
+ </property>
+ </bean>
+
+
+ <bean id="statisticLogDBUtils" class="at.gv.egovernment.moa.id.commons.db.StatisticLogDBUtils">
+ </bean>
+
+ <bean name="statisticLogTransactionManager" id="statisticLogTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
+ <property name="entityManagerFactory" ref="statistic" />
+ </bean>
+
+ <bean id="statisticJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
+ <property name="showSql" value="${advancedlogging.hibernate.show_sql}" />
+ <property name="generateDdl" value="${advancedlogging.jpaVendorAdapter.generateDdl}" />
+ <property name="databasePlatform" value="${advancedlogging.hibernate.dialect}" />
+ </bean>
+
+ <bean name="statistic" id="statistic" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
+ <property name="dataSource" ref="statisticLogDataSource" />
+ <property name="jpaVendorAdapter" ref="statisticJpaVendorAdapter" />
+ <property name="packagesToScan" value="at.gv.egovernment.moa.id.commons.db.dao.statistic" />
+ <property name="persistenceUnitName" value="statistic" />
+ </bean>
+
+
+
+</beans> \ No newline at end of file
diff --git a/id/server/moa-id-spring-initializer/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthSpringInitializer.java b/id/server/moa-id-spring-initializer/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthSpringInitializer.java
index 327d659ec..3a53d081d 100644
--- a/id/server/moa-id-spring-initializer/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthSpringInitializer.java
+++ b/id/server/moa-id-spring-initializer/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthSpringInitializer.java
@@ -7,6 +7,8 @@ import javax.servlet.ServletRegistration;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.WebApplicationInitializer;
@@ -18,6 +20,7 @@ import org.springframework.web.servlet.DispatcherServlet;
import at.gv.egiz.components.spring.api.SpringLoader;
import at.gv.egovernment.moa.id.commons.utils.MOAIDMessageProvider;
+import at.gv.egovernment.moa.id.config.auth.PropertyBasedAuthConfigurationProvider;
import at.gv.egovernment.moa.logging.Logger;
/**
@@ -50,16 +53,34 @@ public class MOAIDAuthSpringInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
try {
+ Logger.info("=============== Loading Config Root Context! ===============");
+ ApplicationContext cfgRootContext =
+ new ClassPathXmlApplicationContext(new String[] {
+ "/moaid.configuration.beans.xml",
+ "/configuration.beans.xml"});
+
+
Logger.info("=============== Loading Root Context! ===============");
GenericWebApplicationContext rootContext = new GenericWebApplicationContext();
rootContext.setServletContext(servletContext);
+ rootContext.setParent(cfgRootContext);
+ PropertyBasedAuthConfigurationProvider moaidconfig = (PropertyBasedAuthConfigurationProvider) cfgRootContext.getBean("moaidauthconfig");
+ String[] springProfiles = moaidconfig.getActiveProfiles();
+
+
Logger.info("=============== Setting active profiles! ===============");
if (this.activeProfiles != null) {
for (String profile : this.activeProfiles) {
rootContext.getEnvironment().addActiveProfile(profile);
}
}
+
+ if (springProfiles != null) {
+ for (String profile : springProfiles) {
+ rootContext.getEnvironment().addActiveProfile(profile);
+ }
+ }
Logger.info("=============== Loading Local Contexts! ===============");
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(
@@ -76,7 +97,7 @@ public class MOAIDAuthSpringInitializer implements WebApplicationInitializer {
// logger.debug("Beans after logAMQP in {}", rootContext);
// dumpBeanDefinitions(rootContext);
-
+
Logger.info("=============== Loading SPI Context! ===============");
// logger.debug("Startup with context {}", rootContext);
if (rootContext instanceof BeanDefinitionRegistry) {
@@ -142,16 +163,16 @@ public class MOAIDAuthSpringInitializer implements WebApplicationInitializer {
}
private void dumpBeanDefinitions(GenericApplicationContext context) {
- Logger.trace("Registered Bean in context " + context.toString());
+ Logger.debug("Registered Bean in context " + context.toString());
String[] registeredBeans = context.getBeanDefinitionNames();
for (String registeredBean : registeredBeans) {
BeanDefinition beanDefinition = context
.getBeanDefinition(registeredBean);
- Logger.trace(registeredBean + " -> " + beanDefinition.getBeanClassName());
+ Logger.debug(registeredBean + " -> " + beanDefinition.getBeanClassName());
}
- Logger.trace("Registered Bean in context --"+ context);
+ Logger.debug("Registered Bean in context --"+ context);
}
}
diff --git a/id/server/moa-id-spring-initializer/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthSpringResourceProvider.java b/id/server/moa-id-spring-initializer/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthSpringResourceProvider.java
index bfa1baddd..565e1cccd 100644
--- a/id/server/moa-id-spring-initializer/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthSpringResourceProvider.java
+++ b/id/server/moa-id-spring-initializer/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthSpringResourceProvider.java
@@ -38,13 +38,12 @@ public class MOAIDAuthSpringResourceProvider implements SpringResourceProvider {
*/
@Override
public Resource[] getResourcesToLoad() {
- ClassPathResource moaidauthConfig = new ClassPathResource("/moaid.configuration.beans.xml", MOAIDAuthInitializer.class);
- ClassPathResource configurationDBConfig = new ClassPathResource("/configuration.beans.xml", MOAIDAuthInitializer.class);
ClassPathResource moaIdAuthBeans = new ClassPathResource("/moaid.authentication.beans.xml", MOAIDAuthInitializer.class);
ClassPathResource moaSessionCommonBeans = new ClassPathResource("/session.common.beans.xml", MOAIDAuthInitializer.class);
ClassPathResource moaSessionDBBeans = new ClassPathResource("/session.db.beans.xml", MOAIDAuthInitializer.class);
ClassPathResource moaSessionRedisBeans = new ClassPathResource("/session.redis.beans.xml", MOAIDAuthInitializer.class);
- return new Resource[] {configurationDBConfig, moaidauthConfig, moaIdAuthBeans, moaSessionDBBeans, moaSessionRedisBeans, moaSessionCommonBeans};
+ ClassPathResource configurationStatisticLog = new ClassPathResource("/statistic.logging.beans.xml", MOAIDAuthInitializer.class);
+ return new Resource[] {configurationStatisticLog, moaIdAuthBeans, moaSessionDBBeans, moaSessionRedisBeans, moaSessionCommonBeans};
}
diff --git a/id/server/modules/moa-id-module-openID/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/json/OAuth20SignatureUtil.java b/id/server/modules/moa-id-module-openID/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/json/OAuth20SignatureUtil.java
index 9f20ee956..cd7b8312d 100644
--- a/id/server/modules/moa-id-module-openID/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/json/OAuth20SignatureUtil.java
+++ b/id/server/modules/moa-id-module-openID/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/json/OAuth20SignatureUtil.java
@@ -54,7 +54,7 @@ public final class OAuth20SignatureUtil {
} else if (key instanceof ECPrivateKey) {
Logger.debug("OAuth - going to uses SHA256withECDSA signature");
return OAuthSignatureAlgorithm.ECDSA256;
- } else if (key instanceof iaik.security.ecc.ecdsa.ECPrivateKey) {
+ } else if (key instanceof iaik.security.ec.common.ECPrivateKey) {
Logger.debug("OAuth - going to uses SHA256withECDSA signature with iaik");
return OAuthSignatureAlgorithm.ECDSA256_IAKIK;
} else {
@@ -69,7 +69,7 @@ public final class OAuth20SignatureUtil {
} else if (key instanceof ECPublicKey) {
Logger.debug("OAuth - going to uses SHA256withECDSA signature");
return OAuthSignatureAlgorithm.ECDSA256;
- } else if (key instanceof iaik.security.ecc.ecdsa.ECPublicKey) {
+ } else if (key instanceof iaik.security.ec.common.ECPublicKey) {
Logger.debug("OAuth - going to uses SHA256withECDSA signature with iaik");
return OAuthSignatureAlgorithm.ECDSA256_IAKIK;
} else {
diff --git a/id/server/modules/moa-id-module-openID/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/CertTest.java b/id/server/modules/moa-id-module-openID/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/CertTest.java
index 812591293..35bbac6e7 100644
--- a/id/server/modules/moa-id-module-openID/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/CertTest.java
+++ b/id/server/modules/moa-id-module-openID/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/CertTest.java
@@ -33,7 +33,7 @@ import org.testng.annotations.Test;
import at.gv.egovernment.moa.id.protocols.oauth20.json.OAuth20SHA256Signer;
import at.gv.egovernment.moa.id.protocols.oauth20.json.OAuth20SHA256Verifier;
import at.gv.egovernment.moa.util.KeyStoreUtils;
-import iaik.security.ec.provider.ECCelerate;
+
import net.oauth.jsontoken.crypto.Signer;
import net.oauth.jsontoken.crypto.Verifier;
@@ -119,8 +119,8 @@ public class CertTest {
}
@Test
- public void testECDSA() throws Exception {
- ECCelerate.addAsProvider();
+ public void testECDSA() throws Exception {
+ //ECCProvider.addAsProvider();
// Security.addProvider(new ECCProvider());
BasicX509Credential credential = this.getCredentials(this.ecdsaKeyStorePath);
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 b6d217e4c..8ae1850ce 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
@@ -41,8 +41,10 @@ import at.gv.egovernment.moa.util.MiscUtil;
public class DatabaseTestModule implements TestModuleInterface{
private MOASessionDBUtils dbUtils;
+ private StatisticLogDBUtils statLogUtils;
- public DatabaseTestModule(MOASessionDBUtils dbUtils){
+ public DatabaseTestModule(MOASessionDBUtils dbUtils, StatisticLogDBUtils statLogUtils){
+ this.statLogUtils = statLogUtils;
this.dbUtils = dbUtils;
}
@@ -112,7 +114,7 @@ public class DatabaseTestModule implements TestModuleInterface{
Date expioredate = new Date(new Date().getTime() - 120);
try {
- Session session = StatisticLogDBUtils.getCurrentSession();
+ Session session = statLogUtils.getCurrentSession();
List<StatisticLog> results;
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 b5ccd73f6..4224fae59 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
@@ -32,12 +32,14 @@ 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.commons.db.MOASessionDBUtils;
+import at.gv.egovernment.moa.id.commons.db.StatisticLogDBUtils;
import at.gv.egovernment.moa.logging.Logger;
import at.gv.egovernment.moa.util.FileUtils;
public class TestManager{
@Autowired private MOASessionDBUtils moaSessionDBUtils;
+ @Autowired(required=false) private StatisticLogDBUtils statisticLogDBUtils = null;
@Autowired private AuthConfiguration authConfig;
private Map<String, TestModuleInterface> tests = new HashMap<String, TestModuleInterface>();
@@ -92,7 +94,7 @@ public class TestManager{
Logger.debug("Start initializing MOA-ID-Auth TestManager");
//add Database test
- DatabaseTestModule test1 = new DatabaseTestModule(this.moaSessionDBUtils);
+ DatabaseTestModule test1 = new DatabaseTestModule(this.moaSessionDBUtils, this.statisticLogDBUtils);
tests.put(test1.getName(), test1);
//add IdentityLink verification test
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
index 41fab4444..6c195e7d7 100644
--- 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
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
+<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"