图1 安全管理对象,拦截器和安全管理组件交互图 图2 Acegi安全控制系统数据库设计 |
/* 配置数据库datasource 和Acegi 的 jdbcDao */ <bean id=”dataSource” class=”org.springframework.jdbc.datasource.DriverManagerDataSource”> <property name=”driverClassName”> <value>${jdbc.driverClassName}</value> </property> <property name=”url”> <value>${jdbc.url}</value> </property> |
|
<property name=”username”> <value>${jdbc.username}</value> </property> <property name=”password”> <value>${jdbc.password}</value> </property> </bean> <bean id=”jdbcDaoImpl” class=”org.acegisecurity. roviders. dao.jdbc.JdbcDaoImpl”> <property name=”dataSource”> <ref bean=”dataSource”/> </property> </bean> /*配置用户信息的加密算法*/ <bean id=”passwordEncoder” Class=”org.acegisecurity.providers.encoding.Md5passwordEncoder”/> /*配置缓存有效时间*/ <bean id=”userCache” class=”org.acegiSecurity. providers. dao.cache.EhCacheBasedUserCache”> …//这里对缓存有效时间进行设置 </bean> /*配置daoAuthenticationProvider*/ <bean id=”daoAuthenticationProvider” class=”org.acegisecurity.providers.dao.DaoAuthenticationProvider”> <property name=”authenticationDao”> <ref local=”JdbcDaoImpl”/> </property> <property name=”passwordEncoder”> <ref local=” passwordEncoder”/> </property> <property name=”userCache”> <ref local=” userCache”/> </property> </bean> /*配置认证管理器*/ <bean id=”authenticationManager” class=”org.acegisecurity. providers.ProviderManager”> <property name=”providers”> <list> <ref local=”daoAuthenticationProvider”/> </list> </property> </bean> |
<filter> <filter-name>Acegi HTTP Request Security Filter</filter-name> <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class> <init-param> <param-name>targetClass</param-name> <param-value> Org.acegisecurity.intercept.web.SecurityEnforcementFilter </param-value> </init-param> </filter> <filter-mapping> <filter-name>Acigi HTTP Request Security Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> |
<bean id=”securityEnforcementFilter” class=””> <property name=”filterSecurityInterceptor”> <ref bean=”filterInvocationInteceptor”/> </property> <property name=”authenticationEntryPoint”> <ref bean=”authenticationProcessingFilterEntryPoint”/> </property> |
<bean id=”filterInvocationInterceptor” Class=””> <property name=”authenuserCacheticationManager”>1 <property name=”accessDecisionManager”> <property name=”objectDefinitionSource”> <ref local="filterObjectDefinitionSource"/> </property> <bean id="filterObjectDefinitionSource" class="org.xiaohongli.acegi.db.DBFilterObjectDefinitionSource"> <constructor-arg><refbean="jdbcTemplate"/> </constructor-arg> </bean> |
<bean id="methodObjectDefinitionSource" class="org.xiaohongli.acegi.db.DBMethodObjectDefinitionSource"> <constructor-arg><refbean="jdbcTemplate"/> </constructor-arg> </bean> |