blob: 3ad0aeb52e144536ca2b72a6ac657bb496ca160d [file] [log] [blame]
Michael Hanlbd852b82015-11-18 22:17:00 +01001<?xml version="1.0" encoding="UTF-8"?>
2<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xmlns:p="http://www.springframework.org/schema/p"
4 xmlns:util="http://www.springframework.org/schema/util"
5 xmlns:aop="http://www.springframework.org/schema/aop"
6 xmlns:tx="http://www.springframework.org/schema/tx"
7 xmlns="http://www.springframework.org/schema/beans"
8 xmlns:cache="http://www.springframework.org/schema/cache"
9 xsi:schemaLocation="http://www.springframework.org/schema/beans
10 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
11 http://www.springframework.org/schema/tx
12 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
13
14
15 http://www.springframework.org/schema/aop
16 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
17 http://www.springframework.org/schema/cache
18 http://www.springframework.org/schema/cache/spring-cache-4.0.xsd
19
20
21 http://www.springframework.org/schema/util
22 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
23
Michael Hanlbd852b82015-11-18 22:17:00 +010024 <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="jdbc_props"
36 class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
37 <property name="ignoreResourceNotFound" value="true"/>
38 <property name="locations">
39 <array>
40 <value>classpath:jdbc.properties</value>
Michael Hanldaf86602016-05-12 14:31:52 +020041 <value>file:./jdbc_tests.properties</value>
Michael Hanlbd852b82015-11-18 22:17:00 +010042 </array>
43 </property>
44 </bean>
45
46 <bean id='cacheManager'
47 class='org.springframework.cache.ehcache.EhCacheCacheManager'
48 p:cacheManager-ref='ehcache'/>
49
50 <bean id='ehcache'
51 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
52 p:configLocation='classpath:ehcache.xml'
53 p:shared='true'/>
54
55 <!-- props are injected from default-config.xml -->
56 <bean id="kustvakt_config"
57 class="de.ids_mannheim.korap.config.KustvaktConfiguration">
58 <property name="properties" ref="props"/>
59 </bean>
60
61 <!--class="org.apache.commons.dbcp2.BasicDataSource"-->
62 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
Michael Hanldaf86602016-05-12 14:31:52 +020063 <!-- org.springframework.jdbc.datasource.DriverManagerDataSource -->
Michael Hanlbd852b82015-11-18 22:17:00 +010064 <bean id="dataSource"
65 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
Michael Hanldaf86602016-05-12 14:31:52 +020066 lazy-init="false">
67 <property name="driverClassName" value="org.sqlite.JDBC"/>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +020068 <property name="url" value="jdbc:sqlite::memory:"/>
Michael Hanldaf86602016-05-12 14:31:52 +020069 <!--<property name="initialSize" value="1" />-->
70 <!--<property name="maxTotal" value="1" />-->
71 <!--<property name="maxIdle" value="1" />-->
72 <!--<property name="username" value="${jdbc.username}"/>-->
73 <!--<property name="password" value="${jdbc.password}"/>-->
Michael Hanlefb54c42016-01-16 18:54:03 +010074 <!-- relevant for single connection datasource and sqlite -->
Michael Hanlbd852b82015-11-18 22:17:00 +010075 <property name="suppressClose">
76 <value>true</value>
77 </property>
Michael Hanlefb54c42016-01-16 18:54:03 +010078 <!--<property name="initialSize" value="2"/>-->
79 <!--<property name="maxIdle" value="2"/>-->
80 <!--<property name="poolPreparedStatements" value="true"/>-->
Michael Hanlbd852b82015-11-18 22:17:00 +010081 </bean>
82
83 <!-- to configure database for sqlite, mysql, etc. migrations -->
84 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
85 <property name="baselineOnMigrate" value="false"/>
86 <property name="locations"
Michael Hanldaf86602016-05-12 14:31:52 +020087 value="classpath:db.sqlite"/>
Michael Hanlbd852b82015-11-18 22:17:00 +010088 <property name="dataSource" ref="dataSource"/>
89 </bean>
90
91 <bean id="kustvakt_db"
92 class="de.ids_mannheim.korap.handlers.JDBCClient">
93 <constructor-arg index="0" ref="dataSource"/>
Michael Hanldaf86602016-05-12 14:31:52 +020094 <property name="database" value="jdbc:sqlite::memory:"/>
Michael Hanlbd852b82015-11-18 22:17:00 +010095 </bean>
96
Michael Hanle4fc7752016-02-17 11:41:18 +010097 <bean id="kustvakt_userdetails"
98 class="de.ids_mannheim.korap.handlers.UserDetailsDao">
99 <constructor-arg ref="kustvakt_db"/>
100 </bean>
101
102 <bean id="kustvakt_usersettings"
103 class="de.ids_mannheim.korap.handlers.UserSettingsDao">
104 <constructor-arg ref="kustvakt_db"/>
105 </bean>
106
Michael Hanlbd852b82015-11-18 22:17:00 +0100107 <bean id="kustvakt_auditing"
108 class="de.ids_mannheim.korap.handlers.JDBCAuditing">
109 <constructor-arg ref="kustvakt_db"/>
110 </bean>
111
112 <bean id="kustvakt_userdb"
113 class="de.ids_mannheim.korap.handlers.EntityDao">
114 <constructor-arg ref="kustvakt_db"/>
115 </bean>
116
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200117 <bean id="resource_provider"
Michael Hanlbd852b82015-11-18 22:17:00 +0100118 class="de.ids_mannheim.korap.handlers.ResourceDao">
119 <constructor-arg ref="kustvakt_db"/>
120 </bean>
121
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200122 <bean id="document_provider"
123 class="de.ids_mannheim.korap.handlers.DocumentDao">
124 <constructor-arg ref="kustvakt_db"/>
125 </bean>
126
Michael Hanlbd852b82015-11-18 22:17:00 +0100127 <bean id="kustvakt_policies"
128 class="de.ids_mannheim.korap.security.ac.PolicyDao">
129 <constructor-arg ref="kustvakt_db"/>
130 </bean>
131
132 <bean name="kustvakt_encryption"
133 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
134 <constructor-arg ref="kustvakt_config"/>
135 </bean>
136
137 <!-- authentication providers to use -->
138 <bean id="api_auth"
139 class="de.ids_mannheim.korap.security.auth.APIAuthentication">
140 <constructor-arg
141 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
142 ref="kustvakt_config"/>
143 </bean>
144
145 <bean id="openid_auth"
146 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
147 <constructor-arg
148 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
149 ref="kustvakt_config"/>
150 <constructor-arg
151 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
152 ref="kustvakt_db"/>
153 </bean>
154
155 <bean id="basic_auth"
156 class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/>
157
158
159 <bean id="session_auth"
160 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
161 <constructor-arg
162 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
163 ref="kustvakt_config"/>
164 <constructor-arg
165 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
166 ref="kustvakt_encryption"/>
167 </bean>
168
Michael Hanldaf86602016-05-12 14:31:52 +0200169 <util:list id="kustvakt_authproviders"
Michael Hanlbd852b82015-11-18 22:17:00 +0100170 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
171 <ref bean="basic_auth"/>
172 <ref bean="session_auth"/>
173 <ref bean="api_auth"/>
174 <ref bean="openid_auth"/>
175 </util:list>
176
Michael Hanldaf86602016-05-12 14:31:52 +0200177 <bean id="userdata_details"
178 class="de.ids_mannheim.korap.handlers.UserDetailsDao">
179 <constructor-arg
180 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
181 ref="kustvakt_db"/>
182 </bean>
183 <bean id="userdata_settings"
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200184 class="de.ids_mannheim.korap.handlers.UserSettingsDao">
Michael Hanldaf86602016-05-12 14:31:52 +0200185 <constructor-arg
186 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
187 ref="kustvakt_db"/>
188 </bean>
189
190 <util:list id="kustvakt_userdata"
191 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
192 <ref bean="userdata_details"/>
193 <ref bean="userdata_settings"/>
194 </util:list>
195
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200196 <util:list id="kustvakt_resources"
197 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
198 <ref bean="document_provider"/>
199 <ref bean="resource_provider"/>
200 </util:list>
201
Michael Hanldaf86602016-05-12 14:31:52 +0200202
Michael Hanlbd852b82015-11-18 22:17:00 +0100203 <!-- specify type for constructor argument -->
204 <bean id="kustvakt_authenticationmanager"
205 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
206 <constructor-arg
207 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface"
208 ref="kustvakt_userdb"/>
209 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
210 ref="kustvakt_encryption"/>
211 <constructor-arg ref="kustvakt_config"/>
212 <constructor-arg
213 type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
214 ref="kustvakt_auditing"/>
Michael Hanldaf86602016-05-12 14:31:52 +0200215 <constructor-arg ref="kustvakt_userdata"/>
Michael Hanlbd852b82015-11-18 22:17:00 +0100216 <!-- inject authentication providers to use -->
Michael Hanldaf86602016-05-12 14:31:52 +0200217 <property name="providers" ref="kustvakt_authproviders"/>
Michael Hanlbd852b82015-11-18 22:17:00 +0100218 </bean>
219
220 <!-- todo: if db interfaces not loaded via spring, does transaction even work then? -->
221 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
222 <tx:advice id="txAdvice" transaction-manager="txManager">
223 <!-- the transactional semantics... -->
224 <tx:attributes>
225 <!-- all methods starting with 'get' are read-only -->
226 <tx:method name="get*" read-only="true"
227 rollback-for="KorAPException"/>
228 <!-- other methods use the default transaction settings (see below) -->
229 <tx:method name="*" rollback-for="KorAPException"/>
230 </tx:attributes>
231 </tx:advice>
232
233 <!-- ensure that the above transactional advice runs for any execution
234 of an operation defined by the service interface -->
235 <aop:config>
236 <aop:pointcut id="service"
237 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/>
238 <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
239 </aop:config>
240
241 <!-- similarly, don't forget the PlatformTransactionManager -->
242 <bean id="txManager"
243 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
244 <property name="dataSource" ref="dataSource"/>
245 </bean>
246</beans>