aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib')
-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
10 files changed, 165 insertions, 47 deletions
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"/>