初次接触Acegi记录的

[?xml version="1.0" encoding="UTF-8"?]
[!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"]
[beans]
 [!---过滤器代理bean_1级-----------------------------------------------------------]
 [!--  if you wish to use channel security, add "channelProcessingFilter," in front
  of "httpSessionContextIntegrationFilter" in the list below --]
 [!--FilterChainProxy是对FilterToBeanProxy的一个封装;该过滤器代理用来调度一下过滤器bean--]
 [bean id="filterChainProxy"
  class="org.acegisecurity.util.FilterChainProxy"]
  [property name="filterInvocationDefinitionSource"]
   [value]
    CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    PATTERN_TYPE_APACHE_ANT
    [!--        /**=httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,basicProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,switchUserProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor --]
    /**=httpSessionContextIntegrationFilter,authenticationProcessingFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,concurrentSessionFilter,filterInvocationInterceptor
   [/value]
  [/property]
 [/bean]

 [!---以下是上面用到的几个过滤器_2级-----------------------------------------------]
 [!--该过滤器是用来[Integration:综合;]把认证信息记录到Session中的;--]
 [bean id="httpSessionContextIntegrationFilter"
  class="org.acegisecurity.context.HttpSessionContextIntegrationFilter"]
  [property name="context"]
   [value]org.acegisecurity.context.SecurityContextImpl[/value]
  [/property]
 [/bean]

 [!--authenticationProcessingFilter处理登陆请求.当身份验证成功时,
 AuthenticationProcessingFilter会在会话中放置一个Authentication对象,
 并且重定向到登录成功页面--]
 [bean id="authenticationProcessingFilter"
  class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter"]
  [property name="authenticationManager"]
   [ref bean="authenticationManager" /]
  [/property]
  [property name="authenticationFailureUrl"]
   [value]/Login.html?login_error=1[/value]
  [/property]
  [property name="defaultTargetUrl"]
   [value]/app/index.action[/value]
  [/property]
  [property name="filterProcessesUrl"]
   [value]/j_acegi_security_check[/value]
  [/property]
 [/bean]

 [!--RememberMeProcessingFilter是以cookie的形式来保存认证信息的.--]
 [bean id="rememberMeProcessingFilter"
  class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter"]
  [property name="authenticationManager"]
   [ref local="authenticationManager" /]
  [/property]
  [property name="rememberMeServices"]
   [ref local="rememberMeServices" /]
  [/property]
 [/bean]

 [!--anonymousProcessingFilter是在匿名的时候(这时候是没有认证信息的)给这个用户分配一个匿名的认证信息--]
 [bean id="anonymousProcessingFilter"
  class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter"]
  [property name="key"]
   [value]foobar[/value]
  [/property]
  [property name="userAttribute"]
   [value]anonymousUser,ROLE_ANONYMOUS[/value]
  [/property]
 [/bean]

 [!--exceptionTranslationFilter异常转换过滤器,
 主要是处理AccessDeniedException和AuthenticationException,
 将给每个异常找到合适的"去向" --]
 [bean id="exceptionTranslationFilter"
  class="org.acegisecurity.ui.ExceptionTranslationFilter"]
  [property name="authenticationEntryPoint"]
   [ref local="authenticationProcessingFilterEntryPoint" /]
  [/property]
 [/bean]

 [!--该过滤器一般用来控制同一用户名只有一个人在线--]
 [!-- fifth item in chain: ConcurrentSessionFilter --]
 [bean id="concurrentSessionFilter"
  class="org.acegisecurity.concurrent.ConcurrentSessionFilter"]
  [property name="sessionRegistry"]
   [ref local="sessionRegistry" /]
  [/property]
  [property name="expiredUrl"]
   [value]/[/value]
  [/property]
 [/bean]

 [!--ilterSecurityInterceptor拦截URL的类(实际上它算是个过滤器)--]
 [!-- Note the order that entries are placed against the objectDefinitionSource is critical.
  The FilterSecurityInterceptor will work from the top of the list down to the FIRST pattern that matches the request URL.
  Accordingly, you should place MOST SPECIFIC (ie a/b/c/d.*) expressions first, with LEAST SPECIFIC (ie a/.*) expressions last --]
 [bean id="filterInvocationInterceptor"
  class="org.acegisecurity.intercept.web.FilterSecurityInterceptor"]
  [property name="authenticationManager"]
   [ref bean="authenticationManager" /]
  [/property]
  [property name="accessDecisionManager"]
   [ref local="httpRequestAccessDecisionManager" /]
  [/property]
  [property name="objectDefinitionSource"]
   [value]
    PATTERN_TYPE_APACHE_ANT
    /**/*.jpg=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN
    /**/*.gif=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN
    /**/*.png=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN
    /**/*.css=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN
    /**/*.js=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN
    /remote/**=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN
    /Login.html*=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN
    /app/userRegInput.action*=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN
    /app/validateRegInput.action*=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN
    /app/agree.action*=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN
    /app/actcodeValidation.action*=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN
    /remoteclient/**=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN
    /sysadmin/**=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN
    /**=ROLE_USER,ROLE_ADMIN
   [/value]
  [/property]
 [/bean]

 [!---以下是上面几个过滤器使用到的类_3级--------------------------------------------]
 
 [!--认证管理器,用于认证ContextHolder中的Authentication对象。--]
 [bean id="authenticationManager"
  class="org.acegisecurity.providers.ProviderManager"]
  [property name="providers"]
   [list]
    [ref local="daoAuthenticationProvider" /]
    [ref local="anonymousAuthenticationProvider" /]
    [ref local="rememberMeAuthenticationProvider" /]
   [/list]
  [/property]
  [property name="sessionController"]
   [ref bean="concurrentSessionController" /]
  [/property]
 [/bean]

 [!-- 授权管理器 --]
 [bean id="httpRequestAccessDecisionManager"
  class="org.acegisecurity.vote.AffirmativeBased"]
  [property name="allowIfAllAbstainDecisions"]
   [value]false[/value]
  [/property]
  [property name="decisionVoters"]
   [list]
    [ref bean="roleVoter" /]
   [/list]
  [/property]
 [/bean]

 [bean id="rememberMeServices"
  class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices"]
  [property name="userDetailsService"]
   [ref local="userSecurtyDetails" /]
  [/property]
  [property name="key"]
   [value]springRocks[/value]
  [/property]
 [/bean]
 
 [!-- 当抛出AccessDeniedException时,将用户重定向到登录界面。
 属性loginFormUrl配置了一个登录表单的URL,当需要用户登录时,
 authenticationProcessingFilterEntryPoint会将用户重定向到该URL --]
 [bean id="authenticationProcessingFilterEntryPoint"
  class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint"]
  [property name="loginFormUrl"]
   [value]/Login.html[/value]
  [/property]
  [property name="forceHttps"]
   [value]false[/value]
  [/property]
 [/bean]

 [bean id="sessionRegistry"
  class="org.acegisecurity.concurrent.SessionRegistryImpl" /]

 [!---以下是被过滤器使用的类的关联的类_4级--------------------------------------------]
 [bean id="daoAuthenticationProvider"
  class="org.acegisecurity.providers.dao.DaoAuthenticationProvider"]
  [property name="userDetailsService"]
   [ref local="userSecurtyDetails" /]
  [/property]
  [property name="userCache"]
   [ref local="userCache" /]
  [/property]
  [!-- [property name="passwordEncoder"][ref local="passwordEncoder"/][/property]--]
 [/bean]

 [bean id="anonymousAuthenticationProvider"
  class="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider"]
  [property name="key"]
   [value]foobar[/value]
  [/property]
 [/bean]

 [bean id="rememberMeAuthenticationProvider"
  class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider"]
  [property name="key"]
   [value]springRocks[/value]
  [/property]
 [/bean]

 [!-- ConcurrentSessionController 这个用来控制同一用户只有一个人登陆--]
 [bean id="concurrentSessionController"
  class="org.acegisecurity.concurrent.ConcurrentSessionControllerImpl"]
  [property name="maximumSessions"]
   [value]1[/value]
  [/property]
  [property name="sessionRegistry"]
   [ref local="sessionRegistry" /]
  [/property]
 [/bean]

 [bean id="userSecurtyDetails"
  class="org.springframework.aop.framework.ProxyFactoryBean"]
  [property name="target"]
   [ref local="Authentication" /]
  [/property]
  [!-- property name="interceptorNames"]
   [list]
   [value]transactionInterceptor[/value]
   [/list]
   [/property --]
 [/bean]

 [!-- An access decision voter that reads AUTH_* configuration settings --]
 [bean id="roleVoter" class="org.acegisecurity.vote.RoleVoter"]
  [!-- set that this voter can only used for AUTH_ started roles! --]
 [/bean]

 [!---以下是第4级关联的类_5级------------------------------------------------]
 [bean id="userCache"
  class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache"]
  [property name="cache"]
   [ref local="userCacheBackend" /]
  [/property]
 [/bean]

 [!--我们自定义的AuthenticationProvider类实现了UserDetailsService接口,该接口由acegi提供,该接口就声明了一个抽象方法
  loadUserByUsername(String userName)throws UsernameNotFoundException, DataAccessException;该方法返回
  UserDetails类型 --]
 [bean id="Authentication"
  class="cn.com.s520.leopard.framework.authority.AuthenticationProvider"]
  [property name="userdao"]
   [ref bean="userMemberDAO" /][!-- 这里是引用外部的bean --]
  [/property]
 [/bean]

 [!---以下是第5级关联的类_6级---------------------------------------------]
 [bean id="userCacheBackend"
  class="org.springframework.cache.ehcache.EhCacheFactoryBean"]
  [property name="cacheManager"]
   [ref local="cacheManager" /]
  [/property]
  [property name="cacheName"]
   [value]userCache[/value]
  [/property]
 [/bean]

 [!---以下是第6级关联的类_7级------------------------------------------]
 [bean id="cacheManager"
  class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" /]

 [!---以下是acegi提供的工具类,以上bean暂时没用到,我放到这里--------------------------------]
 [!-- 密码加密 --]
 [bean id="passwordEncoder"
  class="org.acegisecurity.providers.encoding.Md5PasswordEncoder" /]

[/beans]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值