blob: 983a69cdde8f2fd0b7f170eee67dba2daa772d68 [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 Hanl72c7b832015-09-03 08:42:15 +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 Hanl72c7b832015-09-03 08:42:15 +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
15 http://www.springframework.org/schema/cache
16 http://www.springframework.org/schema/cache/spring-cache-4.0.xsd
17
18
Michael Hanlca740d72015-06-16 10:04:58 +020019 http://www.springframework.org/schema/util
20 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
21
Michael Hanl72c7b832015-09-03 08:42:15 +020022 <cache:annotation-driven/>
Michael Hanlca740d72015-06-16 10:04:58 +020023 <util:properties id="props" location="classpath:kustvakt.conf"/>
24
Michael Hanl72c7b832015-09-03 08:42:15 +020025 <bean id="jdbc_props"
26 class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
27 <property name="locations" value="classpath:jdbc.properties"/>
Michael Hanlca740d72015-06-16 10:04:58 +020028 </bean>
29
Michael Hanl72c7b832015-09-03 08:42:15 +020030 <bean id='cacheManager'
31 class='org.springframework.cache.ehcache.EhCacheCacheManager'
32 p:cacheManager-ref='ehcache'/>
33
34 <bean id='ehcache'
35 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
36 p:configLocation='classpath:ehcache.xml'
37 p:shared='true'/>
38
39 <!-- props are injected from default-config.xml -->
Michael Hanl1e18cb42015-08-06 20:57:35 +020040 <bean id="kustvakt_config"
Michael Hanlf21773f2015-10-16 23:02:31 +020041 class="de.ids_mannheim.korap.config.KustvaktConfiguration">
Michael Hanlca740d72015-06-16 10:04:58 +020042 <property name="properties" ref="props"/>
43 </bean>
44
Michael Hanl72c7b832015-09-03 08:42:15 +020045 <bean id="dataSource"
Michael Hanlf21773f2015-10-16 23:02:31 +020046 class="org.apache.commons.dbcp2.BasicDataSource"
Michael Hanl72c7b832015-09-03 08:42:15 +020047 lazy-init="true">
48 <property name="driverClassName" value="${jdbc.driverClassName}"/>
49 <property name="url" value="${jdbc.url}"/>
50 <property name="username" value="${jdbc.username}"/>
51 <property name="password" value="${jdbc.password}"/>
52 <!-- relevant for single connection datasource and sqlite -->
Michael Hanlf21773f2015-10-16 23:02:31 +020053 <!--<property name="suppressClose">-->
54 <!--<value>true</value>-->
55 <!--</property>-->
56 <property name="initialSize" value="1"/>
57 <property name="maxIdle" value="1"/>
58 <property name="poolPreparedStatements" value="true"/>
Michael Hanl72c7b832015-09-03 08:42:15 +020059 </bean>
60
61 <!-- to configure database for sqlite, mysql, etc. migrations -->
62 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
63 <property name="baselineOnMigrate" value="false"/>
64 <property name="locations"
65 value="classpath:${jdbc.schemaPath}"/>
66 <property name="dataSource" ref="dataSource"/>
67 </bean>
68
69 <bean id="kustvakt_db"
Michael Hanl482f30d2015-09-25 12:39:46 +020070 class="de.ids_mannheim.korap.handlers.JDBCClient">
Michael Hanl72c7b832015-09-03 08:42:15 +020071 <constructor-arg index="0" ref="dataSource"/>
72 <!-- deprecated property -->
73 <property name="database" value="${jdbc.database}"/>
74 </bean>
75
76 <bean id="kustvakt_auditing"
Michael Hanl482f30d2015-09-25 12:39:46 +020077 class="de.ids_mannheim.korap.handlers.JDBCAuditing">
Michael Hanl72c7b832015-09-03 08:42:15 +020078 <constructor-arg ref="kustvakt_db"/>
79 </bean>
80
81 <bean id="kustvakt_userdb"
Michael Hanl482f30d2015-09-25 12:39:46 +020082 class="de.ids_mannheim.korap.handlers.EntityDao">
Michael Hanl72c7b832015-09-03 08:42:15 +020083 <constructor-arg ref="kustvakt_db"/>
84 </bean>
85
Michael Hanl482f30d2015-09-25 12:39:46 +020086 <!--fixme: change name according to convention -->
Michael Hanl72c7b832015-09-03 08:42:15 +020087 <bean id="collectionProvider"
Michael Hanl482f30d2015-09-25 12:39:46 +020088 class="de.ids_mannheim.korap.handlers.CollectionDao">
Michael Hanl72c7b832015-09-03 08:42:15 +020089 <constructor-arg ref="kustvakt_db"/>
90 </bean>
91
Michael Hanl482f30d2015-09-25 12:39:46 +020092 <!--fixme: change name according to convention -->
Michael Hanl72c7b832015-09-03 08:42:15 +020093 <bean id="resourceProvider"
Michael Hanl482f30d2015-09-25 12:39:46 +020094 class="de.ids_mannheim.korap.handlers.ResourceDao">
Michael Hanl72c7b832015-09-03 08:42:15 +020095 <constructor-arg ref="kustvakt_db"/>
96 </bean>
97
98 <bean id="kustvakt_policies"
Michael Hanlf21773f2015-10-16 23:02:31 +020099 class="de.ids_mannheim.korap.security.ac.PolicyDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200100 <constructor-arg ref="kustvakt_db"/>
101 </bean>
102
Michael Hanl1e18cb42015-08-06 20:57:35 +0200103 <bean name="kustvakt_encryption"
Michael Hanlf21773f2015-10-16 23:02:31 +0200104 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
Michael Hanl72c7b832015-09-03 08:42:15 +0200105 <constructor-arg ref="kustvakt_config"/>
106 </bean>
107
Michael Hanl72c7b832015-09-03 08:42:15 +0200108 <!-- authentication providers to use -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200109 <bean id="api_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200110 class="de.ids_mannheim.korap.security.auth.APIAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200111 <constructor-arg
112 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
113 ref="kustvakt_config"/>
114 </bean>
115
116 <bean id="openid_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200117 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200118 <constructor-arg
119 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
120 ref="kustvakt_config"/>
121 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200122 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
Michael Hanl72c7b832015-09-03 08:42:15 +0200123 ref="kustvakt_db"/>
124 </bean>
125
126 <bean id="basic_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200127 class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200128
129
130 <bean id="session_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200131 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200132 <constructor-arg
133 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
134 ref="kustvakt_config"/>
135 <constructor-arg
136 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
137 ref="kustvakt_encryption"/>
138 </bean>
139
140 <util:list id="auth_providers"
141 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
142 <ref bean="basic_auth"/>
143 <ref bean="session_auth"/>
144 <ref bean="api_auth"/>
145 <ref bean="openid_auth"/>
146 </util:list>
147
148 <!-- specify type for constructor argument -->
149 <bean id="kustvakt_authenticationmanager"
Michael Hanlf21773f2015-10-16 23:02:31 +0200150 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
Michael Hanl72c7b832015-09-03 08:42:15 +0200151 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200152 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface"
Michael Hanl72c7b832015-09-03 08:42:15 +0200153 ref="kustvakt_userdb"/>
154 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
155 ref="kustvakt_encryption"/>
156 <constructor-arg ref="kustvakt_config"/>
Michael Hanlf21773f2015-10-16 23:02:31 +0200157 <constructor-arg
158 type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
159 ref="kustvakt_auditing"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200160 <!-- inject authentication providers to use -->
161 <property name="providers" ref="auth_providers"/>
162 </bean>
163
Michael Hanl72c7b832015-09-03 08:42:15 +0200164 <!-- todo: if db interfaces not loaded via spring, does transaction even work then? -->
165 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
166 <tx:advice id="txAdvice" transaction-manager="txManager">
167 <!-- the transactional semantics... -->
168 <tx:attributes>
169 <!-- all methods starting with 'get' are read-only -->
170 <tx:method name="get*" read-only="true"
171 rollback-for="KorAPException"/>
172 <!-- other methods use the default transaction settings (see below) -->
173 <tx:method name="*" rollback-for="KorAPException"/>
174 </tx:attributes>
175 </tx:advice>
176
177 <!-- ensure that the above transactional advice runs for any execution
178 of an operation defined by the service interface -->
179 <aop:config>
180 <aop:pointcut id="service"
Michael Hanlf21773f2015-10-16 23:02:31 +0200181 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200182 <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
183 </aop:config>
184
185 <!-- similarly, don't forget the PlatformTransactionManager -->
186 <bean id="txManager"
187 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
188 <property name="dataSource" ref="dataSource"/>
Michael Hanlca740d72015-06-16 10:04:58 +0200189 </bean>
190</beans>