Java Reference
In-Depth Information
<bean id="authenticationDao"
class="org.springframework.security.userdetails.jdbc.JdbcDaoImpl">
<property name="dataSource" ref="dataSource"/>
<property name="userByUserNameQuery" >
<value>
SELECT username, password, enabled
FROM users
WHERE username=?
</value>
</property>
<property name="authoritiesByUserNameQuery" >
<value>
SELECT username, authority
FROM authorities
WHERE username=?
</value>
</property>
</bean>
</beans>
If your tables and column names were different, it is possible to supply your custom
queries by overriding the userByUserNameQuery and authoritiesByUserNameQuery properties.
You need to use proper aliases for the columns that have different names than the default
tables because Spring retrieves data from the resultset using default column names.
eInsure used the e-mail address instead of the username and role in the place of author-
ity. Listing 6-12 shows the configuration of the custom queries with aliases.
Listing 6-12. applicationContext-security.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
" http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
 
Search WWH ::




Custom Search