blob: 62d5997106e14f4ec910774be36726b2bd47baa6 [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 -->
Michael Hanl72c7b832015-09-03 08:42:15 +020059 <bean id="dataSource"
Michael Hanl19390652016-01-16 11:01:24 +010060 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
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 -->
Michael Hanl19390652016-01-16 11:01:24 +010067 <property name="suppressClose">
68 <value>true</value>
69 </property>
70 <!--<property name="initialSize" value="2"/>-->
71 <!--<property name="maxIdle" value="2"/>-->
72 <!--<property name="poolPreparedStatements" value="true"/>-->
Michael Hanl72c7b832015-09-03 08:42:15 +020073 </bean>
74
75 <!-- to configure database for sqlite, mysql, etc. migrations -->
76 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
77 <property name="baselineOnMigrate" value="false"/>
78 <property name="locations"
Michael Hanldaf86602016-05-12 14:31:52 +020079 value="${jdbc.schemaPath}"/>
Michael Hanl72c7b832015-09-03 08:42:15 +020080 <property name="dataSource" ref="dataSource"/>
81 </bean>
82
83 <bean id="kustvakt_db"
Michael Hanl482f30d2015-09-25 12:39:46 +020084 class="de.ids_mannheim.korap.handlers.JDBCClient">
Michael Hanl72c7b832015-09-03 08:42:15 +020085 <constructor-arg index="0" ref="dataSource"/>
86 <!-- deprecated property -->
87 <property name="database" value="${jdbc.database}"/>
88 </bean>
89
90 <bean id="kustvakt_auditing"
Michael Hanl482f30d2015-09-25 12:39:46 +020091 class="de.ids_mannheim.korap.handlers.JDBCAuditing">
Michael Hanl72c7b832015-09-03 08:42:15 +020092 <constructor-arg ref="kustvakt_db"/>
93 </bean>
94
95 <bean id="kustvakt_userdb"
Michael Hanl482f30d2015-09-25 12:39:46 +020096 class="de.ids_mannheim.korap.handlers.EntityDao">
Michael Hanl72c7b832015-09-03 08:42:15 +020097 <constructor-arg ref="kustvakt_db"/>
98 </bean>
99
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200100 <bean id="resource_provider"
Michael Hanl482f30d2015-09-25 12:39:46 +0200101 class="de.ids_mannheim.korap.handlers.ResourceDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200102 <constructor-arg ref="kustvakt_db"/>
103 </bean>
104
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200105 <bean id="document_provider"
106 class="de.ids_mannheim.korap.handlers.DocumentDao">
107 <constructor-arg ref="kustvakt_db"/>
108 </bean>
109
Michael Hanl72c7b832015-09-03 08:42:15 +0200110 <bean id="kustvakt_policies"
Michael Hanlf21773f2015-10-16 23:02:31 +0200111 class="de.ids_mannheim.korap.security.ac.PolicyDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200112 <constructor-arg ref="kustvakt_db"/>
113 </bean>
114
Michael Hanl1e18cb42015-08-06 20:57:35 +0200115 <bean name="kustvakt_encryption"
Michael Hanlf21773f2015-10-16 23:02:31 +0200116 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
Michael Hanl72c7b832015-09-03 08:42:15 +0200117 <constructor-arg ref="kustvakt_config"/>
118 </bean>
119
Michael Hanl72c7b832015-09-03 08:42:15 +0200120 <!-- authentication providers to use -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200121 <bean id="api_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200122 class="de.ids_mannheim.korap.security.auth.APIAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200123 <constructor-arg
124 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
125 ref="kustvakt_config"/>
126 </bean>
127
128 <bean id="openid_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200129 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200130 <constructor-arg
131 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
132 ref="kustvakt_config"/>
133 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200134 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
Michael Hanl72c7b832015-09-03 08:42:15 +0200135 ref="kustvakt_db"/>
136 </bean>
137
138 <bean id="basic_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200139 class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200140
141
142 <bean id="session_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200143 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200144 <constructor-arg
145 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
146 ref="kustvakt_config"/>
147 <constructor-arg
148 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
149 ref="kustvakt_encryption"/>
150 </bean>
151
Michael Hanldaf86602016-05-12 14:31:52 +0200152 <util:list id="kustvakt_authproviders"
Michael Hanl72c7b832015-09-03 08:42:15 +0200153 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
154 <ref bean="basic_auth"/>
155 <ref bean="session_auth"/>
156 <ref bean="api_auth"/>
157 <ref bean="openid_auth"/>
158 </util:list>
159
Michael Hanldaf86602016-05-12 14:31:52 +0200160
161 <bean id="userdata_details"
162 class="de.ids_mannheim.korap.handlers.UserDetailsDao">
163 <constructor-arg
Michael Hanldaf86602016-05-12 14:31:52 +0200164 ref="kustvakt_db"/>
165 </bean>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200166
Michael Hanldaf86602016-05-12 14:31:52 +0200167 <bean id="userdata_settings"
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200168 class="de.ids_mannheim.korap.handlers.UserSettingsDao">
Michael Hanldaf86602016-05-12 14:31:52 +0200169 <constructor-arg
Michael Hanldaf86602016-05-12 14:31:52 +0200170 ref="kustvakt_db"/>
171 </bean>
172
173 <util:list id="kustvakt_userdata"
174 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
175 <ref bean="userdata_details"/>
176 <ref bean="userdata_settings"/>
177 </util:list>
178
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200179
180 <util:list id="kustvakt_resources"
181 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
182 <ref bean="document_provider"/>
183 <ref bean="resource_provider"/>
184 </util:list>
185
Michael Hanl72c7b832015-09-03 08:42:15 +0200186 <!-- specify type for constructor argument -->
187 <bean id="kustvakt_authenticationmanager"
Michael Hanlf21773f2015-10-16 23:02:31 +0200188 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
Michael Hanl72c7b832015-09-03 08:42:15 +0200189 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200190 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface"
Michael Hanl72c7b832015-09-03 08:42:15 +0200191 ref="kustvakt_userdb"/>
192 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
193 ref="kustvakt_encryption"/>
194 <constructor-arg ref="kustvakt_config"/>
Michael Hanlf21773f2015-10-16 23:02:31 +0200195 <constructor-arg
196 type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
197 ref="kustvakt_auditing"/>
Michael Hanldaf86602016-05-12 14:31:52 +0200198 <constructor-arg ref="kustvakt_userdata"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200199 <!-- inject authentication providers to use -->
Michael Hanldaf86602016-05-12 14:31:52 +0200200 <property name="providers" ref="kustvakt_authproviders"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200201 </bean>
202
Michael Hanl72c7b832015-09-03 08:42:15 +0200203 <!-- todo: if db interfaces not loaded via spring, does transaction even work then? -->
204 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
205 <tx:advice id="txAdvice" transaction-manager="txManager">
206 <!-- the transactional semantics... -->
207 <tx:attributes>
208 <!-- all methods starting with 'get' are read-only -->
209 <tx:method name="get*" read-only="true"
210 rollback-for="KorAPException"/>
211 <!-- other methods use the default transaction settings (see below) -->
212 <tx:method name="*" rollback-for="KorAPException"/>
213 </tx:attributes>
214 </tx:advice>
215
216 <!-- ensure that the above transactional advice runs for any execution
217 of an operation defined by the service interface -->
218 <aop:config>
219 <aop:pointcut id="service"
Michael Hanlf21773f2015-10-16 23:02:31 +0200220 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200221 <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
222 </aop:config>
223
224 <!-- similarly, don't forget the PlatformTransactionManager -->
225 <bean id="txManager"
226 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
227 <property name="dataSource" ref="dataSource"/>
Michael Hanlca740d72015-06-16 10:04:58 +0200228 </bean>
229</beans>