blob: 32ebb35ff39a1e088a34b4f6801b9281aecf125b [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"
margaretha0e8f4e72018-04-05 14:11:52 +02003 xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
4 xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
5 xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
margaretha543f2002017-07-14 00:27:15 +02006 xmlns:cache="http://www.springframework.org/schema/cache"
7 xsi:schemaLocation="http://www.springframework.org/schema/beans
8 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
9 http://www.springframework.org/schema/tx
10 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
11 http://www.springframework.org/schema/aop
12 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
13 http://www.springframework.org/schema/context
14 http://www.springframework.org/schema/context/spring-context-4.0.xsd
15 http://www.springframework.org/schema/util
16 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
17
18 <context:component-scan base-package="de.ids_mannheim.korap" />
19 <context:annotation-config />
20
margaretha0e8f4e72018-04-05 14:11:52 +020021 <!-- <bean id="test" class="de.ids_mannheim.korap.web.Test"> <property name="config"
22 ref="kustvakt_config" /> </bean> -->
margarethaade7d4a2017-07-20 19:53:35 +020023
margaretha543f2002017-07-14 00:27:15 +020024 <bean id="props"
25 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
26 <property name="ignoreResourceNotFound" value="true" />
27 <property name="locations">
28 <array>
29 <value>classpath:kustvakt.conf</value>
30 <value>file:./kustvakt.conf</value>
31 </array>
32 </property>
33 </bean>
34
35 <bean id="placeholders"
36 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
37 <property name="ignoreResourceNotFound" value="true" />
38 <property name="locations">
39 <array>
margarethaaecee1b2018-02-20 14:44:21 +010040 <value>classpath:properties/jdbc.properties</value>
margarethaea68a0a2017-09-21 03:09:49 +020041 <value>file:./jdbc.properties</value>
margarethaaecee1b2018-02-20 14:44:21 +010042 <value>classpath:properties/mail.properties</value>
43 <value>file:./mail.properties</value>
44 <value>classpath:properties/hibernate.properties</value>
margaretha0e8f4e72018-04-05 14:11:52 +020045
margarethaade7d4a2017-07-20 19:53:35 +020046 <value>classpath:kustvakt.conf</value>
margaretha14503cd2017-09-08 15:35:24 +020047 <value>file:./kustvakt.conf</value>
margaretha543f2002017-07-14 00:27:15 +020048 </array>
49 </property>
50 </bean>
51
52 <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
53 p:cacheManager-ref='ehcache' />
54
55 <bean id='ehcache'
56 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
57 p:configLocation='classpath:ehcache.xml' p:shared='true' />
58
margaretha543f2002017-07-14 00:27:15 +020059 <!--class="org.apache.commons.dbcp2.BasicDataSource" -->
60 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
61 <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
62 lazy-init="true">
63 <property name="driverClassName" value="${jdbc.driverClassName}" />
64 <property name="url" value="${jdbc.url}" />
65 <property name="username" value="${jdbc.username}" />
66 <property name="password" value="${jdbc.password}" />
67 <!-- relevant for single connection datasource and sqlite -->
68 <!-- <property name="suppressClose"> <value>true</value> </property> -->
69 <!--<property name="initialSize" value="2"/> -->
70 <property name="maxTotal" value="4" />
71 <property name="maxIdle" value="2" />
72 <property name="minIdle" value="1" />
73 <property name="maxWaitMillis" value="15000" />
74 <!--<property name="poolPreparedStatements" value="true"/> -->
75 </bean>
76
77 <bean id="sqliteDataSource"
78 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
79 lazy-init="true">
80 <property name="driverClassName" value="${jdbc.driverClassName}" />
81 <property name="url" value="${jdbc.url}" />
82 <property name="username" value="${jdbc.username}" />
83 <property name="password" value="${jdbc.password}" />
margarethae6c711b2018-02-06 21:55:04 +010084 <property name="connectionProperties">
margaretha0e8f4e72018-04-05 14:11:52 +020085 <props>
86 <prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop>
87 </props>
88 </property>
89
margaretha543f2002017-07-14 00:27:15 +020090 <!-- relevant for single connection datasource and sqlite -->
91 <property name="suppressClose">
92 <value>true</value>
93 </property>
94 <!--<property name="initialSize" value="2"/> -->
95 <!--<property name="poolPreparedStatements" value="true"/> -->
96 </bean>
97
98 <!-- to configure database for sqlite, mysql, etc. migrations -->
99 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
margarethaf6d5a822017-10-19 19:51:20 +0200100 <property name="baselineOnMigrate" value="true" />
margarethaecbe72d2017-07-26 17:13:32 +0200101 <!-- <property name="validateOnMigrate" value="false" /> -->
102 <!-- <property name="cleanOnValidationError" value="true" /> -->
margaretha543f2002017-07-14 00:27:15 +0200103 <property name="locations" value="${jdbc.schemaPath}" />
margaretha894a7d72017-11-08 19:24:20 +0100104 <!-- <property name="dataSource" ref="dataSource" /> -->
105 <property name="dataSource" ref="sqliteDataSource" />
margaretha543f2002017-07-14 00:27:15 +0200106 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200107
108
margaretha543f2002017-07-14 00:27:15 +0200109 <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
110 <constructor-arg index="0" ref="dataSource" />
111 <!-- deprecated property -->
112 <property name="database" value="${jdbc.database}" />
113 </bean>
114
115 <bean id="entityManagerFactory"
116 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
margaretha894a7d72017-11-08 19:24:20 +0100117 <!-- <property name="dataSource" ref="dataSource" /> -->
118 <property name="dataSource" ref="sqliteDataSource" />
margaretha0e8f4e72018-04-05 14:11:52 +0200119
margarethaa452c5e2018-04-25 22:48:09 +0200120 <property name="packagesToScan">
121 <array>
122 <value>de.ids_mannheim.korap.entity</value>
123 <value>de.ids_mannheim.korap.oauth2.entity</value>
124 </array>
125 </property>
margaretha543f2002017-07-14 00:27:15 +0200126 <property name="jpaVendorAdapter">
127 <bean id="jpaVendorAdapter"
128 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
129 <property name="databasePlatform" value="${hibernate.dialect}" />
130 </bean>
131 </property>
132 <property name="jpaProperties">
133 <props>
134 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
135 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
136 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
137 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
138 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
139 </prop>
140 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
141 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
142 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
143 </props>
144 </property>
145 </bean>
146
147 <tx:annotation-driven proxy-target-class="true"
148 transaction-manager="transactionManager" />
margaretha0e8f4e72018-04-05 14:11:52 +0200149
margaretha543f2002017-07-14 00:27:15 +0200150 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
151 <property name="entityManagerFactory" ref="entityManagerFactory" />
152 </bean>
153
154 <bean id="transactionTemplate"
155 class="org.springframework.transaction.support.TransactionTemplate">
156 <constructor-arg ref="transactionManager" />
157 </bean>
158
margarethaade7d4a2017-07-20 19:53:35 +0200159 <!-- Data access objects -->
margaretha0e8f4e72018-04-05 14:11:52 +0200160 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao" />
margarethab4ce6602018-04-26 20:23:57 +0200161 <bean id="accessScopeDao" class="de.ids_mannheim.korap.oauth2.dao.AccessScopeDao" />
margaretha064eb6f2018-07-10 18:33:01 +0200162 <bean id="authorizationDao" class="de.ids_mannheim.korap.oauth2.dao.AuthorizationCacheDao" />
margarethab4ce6602018-04-26 20:23:57 +0200163
164 <!-- props are injected from default-config.xml -->
165 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.FullConfiguration">
166 <constructor-arg name="properties" ref="props" />
167 </bean>
168
169 <bean id="initializator" class="de.ids_mannheim.korap.config.Initializator"
170 init-method="init">
margarethab4ce6602018-04-26 20:23:57 +0200171 </bean>
margarethaade7d4a2017-07-20 19:53:35 +0200172
173 <!-- Krill -->
174 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
margaretha0e8f4e72018-04-05 14:11:52 +0200175 <constructor-arg value="${krill.indexDir}" />
margaretha543f2002017-07-14 00:27:15 +0200176 </bean>
177
margaretha31a9f522018-04-03 20:40:45 +0200178 <!-- URLValidator -->
margarethae4034a82018-07-02 14:46:59 +0200179 <bean id="redirectURIValidator" class="org.apache.commons.validator.routines.UrlValidator">
180 <constructor-arg value="http,https" index="0" />
181 <constructor-arg index="1" type="long">
182 <util:constant
183 static-field="org.apache.commons.validator.routines.UrlValidator.NO_FRAGMENTS" />
184 </constructor-arg>
margarethaa0486272018-04-12 19:59:31 +0200185 </bean>
margarethad7cab212018-07-02 19:01:43 +0200186 <bean id="urlValidator" class="org.apache.commons.validator.routines.UrlValidator">
187 <constructor-arg value="http,https" />
188 </bean>
189
margaretha0e8f4e72018-04-05 14:11:52 +0200190
margaretha56e8e552017-12-05 16:31:21 +0100191 <bean id="kustvakt_rewrite" class="de.ids_mannheim.korap.rewrite.FullRewriteHandler">
192 <constructor-arg ref="kustvakt_config" />
193 </bean>
194
margaretha543f2002017-07-14 00:27:15 +0200195 <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
196 <constructor-arg ref="kustvakt_db" />
197 </bean>
198
margarethad7cab212018-07-02 19:01:43 +0200199 <bean id="kustvaktResponseHandler" class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha0e8f4e72018-04-05 14:11:52 +0200200 <constructor-arg index="0" name="iface" ref="kustvakt_auditing" />
201 </bean>
margarethaa452c5e2018-04-25 22:48:09 +0200202
margarethafb027f92018-04-23 20:00:13 +0200203 <!-- OAuth -->
204 <bean id="oauth2ResponseHandler" class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha05122312018-04-16 15:01:34 +0200205 <constructor-arg index="0" name="iface" ref="kustvakt_auditing" />
206 </bean>
margarethaa452c5e2018-04-25 22:48:09 +0200207
margarethafb027f92018-04-23 20:00:13 +0200208 <bean id="mdGenerator" class="org.apache.oltu.oauth2.as.issuer.MD5Generator">
209 </bean>
210 <bean id="oauthIssuer" class="org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl">
211 <constructor-arg index="0" ref="mdGenerator" />
212 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200213
margaretha543f2002017-07-14 00:27:15 +0200214 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
215 <constructor-arg ref="kustvakt_db" />
216 </bean>
217
margaretha543f2002017-07-14 00:27:15 +0200218 <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
219 <constructor-arg ref="kustvakt_db" />
220 </bean>
221
margarethaa452c5e2018-04-25 22:48:09 +0200222 <bean name="kustvakt_encryption" class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha543f2002017-07-14 00:27:15 +0200223 <constructor-arg ref="kustvakt_config" />
224 </bean>
225
226 <!-- authentication providers to use -->
margaretha0e8f4e72018-04-05 14:11:52 +0200227 <!-- <bean id="api_auth" class="de.ids_mannheim.korap.authentication.APIAuthentication">
228 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
229 ref="kustvakt_config" /> </bean> -->
230
margaretha4de41192017-11-15 11:47:11 +0100231 <bean id="ldap_auth" class="de.ids_mannheim.korap.authentication.LdapAuth3">
margaretha543f2002017-07-14 00:27:15 +0200232 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
233 ref="kustvakt_config" />
234 </bean>
235
236 <bean id="openid_auth"
margaretha139d0f72017-11-14 18:56:22 +0100237 class="de.ids_mannheim.korap.authentication.OpenIDconnectAuthentication">
margaretha543f2002017-07-14 00:27:15 +0200238 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
239 ref="kustvakt_config" />
240 <constructor-arg
241 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
242 </bean>
243
margaretha543f2002017-07-14 00:27:15 +0200244 <bean id="session_auth"
margaretha139d0f72017-11-14 18:56:22 +0100245 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
margaretha543f2002017-07-14 00:27:15 +0200246 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
247 ref="kustvakt_config" />
248 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
249 ref="kustvakt_encryption" />
250 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +0200251
margarethacf306d32018-05-30 19:45:35 +0200252 <bean id="oauth2_auth"
253 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
254
margaretha543f2002017-07-14 00:27:15 +0200255 <util:list id="kustvakt_authproviders"
256 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
margaretha4de41192017-11-15 11:47:11 +0100257 <ref bean="ldap_auth" />
margaretha543f2002017-07-14 00:27:15 +0200258 <ref bean="session_auth" />
margaretha4de41192017-11-15 11:47:11 +0100259 <!-- <ref bean="api_auth" /> -->
margaretha543f2002017-07-14 00:27:15 +0200260 <ref bean="openid_auth" />
margarethacf306d32018-05-30 19:45:35 +0200261 <ref bean="oauth2_auth" />
margaretha543f2002017-07-14 00:27:15 +0200262 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200263
264
margaretha543f2002017-07-14 00:27:15 +0200265 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
266 <constructor-arg ref="kustvakt_db" />
267 </bean>
Michael Hanl72c7b832015-09-03 08:42:15 +0200268
margaretha543f2002017-07-14 00:27:15 +0200269 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
270 <constructor-arg ref="kustvakt_db" />
271 </bean>
272
273 <util:list id="kustvakt_userdata"
274 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
275 <ref bean="userdata_details" />
276 <ref bean="userdata_settings" />
277 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200278
Michael Hanldaf86602016-05-12 14:31:52 +0200279
margaretha543f2002017-07-14 00:27:15 +0200280 <util:list id="kustvakt_resources"
281 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
282 <ref bean="document_provider" />
margaretha543f2002017-07-14 00:27:15 +0200283 </util:list>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200284
margaretha543f2002017-07-14 00:27:15 +0200285 <!-- specify type for constructor argument -->
286 <bean id="kustvakt_authenticationmanager"
margaretha139d0f72017-11-14 18:56:22 +0100287 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha0e8f4e72018-04-05 14:11:52 +0200288 <constructor-arg type="de.ids_mannheim.korap.interfaces.EntityHandlerIface"
289 ref="kustvakt_userdb" />
margaretha543f2002017-07-14 00:27:15 +0200290 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
291 ref="kustvakt_encryption" />
292 <constructor-arg ref="kustvakt_config" />
293 <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
294 ref="kustvakt_auditing" />
295 <constructor-arg ref="kustvakt_userdata" />
296 <!-- inject authentication providers to use -->
297 <property name="providers" ref="kustvakt_authproviders" />
298 </bean>
Michael Hanldaf86602016-05-12 14:31:52 +0200299
margaretha543f2002017-07-14 00:27:15 +0200300 <!-- todo: if db interfaces not loaded via spring, does transaction even
301 work then? -->
302 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
303 bean below) -->
304 <tx:advice id="txAdvice" transaction-manager="txManager">
305 <!-- the transactional semantics... -->
306 <tx:attributes>
307 <!-- all methods starting with 'get' are read-only -->
308 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
309 <!-- other methods use the default transaction settings (see below) -->
310 <tx:method name="*" rollback-for="KorAPException" />
311 </tx:attributes>
312 </tx:advice>
Michael Hanldaf86602016-05-12 14:31:52 +0200313
margaretha543f2002017-07-14 00:27:15 +0200314 <!-- ensure that the above transactional advice runs for any execution of
315 an operation defined by the service interface -->
316 <aop:config>
317 <aop:pointcut id="service"
318 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
319 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
320 </aop:config>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200321
margaretha543f2002017-07-14 00:27:15 +0200322 <!-- similarly, don't forget the PlatformTransactionManager -->
323 <bean id="txManager"
324 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
margaretha894a7d72017-11-08 19:24:20 +0100325 <!-- <property name="dataSource" ref="dataSource" /> -->
326 <property name="dataSource" ref="sqliteDataSource" />
margaretha543f2002017-07-14 00:27:15 +0200327 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200328
margarethac9f1dfa2018-02-07 17:50:33 +0100329 <!-- mail -->
margaretha0e8f4e72018-04-05 14:11:52 +0200330 <bean id="authenticator" class="de.ids_mannheim.korap.service.MailAuthenticator">
331 <constructor-arg index="0" value="${mail.username}" />
332 <constructor-arg index="1" value="${mail.password}" />
margarethaaecee1b2018-02-20 14:44:21 +0100333 </bean>
334 <bean id="smtpSession" class="javax.mail.Session" factory-method="getInstance">
335 <constructor-arg index="0">
336 <props>
337 <prop key="mail.smtp.submitter">${mail.username}</prop>
338 <prop key="mail.smtp.auth">${mail.auth}</prop>
339 <prop key="mail.smtp.host">${mail.host}</prop>
340 <prop key="mail.smtp.port">${mail.port}</prop>
341 <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
342 <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
343 </props>
344 </constructor-arg>
margaretha0e8f4e72018-04-05 14:11:52 +0200345 <constructor-arg index="1" ref="authenticator" />
margarethac9f1dfa2018-02-07 17:50:33 +0100346 </bean>
347 <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
margarethaaecee1b2018-02-20 14:44:21 +0100348 <property name="username" value="${mail.username}" />
margaretha0e8f4e72018-04-05 14:11:52 +0200349 <property name="password" value="${mail.password}" />
margarethac9f1dfa2018-02-07 17:50:33 +0100350 <property name="session" ref="smtpSession" />
351 </bean>
352 <bean id="velocityEngine" class="org.apache.velocity.app.VelocityEngine">
353 <constructor-arg index="0">
354 <props>
355 <prop key="resource.loader">class</prop>
margaretha0e8f4e72018-04-05 14:11:52 +0200356 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
357 </prop>
margarethac9f1dfa2018-02-07 17:50:33 +0100358 </props>
359 </constructor-arg>
margarethaaecee1b2018-02-20 14:44:21 +0100360 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +0200361</beans>