Spring Security Contacts Example - sangeeth/springworks GitHub Wiki
The example found in Spring Source uses Gradle. So I converted it into a Maven project. Then instead of HSQLDB, I changed few things to run on MySQL.
By default the sample uses HSQLDB. In order to use MySQL, we need to make some changes in the following Spring bean definition files
- applicationContext-common-authorization.xml
- applicationContext-common-business.xml
Define "dataSource" bean as shown below
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost/springworks_security_contacts"/> <property name="username" value="springworks"/> <property name="password" value="springworks"/> </bean>
To "dataSourcePopulator" bean, specify the MySQL specific DDL script /springworks_security_contacts.mysql.ddl.sql as shown below.
<bean id="dataSourcePopulator" class="sample.contact.DataSourcePopulator"> <property name="dataSource" ref="dataSource"/> <property name="mutableAclService" ref="aclService"/> <property name="platformTransactionManager" ref="transactionManager"/> <property name="createScript" value="/springworks_security_contacts.mysql.ddl.sql"/> </bean>
Define the "aclService" bean as shown below
<bean id="aclService" class="org.springframework.security.acls.jdbc.JdbcMutableAclService"> <constructor-arg ref="dataSource"/> <constructor-arg ref="lookupStrategy"/> <constructor-arg ref="aclCache"/> <property name="classIdentityQuery" value="SELECT @@IDENTITY"/> <property name="sidIdentityQuery" value="SELECT @@IDENTITY"/> </bean>
By default, the AclService expects a function named "identity", hence if you don't specify the following properties, DataSourcePopulator will error out with SQL exception.
- classIdentityquery
- sidIdentityQuery