acegi 源码学习之用户登录篇
一、查看 applicationContext-acegi-security.xml 配置文件,涉及到登录的配置为:
1 .
< bean id = "authenticationProcessingFilter" class = "org.javajohn.test.plugins.security.UserAuthenticationProcessingFilter" >
< property name = "authenticationManager" ref = "authenticationManager" />
< property name = "authenticationFailureUrl" >
< value > /login.jsp?login_error=1 </ value >
</ property >
< property name = "defaultTargetUrl" >
< value > /index.jsp </ value >
</ property >
< property name = "filterProcessesUrl" >
< value > /j_acegi_security_check </ value >
</ property >
< property name = "userManager" ref = "userManager" />
< property name = "rememberMeServices" ref = "rememberMeServices" />
< property name = "exceptionMappings" >
< value >
org.acegisecurity.AuthenticationException=/login.jsp?login_error=user_psw_error
org.acegisecurity.concurrent.ConcurrentLoginException=/login.jsp?login_error=too_many_user_error
</ value >
</ property >
</ bean >
2 . < bean id = "authenticationManager"
class = "org.acegisecurity.providers.ProviderManager" >
< property name = "providers" >
< list >
< ref local = "daoAuthenticationProvider" />
< bean class = "org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider" >
< property name = "key" value = "javajohnKey" />
</ bean >
< bean class = "org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider" >
< property name = "key" value = "javajohnKey" />
</ bean >
</ list >
</ property >
</ bean >
3 .
< bean id = "daoAuthenticationProvider" class = "org.acegisecurity.providers.dao.DaoAuthenticationProvider" >
< property name = "userDetailsService" ref = "jdbcDaoImpl" />
< property name = "userCache" >
< bean class = "org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache" >
< property name = "cache" >
< bean class = "org.springframework.cache.ehcache.EhCacheFactoryBean" >
< property name = "cacheManager" >
< bean class = "org.springframework.cache.ehcache.EhCacheManagerFactoryBean" />
</ property >
< property name = "cacheName" value = "userCache" />
</ bean >
</ property >
</ bean >
</ property >
< property name = "passwordEncoder" ref = "passwordEncoder" />
</ bean >
4 . < bean id = "jdbcDaoImpl"
class = "org.acegisecurity.userdetails.jdbc.JdbcDaoImpl" >
< property name = "dataSource" ref = "dataSource" />
< property name = "usersByUsernameQuery" >
< value >
select loginid,passwd,1 from users where status='1' and loginid = ?
</ value >
</ property >
< property name = "authoritiesByUsernameQuery" >
< value >
select u.loginid,p.name from
users u,roles r,permissions p,user_role ur,role_permis rp
where
u.id=ur.user_id and