blob: edc741d388f50ed28c033e4eb2fa135b7db33786 [file] [log] [blame]
Michael Hanlca740d72015-06-16 10:04:58 +02001<?xml version="1.0" encoding="UTF-8"?>
2<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Michael Hanlf8fcc7a2016-06-03 17:41:07 +02003 xmlns:p="http://www.springframework.org/schema/p"
Michael Hanlca740d72015-06-16 10:04:58 +02004 xmlns:util="http://www.springframework.org/schema/util"
Michael Hanl72c7b832015-09-03 08:42:15 +02005 xmlns:aop="http://www.springframework.org/schema/aop"
6 xmlns:tx="http://www.springframework.org/schema/tx"
Michael Hanlca740d72015-06-16 10:04:58 +02007 xmlns="http://www.springframework.org/schema/beans"
Michael Hanlf8fcc7a2016-06-03 17:41:07 +02008 xmlns:cache="http://www.springframework.org/schema/cache"
Michael Hanlca740d72015-06-16 10:04:58 +02009 xsi:schemaLocation="http://www.springframework.org/schema/beans
10 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
Michael Hanl72c7b832015-09-03 08:42:15 +020011 http://www.springframework.org/schema/tx
12 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
13 http://www.springframework.org/schema/aop
14 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
Michael Hanle4fc7752016-02-17 11:41:18 +010015
16
Michael Hanlca740d72015-06-16 10:04:58 +020017 http://www.springframework.org/schema/util
18 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
19
Michael Hanld6eadd52015-11-11 18:30:33 +010020 <bean id="props"
21 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
22 <property name="ignoreResourceNotFound" value="true"/>
23 <property name="locations">
24 <array>
25 <value>classpath:kustvakt.conf</value>
Michael Hanl38399df2015-11-13 16:32:19 +010026 <value>file:./kustvakt.conf</value>
Michael Hanld6eadd52015-11-11 18:30:33 +010027 </array>
28 </property>
29 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +020030
Michael Hanl72c7b832015-09-03 08:42:15 +020031 <bean id="jdbc_props"
32 class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
Michael Hanld6eadd52015-11-11 18:30:33 +010033 <property name="ignoreResourceNotFound" value="true"/>
34 <property name="locations">
35 <array>
36 <value>classpath:jdbc.properties</value>
Michael Hanl38399df2015-11-13 16:32:19 +010037 <value>file:./jdbc.properties</value>
Michael Hanld6eadd52015-11-11 18:30:33 +010038 </array>
39 </property>
Michael Hanlca740d72015-06-16 10:04:58 +020040 </bean>
41
Michael Hanlf8fcc7a2016-06-03 17:41:07 +020042 <bean id='cacheManager'
43 class='org.springframework.cache.ehcache.EhCacheCacheManager'
44 p:cacheManager-ref='ehcache'/>
Michael Hanl72c7b832015-09-03 08:42:15 +020045
Michael Hanlf8fcc7a2016-06-03 17:41:07 +020046 <bean id='ehcache'
47 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
48 p:configLocation='classpath:ehcache.xml'
49 p:shared='true'/>
Michael Hanl72c7b832015-09-03 08:42:15 +020050
51 <!-- props are injected from default-config.xml -->
Michael Hanl1e18cb42015-08-06 20:57:35 +020052 <bean id="kustvakt_config"
Michael Hanlf21773f2015-10-16 23:02:31 +020053 class="de.ids_mannheim.korap.config.KustvaktConfiguration">
Michael Hanlca740d72015-06-16 10:04:58 +020054 <property name="properties" ref="props"/>
55 </bean>
56
Michael Hanlf0785322015-11-13 16:14:45 +010057 <!--class="org.apache.commons.dbcp2.BasicDataSource"-->
Michael Hanl2760cc42015-11-16 19:30:01 +010058 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
margaretha0f5a0e62017-03-21 15:33:11 +010059 <bean id="dataSource"
60 class="org.apache.commons.dbcp2.BasicDataSource"
Michael Hanl72c7b832015-09-03 08:42:15 +020061 lazy-init="true">
62 <property name="driverClassName" value="${jdbc.driverClassName}"/>
63 <property name="url" value="${jdbc.url}"/>
64 <property name="username" value="${jdbc.username}"/>
65 <property name="password" value="${jdbc.password}"/>
66 <!-- relevant for single connection datasource and sqlite -->
margaretha0f5a0e62017-03-21 15:33:11 +010067 <!-- <property name="suppressClose">
Michael Hanl19390652016-01-16 11:01:24 +010068 <value>true</value>
margaretha0f5a0e62017-03-21 15:33:11 +010069 </property> -->
Michael Hanl19390652016-01-16 11:01:24 +010070 <!--<property name="initialSize" value="2"/>-->
margaretha0f5a0e62017-03-21 15:33:11 +010071 <property name="maxTotal" value="4"/>
72 <property name="maxIdle" value="2"/>
73 <property name="minIdle" value="1"/>
74 <property name="maxWaitMillis" value="15000"/>
Michael Hanl19390652016-01-16 11:01:24 +010075 <!--<property name="poolPreparedStatements" value="true"/>-->
Michael Hanl72c7b832015-09-03 08:42:15 +020076 </bean>
margarethabcda2f72017-04-27 10:17:58 +020077
margaretha0b418302017-04-27 10:25:38 +020078 <bean id="sqliteDataSource"
margarethabcda2f72017-04-27 10:17:58 +020079 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
80 lazy-init="true">
81 <property name="driverClassName" value="${jdbc.driverClassName}"/>
82 <property name="url" value="${jdbc.url}"/>
83 <property name="username" value="${jdbc.username}"/>
84 <property name="password" value="${jdbc.password}"/>
85 <!-- relevant for single connection datasource and sqlite -->
86 <!-- <property name="suppressClose">
87 <value>true</value>
88 </property> -->
89 <!--<property name="initialSize" value="2"/>-->
90 <!--<property name="poolPreparedStatements" value="true"/>-->
91 </bean>
Michael Hanl72c7b832015-09-03 08:42:15 +020092
93 <!-- to configure database for sqlite, mysql, etc. migrations -->
94 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
95 <property name="baselineOnMigrate" value="false"/>
96 <property name="locations"
Michael Hanldaf86602016-05-12 14:31:52 +020097 value="${jdbc.schemaPath}"/>
margaretha0b418302017-04-27 10:25:38 +020098 <property name="dataSource" ref="sqliteDataSource"/>
Michael Hanl72c7b832015-09-03 08:42:15 +020099 </bean>
100
101 <bean id="kustvakt_db"
Michael Hanl482f30d2015-09-25 12:39:46 +0200102 class="de.ids_mannheim.korap.handlers.JDBCClient">
Michael Hanl72c7b832015-09-03 08:42:15 +0200103 <constructor-arg index="0" ref="dataSource"/>
104 <!-- deprecated property -->
105 <property name="database" value="${jdbc.database}"/>
106 </bean>
107
108 <bean id="kustvakt_auditing"
Michael Hanl482f30d2015-09-25 12:39:46 +0200109 class="de.ids_mannheim.korap.handlers.JDBCAuditing">
Michael Hanl72c7b832015-09-03 08:42:15 +0200110 <constructor-arg ref="kustvakt_db"/>
111 </bean>
112
113 <bean id="kustvakt_userdb"
Michael Hanl482f30d2015-09-25 12:39:46 +0200114 class="de.ids_mannheim.korap.handlers.EntityDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200115 <constructor-arg ref="kustvakt_db"/>
116 </bean>
margaretha62055f72017-04-11 19:17:43 +0200117
118 <bean id="kustvakt_admindb"
119 class="de.ids_mannheim.korap.handlers.AdminDao">
120 <constructor-arg ref="kustvakt_db"/>
121 </bean>
122
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200123 <bean id="resource_provider"
Michael Hanl482f30d2015-09-25 12:39:46 +0200124 class="de.ids_mannheim.korap.handlers.ResourceDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200125 <constructor-arg ref="kustvakt_db"/>
126 </bean>
127
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200128 <bean id="document_provider"
129 class="de.ids_mannheim.korap.handlers.DocumentDao">
130 <constructor-arg ref="kustvakt_db"/>
131 </bean>
132
Michael Hanl72c7b832015-09-03 08:42:15 +0200133 <bean id="kustvakt_policies"
Michael Hanlf21773f2015-10-16 23:02:31 +0200134 class="de.ids_mannheim.korap.security.ac.PolicyDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200135 <constructor-arg ref="kustvakt_db"/>
136 </bean>
137
Michael Hanl1e18cb42015-08-06 20:57:35 +0200138 <bean name="kustvakt_encryption"
Michael Hanlf21773f2015-10-16 23:02:31 +0200139 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
Michael Hanl72c7b832015-09-03 08:42:15 +0200140 <constructor-arg ref="kustvakt_config"/>
141 </bean>
142
Michael Hanl72c7b832015-09-03 08:42:15 +0200143 <!-- authentication providers to use -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200144 <bean id="api_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200145 class="de.ids_mannheim.korap.security.auth.APIAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200146 <constructor-arg
147 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
148 ref="kustvakt_config"/>
149 </bean>
150
151 <bean id="openid_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200152 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200153 <constructor-arg
154 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
155 ref="kustvakt_config"/>
156 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200157 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
Michael Hanl72c7b832015-09-03 08:42:15 +0200158 ref="kustvakt_db"/>
159 </bean>
160
161 <bean id="basic_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200162 class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200163
164
165 <bean id="session_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200166 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200167 <constructor-arg
168 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
169 ref="kustvakt_config"/>
170 <constructor-arg
171 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
172 ref="kustvakt_encryption"/>
173 </bean>
174
Michael Hanldaf86602016-05-12 14:31:52 +0200175 <util:list id="kustvakt_authproviders"
Michael Hanl72c7b832015-09-03 08:42:15 +0200176 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
177 <ref bean="basic_auth"/>
178 <ref bean="session_auth"/>
179 <ref bean="api_auth"/>
180 <ref bean="openid_auth"/>
181 </util:list>
182
Michael Hanldaf86602016-05-12 14:31:52 +0200183
184 <bean id="userdata_details"
185 class="de.ids_mannheim.korap.handlers.UserDetailsDao">
186 <constructor-arg
Michael Hanldaf86602016-05-12 14:31:52 +0200187 ref="kustvakt_db"/>
188 </bean>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200189
Michael Hanldaf86602016-05-12 14:31:52 +0200190 <bean id="userdata_settings"
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200191 class="de.ids_mannheim.korap.handlers.UserSettingsDao">
Michael Hanldaf86602016-05-12 14:31:52 +0200192 <constructor-arg
Michael Hanldaf86602016-05-12 14:31:52 +0200193 ref="kustvakt_db"/>
194 </bean>
195
196 <util:list id="kustvakt_userdata"
197 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
198 <ref bean="userdata_details"/>
199 <ref bean="userdata_settings"/>
200 </util:list>
201
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200202
203 <util:list id="kustvakt_resources"
204 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
205 <ref bean="document_provider"/>
206 <ref bean="resource_provider"/>
207 </util:list>
208
Michael Hanl72c7b832015-09-03 08:42:15 +0200209 <!-- specify type for constructor argument -->
210 <bean id="kustvakt_authenticationmanager"
Michael Hanlf21773f2015-10-16 23:02:31 +0200211 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
Michael Hanl72c7b832015-09-03 08:42:15 +0200212 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200213 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface"
Michael Hanl72c7b832015-09-03 08:42:15 +0200214 ref="kustvakt_userdb"/>
margaretha62055f72017-04-11 19:17:43 +0200215 <constructor-arg
216 type="de.ids_mannheim.korap.interfaces.db.AdminHandlerIface"
217 ref="kustvakt_admindb"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200218 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
219 ref="kustvakt_encryption"/>
220 <constructor-arg ref="kustvakt_config"/>
Michael Hanlf21773f2015-10-16 23:02:31 +0200221 <constructor-arg
222 type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
223 ref="kustvakt_auditing"/>
Michael Hanldaf86602016-05-12 14:31:52 +0200224 <constructor-arg ref="kustvakt_userdata"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200225 <!-- inject authentication providers to use -->
Michael Hanldaf86602016-05-12 14:31:52 +0200226 <property name="providers" ref="kustvakt_authproviders"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200227 </bean>
228
Michael Hanl72c7b832015-09-03 08:42:15 +0200229 <!-- todo: if db interfaces not loaded via spring, does transaction even work then? -->
230 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
231 <tx:advice id="txAdvice" transaction-manager="txManager">
232 <!-- the transactional semantics... -->
233 <tx:attributes>
234 <!-- all methods starting with 'get' are read-only -->
235 <tx:method name="get*" read-only="true"
236 rollback-for="KorAPException"/>
237 <!-- other methods use the default transaction settings (see below) -->
238 <tx:method name="*" rollback-for="KorAPException"/>
239 </tx:attributes>
240 </tx:advice>
241
242 <!-- ensure that the above transactional advice runs for any execution
243 of an operation defined by the service interface -->
244 <aop:config>
245 <aop:pointcut id="service"
Michael Hanlf21773f2015-10-16 23:02:31 +0200246 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200247 <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
248 </aop:config>
249
250 <!-- similarly, don't forget the PlatformTransactionManager -->
251 <bean id="txManager"
252 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
253 <property name="dataSource" ref="dataSource"/>
Michael Hanlca740d72015-06-16 10:04:58 +0200254 </bean>
255</beans>