---
title: "Acegi配置(转)"
author: "yefei"
date: "2010-07-30T15:14:37Z"
tags: []
categories: ["企业架构"]
slug: "acegi"
draft: false
lastmod: "2010-07-30T15:23:34Z"
id: 725454
url: "https://yefei.iteye.com/blog/725454"
---

Acegi配置(转)

2010-07-30 18:51

1.Acegi认证与授权  
1.1在Web.xml中添加  
    &lt;!--acegi 的filter链代理--&gt;  
    &lt;filter&gt;  
        &lt;filter-name&gt;Acegi Filter Chain Proxy&lt;/filter-name&gt;  
        &lt;filter-class&gt;org.acegisecurity.util.FilterToBeanProxy&lt;/filter-class&gt;  
        &lt;init-param&gt;  
            &lt;param-name&gt;targetClass&lt;/param-name&gt;  
            &lt;param-value&gt;org.acegisecurity.util.FilterChainProxy&lt;/param-value&gt;  
        &lt;/init-param&gt;  
    &lt;/filter&gt;  
    &lt;filter-mapping&gt;  
        &lt;filter-name&gt;Acegi Filter Chain Proxy&lt;/filter-name&gt;  
        &lt;url-pattern&gt;/\*&lt;/url-pattern&gt;  
    &lt;/filter-mapping&gt;  
1.2bookstore对每个Component都有单独的配置。这里也参照它的结构，把Acegi的配置文件放在bookstoredemo/src /java/org/springside/bookstoredemo/components/acegi目录下，取名 applicationContext-acegi-security.xml，并在bookstoredemo/src/resources /spring目录下新建applicationContext-components.xml文件，内容如下：  
&lt;?xml version="1.0" encoding="UTF-8"?&gt;  
&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"&gt;  
&lt;beans&gt;  
    &lt;!-- Acegi --&gt;  
    &lt;import resource="classpath:org/springside/bookstoredemo/components/acegi/applicationContext-acegi-security.xml"/&gt;  
&lt;/beans&gt;  
1.3在applicationContext-acegi-security.xml中添加刚才在Web.xml文件中声明的org.acegisecurity.util.FilterChainPrxy:  
    &lt;bean id="filterChainProxy"  
        class="org.acegisecurity.util.FilterChainProxy"&gt;  
        &lt;property name="filterInvocationDefinitionSource"&gt;  
            &lt;value&gt;  
                CONVERT\_URL\_TO\_LOWERCASE\_BEFORE\_COMPARISON  
                PATTERN\_TYPE\_APACHE\_ANT  
                /\*\*=httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor  
            &lt;/value&gt;  
        &lt;/property&gt;  
    &lt;/bean&gt;  
这个bean它主要是装载filterInvocationDefinitionSource指定的filter类，并顺序调用它们的doFilter方法，进行安全服务处理。这个bean总共声明了8个filter。

1.4顺序添加httpSessionContextIntegrationFilter:  
    &lt;bean id="httpSessionContextIntegrationFilter"  
        class="org.acegisecurity.context.HttpSessionContextIntegrationFilter"/&gt;  
这个bean负责每次请求从HttpSession中获取Authentication对象,然后把Authentication存于一个新的 ContextHolder对象(其实质上只是一个ThreadLocal对象)中,则让该次请求过程中的任何Filter都可以通过 ContextHolder来共享Authentication,而不需要从HttpSession中取,减少传HttpRequest参数的麻烦.在请求完后把Authentication对象保存到HttpSession中供下次请求使用,最后把刚才生成的ContextHolder对象销毁.这样就达到了让Authentication对象跨越多个请求的目的.注意此filter须在调用其他Acegi filter前使用  
1.5顺序添加logoutFilter：  
    &lt;!-- 注销处理filter --&gt;  
    &lt;bean id="logoutFilter"  
        class="org.acegisecurity.ui.logout.LogoutFilter"&gt;  
        &lt;constructor-arg value="/shop/index.do"/&gt;  
        &lt;!-- URL redirected to after logout --&gt;  
        &lt;constructor-arg&gt;  
            &lt;list&gt;  
                &lt;ref bean="rememberMeServices"/&gt;  
                &lt;bean  
                        class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler"/&gt;  
            &lt;/list&gt;  
        &lt;/constructor-arg&gt;  
    &lt;/bean&gt;  
这个bean负责处理退出登录后所需要的清理工作。它会把session销毁,把ContextHolder清空， 把rememberMeServices从cookies中清除掉，然后重定向到指定的退出登陆页面。

1.6顺序添加authenticationProcessingFilter  
    &lt;!-- 表单认证处理filter --&gt;  
    &lt;bean id="authenticationProcessingFilter"  
        class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter"&gt;  
        &lt;property name="authenticationManager"  
                ref="authenticationManager"/&gt;  
        &lt;property name="authenticationFailureUrl"  
                value="/acegilogin.jsp?login\_error=1"/&gt;  
        &lt;property name="defaultTargetUrl" value="/admin/index.jsp"/&gt;  
        &lt;property name="filterProcessesUrl"  
                value="/j\_acegi\_security\_check"/&gt;  
        &lt;property name="rememberMeServices" ref="rememberMeServices"/&gt;  
    &lt;/bean&gt;  
这个bean处理一个认证表单,登陆用的表单必须提交用户名和密码这两个参数给这个filter.由用户名和密码构造一个 UsernamePasswordAuthenticationToken，将传给AuthenticationManager的 authenticate方法进行认证处理。该filter默认处理filterProcessesUrl属性指定的URL，认证失败会转到 authenticationFailureUrl，认证成功会转到defaultTargetUrl页面。

1.7顺序添加securityContextHolderAwareRequestFilter  
    &lt;bean id="securityContextHolderAwareRequestFilter"  
        class="org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter"/&gt;  
这个bean保存当前的请求到SavedRequest，并存入Session，然后转到登录页。

1.8顺序添加rememberMeProcessingFilter  
    &lt;bean id="rememberMeProcessingFilter"  
        class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter"&gt;  
        &lt;property name="authenticationManager"  
                ref="authenticationManager"/&gt;  
        &lt;property name="rememberMeServices" ref="rememberMeServices"/&gt;  
    &lt;/bean&gt;  
这个bean以cookie的形式来保存认证信息。负责在用户登录后在本地机上记录用户cookies信息，免除下次再次登陆。检查 AuthenticationManager 中是否已存在Authentication对象，如果不存在则会调用RememberMeServices的aotoLogin方法来从cookies中获取Authentication对象。

1.9顺序添加nonymousProcessingFilter  
    &lt;bean id="anonymousProcessingFilter"  
        class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter"&gt;  
        &lt;property name="key" value="changeThis"/&gt;  
        &lt;property name="userAttribute"  
                value="anonymousUser,ROLE\_ANONYMOUS"/&gt;  
    &lt;/bean&gt;  
这个bean负责为当不存在任何授权信息时，自动为Authentication对象添加userAttribute中定义的匿名用户权限

1.10顺序添加exceptionTranslationFilter  
    &lt;bean id="exceptionTranslationFilter"  
        class="org.acegisecurity.ui.ExceptionTranslationFilter"&gt;  
        &lt;property name="authenticationEntryPoint"&gt;  
            &lt;bean  
                    class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint"&gt;  
                &lt;property name="loginFormUrl" value="/acegilogin.jsp"/&gt;  
                &lt;property name="forceHttps" value="false"/&gt;  
            &lt;/bean&gt;  
        &lt;/property&gt;  
        &lt;property name="accessDeniedHandler"&gt;  
            &lt;bean  
                    class="org.acegisecurity.ui.AccessDeniedHandlerImpl"&gt;  
                &lt;property name="errorPage" value="/accessDenied.jsp"/&gt;  
            &lt;/bean&gt;  
        &lt;/property&gt;  
    &lt;/bean&gt;  
这个bean负责处理各种异常，然后重定向到相应的页面中。

1.11顺序添加filterInvocationInterceptor  
    &lt;bean id="filterInvocationInterceptor"  
        class="org.acegisecurity.intercept.web.FilterSecurityInterceptor"&gt;  
        &lt;property name="authenticationManager"  
                ref="authenticationManager"/&gt;  
        &lt;property name="accessDecisionManager"&gt;  
            &lt;bean class="org.acegisecurity.vote.AffirmativeBased"&gt;  
                &lt;property name="allowIfAllAbstainDecisions"  
                        value="false"/&gt;  
                &lt;property name="decisionVoters"&gt;  
                    &lt;list&gt;  
                        &lt;bean class="org.acegisecurity.vote.RoleVoter"/&gt;  
                        &lt;bean  
                                class="org.acegisecurity.vote.AuthenticatedVoter"/&gt;  
                    &lt;/list&gt;  
                &lt;/property&gt;  
            &lt;/bean&gt;  
        &lt;/property&gt;  
        &lt;property name="objectDefinitionSource"  
                ref="filterDefinitionSource"/&gt;  
    &lt;/bean&gt;  
这个bean会首先调用AuthenticationManager判断用户是否已登陆认证,如还没认证成功,则重定向到登陆界面.认证成功,则从 Authentication中获取用户的权限.然后从objectDefinitionSource属性获取各种URL资源所对应的权限.最后调用 AccessDecisionManager来判断用户所拥有的权限与当前受保护的URL资源所对应的权限是否相匹配.如果匹配失败,则返回403错误给用户.匹配成功则用户可以访问受保护的URL资源

1.12至此，我们在1.3中所声明的8个Filter全部装载完成。试运行，会提示找不到rememberMeServices，这个rememberMeServices在1.6和1.8中声明，添加rememberMeServices：  
    &lt;bean id="rememberMeServices"  
        class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices"&gt;  
        &lt;property name="userDetailsService" ref="userDetailsService"/&gt;  
        &lt;property name="key" value="changeThis"/&gt;  
    &lt;/bean&gt;  
这个bean负责通过以cookie的形式保存先前的用户登录信息。在Authentication对象不存在时， rememberMeProcessingFilter会调用rememberMeServices的autoLogin()方法，尝试在cookie中获取用户登录信息，如果存在则并返回Authentication对象。在每次用户登录时，如果设置了RememberMe功能，在验证用户身份成功后，则会调用loginSuccess()方法记录用户信息在cookie中，否则调用loginFail()方法清除cookie。

1.13为1.12添加userDetailsService:  
    &lt;bean id="userDetailsService"  
        class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl"&gt;  
        &lt;property name="dataSource" ref="dataSource"/&gt;  
        &lt;property name="usersByUsernameQuery"&gt;  
            &lt;value&gt;  
                select loginid,passwd,1 from ss\_users where status='1'  
                and loginid = ?  
            &lt;/value&gt;  
        &lt;/property&gt;  
        &lt;property name="authoritiesByUsernameQuery"&gt;  
            &lt;value&gt;  
                select u.loginid,r.name from ss\_users u,ss\_roles r,ss\_user\_role ur  
                where u.id=ur.user\_id and r.id=ur.role\_id and u.status='1'  
                and u.loginid=?  
            &lt;/value&gt;  
        &lt;/property&gt;  
    &lt;/bean&gt;

1.14为1.11添加authenticationManager：  
    &lt;bean id="authenticationManager"  
        class="org.acegisecurity.providers.ProviderManager"&gt;  
        &lt;property name="providers"&gt;  
            &lt;list&gt;  
                &lt;ref local="daoAuthenticationProvider"/&gt;  
                &lt;bean  
                        class="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider"&gt;  
                    &lt;property name="key" value="changeThis"/&gt;  
                &lt;/bean&gt;  
                &lt;bean  
                        class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider"&gt;  
                    &lt;property name="key" value="changeThis"/&gt;  
                &lt;/bean&gt;  
            &lt;/list&gt;  
        &lt;/property&gt;  
    &lt;/bean&gt;  
AuthenticationManager的其中一个实现是ProviderManager,它负责把身份验证的工作委托给一个或多个Provider(认证提供者).  
Provider都是实现AuthenticationProvider接口,该接口有两个方法authenticate()和support(). authenticate()方法会尝试验证用户身份,若验证成功则返回一个Authentication对象,否则抛出一个 AuthenticationException.  
support()方法会评估当前Authentication对象是否适合这个Provider来进行进一步的处理,而不是指已经通过.  
Provir有多个实现.例如daoAuthenticationProvider,anonymousAuthenticationProvider,rememberMeAuthenticationProvider.

1.15添加daoAuthenticationProvide：  
    &lt;bean id="daoAuthenticationProvider"  
        class="org.acegisecurity.providers.dao.DaoAuthenticationProvider"&gt;  
        &lt;property name="userDetailsService" ref="userDetailsService"/&gt;  
        &lt;property name="userCache" ref="userCache"/&gt;  
        &lt;property name="passwordEncoder" ref="passwordEncoder"/&gt;  
    &lt;/bean&gt;  
daoAuthenticationProvider负责提供用户信息，包括用户名和密码。其中取用户名密码的工作就交给 userDetailsService来做。通过userCache来缓存用户信息，减少查询数据库次数。用passwordEncoder来使用加密密码。userDetailsService的接口实现有jdbcDaoImpl和inMemoryDaoImpl。jdbcDaoImpl通过数据库获取用户名和密码，而inMemoryDaoImpl则只是通过xml定义的方式来获取。  
userCache的接口实现有EhCacheBasedUserCache和NullUserCache。NullUserCache实际上就是不进行缓存。EhCacheBasedUserCache是基于ehcache的开源缓存项目来实现的。  
passwordEncoder是使用加密器对用户输入的明文进行加密。Acegi提供了三种加密器:  
PlaintextPasswordEncoder---默认，不加密，返回明文.  
ShaPasswordEncoder---哈希算法(SHA)加密  
d5PasswordEncoder---消息摘要(MD5)加密

1.16添加userCache：  
    &lt;bean name="userCache" class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache"&gt;  
        &lt;property name="cache"&gt;  
            &lt;bean  
                    class="org.springframework.cache.ehcache.EhCacheFactoryBean" autowire="byName"&gt;  
                &lt;property name="cacheManager" ref="cacheManager"/&gt;  
                &lt;property name="cacheName" value="userCache"/&gt;  
            &lt;/bean&gt;  
        &lt;/property&gt;  
    &lt;/bean&gt;

1.17添加cacheManager：  
    &lt;bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"&gt;  
        &lt;property name="configLocation"&gt;  
            &lt;value&gt;classpath:org/springside/bookstoredemo/components/acegi/ehcache.xml&lt;/value&gt;  
        &lt;/property&gt;  
    &lt;/bean&gt;

1.18添加bookstoredemo/arc/java/org/springside/bookstoredemo/components/acegi/ehcache.xml，内容参照源代码。  
1.19添加passwordEncoder：  
    &lt;!-- 使用Md5算法加密 --&gt;  
    &lt;bean id="passwordEncoder"  
        class="org.acegisecurity.providers.encoding.Md5PasswordEncoder"/&gt;

1.20添加filterDefinitionSource  
    &lt;bean id="filterDefinitionSource"  
        class="org.springside.bookstoredemo.components.acegi.intercept.web.DBFilterInvocationDefinitionSource"&gt;  
        &lt;property name="convertUrlToLowercaseBeforeComparison"  
                value="true"/&gt;  
        &lt;property name="useAntPath" value="true"/&gt;  
        &lt;property name="acegiCacheManager" ref="acegiCacheManager"/&gt;  
    &lt;/bean&gt;

1.21添加  
org.springside.bookstoredemo.components.acegi.domain.Resource;  
org.springside.bookstoredemo.components.acegi.domain.Role;  
org.springside.bookstoredemo.components.acegi.domain.User;  
org.springside.bookstoredemo.components.acegi.resourcedetails.Resourceimport org.springside.bookstoredemo.components.acegi.Constants;  
org.springside.bookstoredemo.components.acegi.resourcedetails.ResourceCache;  
org.springside.bookstoredemo.components.acegi.cache.AcegiCacheManager;  
org.springside.bookstoredemo.components.acegi.resourcedetails.ResourceDetails;  
org.springside.bookstoredemo.components.acegi.intercept.web.DBFilterInvocationDefinitionSource.java;  
添加  
org.springside.bookstoredemo.components.acegi.domain.hbm.Resource.hbm.xml;  
org.springside.bookstoredemo.components.acegi.domain.hbm.Role.hbm.xml;  
org.springside.bookstoredemo.components.acegi.domain.hbm.Role.hbm.xml;  
这几个文件稍稍改下class的映射地址  
在dataAccessContext-hibernate.xml中合适地方添加  
        &lt;property name="mappingDirectoryLocations"&gt;  
            &lt;list&gt;  
                &lt;value&gt;  
                    classpath\*:/org/springside/bookstoredemo/components/acegi/domain/hbm/  
                &lt;/value&gt;  
            &lt;/list&gt;  
        &lt;/property&gt;

1.22添加acegiCacheManager  
    &lt;bean id="acegiCacheManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"  
        abstract="false" autowire="byName"&gt;  
        &lt;property name="transactionManager" ref="transactionManager"/&gt;  
        &lt;property name="proxyTargetClass" value="true"/&gt;  
        &lt;property name="target"&gt;  
            &lt;bean class="org.springside.bookstoredemo.components.acegi.cache.AcegiCacheManagerImpl"&gt;  
                &lt;property name="resourceCache" ref="resourceCache"&gt;&lt;/property&gt;  
                &lt;property name="userCache" ref="userCache"&gt;&lt;/property&gt;  
                &lt;property name="sessionFactory" ref="sessionFactory"&gt;&lt;/property&gt;  
            &lt;/bean&gt;  
        &lt;/property&gt;  
        &lt;property name="transactionAttributes"&gt;  
            &lt;props&gt;  
                &lt;prop key="modify\*"&gt;PROPAGATION\_REQUIRED&lt;/prop&gt;  
                &lt;prop key="auth\*"&gt;PROPAGATION\_REQUIRED&lt;/prop&gt;  
                &lt;prop key="init\*"&gt;PROPAGATION\_REQUIRED,readOnly&lt;/prop&gt;  
                &lt;prop key="refresh\*"&gt;PROPAGATION\_REQUIRED,readOnly&lt;/prop&gt;  
                &lt;prop key="get\*"&gt;PROPAGATION\_REQUIRED,readOnly&lt;/prop&gt;  
            &lt;/props&gt;  
        &lt;/property&gt;  
    &lt;/bean&gt;

1.23添加resourceCache  
    &lt;!-- 自建一个resourceCache以存放resource对应的role关系 --&gt;  
    &lt;!--  
        resource缓存实际执行对象  
    --&gt;  
    &lt;bean id="resourceCache"  
        class="org.springside.bookstoredemo.components.acegi.resourcedetails.ResourceCache"  
        autowire="byName"&gt;  
        &lt;property name="cache"&gt;  
            &lt;bean id="resourceCacheBackend"  
                class="org.springframework.cache.ehcache.EhCacheFactoryBean"&gt;  
                &lt;property name="cacheManager" ref="cacheManager"/&gt;  
                &lt;property name="cacheName" value="resourceCache"/&gt;  
            &lt;/bean&gt;  
        &lt;/property&gt;  
    &lt;/bean&gt;

1.24添加loggerListener  
    &lt;!-- This bean is optional; it isn't used by any other bean as it only listens and logs --&gt;  
    &lt;bean id="loggerListener"  
        class="org.acegisecurity.event.authentication.LoggerListener"/&gt;

1.25打开浏览器，输入http://localhost:8080/bookstoredemo/admin/，提示404错误。我们在webapp 目录下新建文件acegilogin.jsp，并把bookstore例子中的文件内容拷贝过来，再访问http://localhost: 8080/bookstoredemo/admin/，会打开acegilogin,jsp页面，这个页面用来供用户登录。我们先看看Acegi是如何转到这个登录页面的：首先浏览器发送http://localhost:8080/bookstoredemo/admin/请求，调用 httpSessionContextIntegrationFilter，从HttpSession中获取Authentication对象,然后把 Authentication存于一个新的ContextHolder对象。因为没有Authentication信息，Acegi转到异常处理 Filter(1.10声明)，并转向到loginFormUrl。

1.26登录失败的流程  
    1.26.1用户不存在  
    用户输入错误的用户名或密码，Acegi会转到表单认证Filter(1.6中声明)，转向到authenticationFailureUrl；  
    1.26.2用户没有权限  
    用户登录信息正确，Acegi通过系列数据库查询，会得出用户没有任何权限，Acegi会通过/j\_acegi\_security\_check自动转向到/accessDenied.jsp。  
1.26登录成功的流程  
    用户登录信息正确，Acegi通过系列数据库查询，得到用户admin对/admin/下的所有请求都有权限(可以自行分析数据库的数据)。Acegi转到表单认证，转向到defaultTargetUrl。

1.27登出流程  
    用户登出，如果没有声明注销处理Filter(1.5中声明),会清除登录信息，并最终重定向到/j\_acegi\_logout上，而如果声明了注销处理，则重定向到constructor-arg的Value上

1.28需要注意的几点  
登录用户名和密码必须是j\_username,j\_password;/j\_acegi\_logout;/j\_acegi\_security\_check.

另外，还有几个重要的拦截器和组件:  
1.29  
    &lt;bean id="securityInterceptor"  
        class="org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor"&gt;  
        &lt;property name="validateConfigAttributes"&gt;  
            &lt;value&gt;false&lt;/value&gt;  
        &lt;/property&gt;  
        &lt;property name="authenticationManager"&gt;  
            &lt;ref local="authenticationManager" /&gt;  
        &lt;/property&gt;  
        &lt;property name="accessDecisionManager"&gt;  
            &lt;ref local="accessDecisionManager" /&gt;  
        &lt;/property&gt;  
        &lt;property name="runAsManager"&gt;  
            &lt;ref local="runAsManager" /&gt;  
        &lt;/property&gt;  
        &lt;property name="objectDefinitionSource"&gt;  
            &lt;value&gt;  
                sample.contact.ContactManager.create=ROLE\_USER  
                sample.contact.ContactManager.getAllRecipients=ROLE\_ADMIN  
            &lt;/value&gt;  
        &lt;/property&gt;  
    &lt;/bean&gt;  
MethodSecurityInterceptor实现了org.aopalliance.intercept.MethodInterceptor接口.在方法被调用之前,拦截器会先调用AuthenticationManager判断用户身份是否已验证,然后从 objectDefinitionSource中获取方法所应用的权限,再调用AccessDecisionManager来匹配用户权限和方法对应的权限.如果用户没有足够权限调用当前方法,则抛出AccessDeniedException是方法不能被调用.调用runAsManager,使在调用方法前动态改变authentication中获取用户权限.  
1.30  
    &lt;bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"&gt;  
        &lt;property name="proxyTargetClass" value="true" /&gt;  
        &lt;property name="interceptorNames"&gt;  
            &lt;list&gt;  
                &lt;idref local="securityInterceptor" /&gt;  
            &lt;/list&gt;  
        &lt;/property&gt;  
        &lt;property name="beanNames"&gt;  
            &lt;list&gt;  
                &lt;idref bean="userManager"/&gt;  
                &lt;idref bean="roleManager"/&gt;  
                &lt;idref bean="rescManager"/&gt;  
            &lt;/list&gt;  
        &lt;/property&gt;  
    &lt;/bean&gt;  
1.31  
BeanNameAutoProxyCreator  
设置AOP代理的最简单方法就是用Spring的BeanNameAutoProxyCreator.在BeanNameAutoProxyCreator中选出你所需要的interceptor,和列出你所需要保护的Bean.  
    &lt;bean id="accessDecisionManager" class="org.acegisecurity.vote.UnanimousBased"&gt;  
        &lt;property name="allowIfAllAbstainDecisions"&gt;  
            &lt;value&gt;false&lt;/value&gt;  
        &lt;/property&gt;  
        &lt;property name="decisionVoters"&gt;  
            &lt;list&gt;  
                &lt;ref local="roleVoter" /&gt;  
            &lt;/list&gt;  
        &lt;/property&gt;  
    &lt;/bean&gt;