<!-- 从数据库中读取用户信息验证身份 -->
<bean id ="daoAuthenticationProvider"
class= "org.acegisecurity.providers.dao.DaoAuthenticationProvider" >
<property name ="userDetailsService" ref= "inMemDaoImpl" />
</bean >
<!-- 基于内存实现方式-->
<bean id ="inMemDaoImpl"
class= "org.acegisecurity.userdetails.memory.InMemoryDaoImpl" >
<property name ="userMap">
<value >
test=1,ROLE_USER
lisi=1,ROLE_SUPERVISOR
zhangsan=1,ROLE_SUPERVISOR,disabled
</value >
</property >
</bean >.png)
.png)
.png)
<bean id="userDetailsService" class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl"> <property name="jdbcTemplate" ref="JdbcTemplate"> </property> </bean> <bean id="JdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSource"></property> </bean>
<bean id="userDetailsService"
class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl">
<property name="dataSource" ref="dataSource"></property>
</bean>.png)
<bean id="userDetailsService"
class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl">
<property name="jdbcTemplate" ref="JdbcTemplate"> </property>
<!-- 配置查询条件 -->
<property name="usersByUsernameQuery">
<value>
select t.user_name,t.pwd,t.enabled from test_user t where t.user_name=?
</value>
</property>
<property name="authoritiesByUsernameQuery">
<value>
select t.user_name,t.auths from test_auths t where t.user_name=?
</value>
</property>
</bean>
<bean id="JdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"></property>
</bean>acegi security实践教程—把用户信息存放到数据库,布布扣,bubuko.com
acegi security实践教程—把用户信息存放到数据库
原文:http://blog.csdn.net/yuebinghaoyuan/article/details/21153379