Java Spring安全性-不会调用AccessDecisionVoter impl

Java Spring安全性-不会调用AccessDecisionVoter impl,java,spring-security,voting,Java,Spring Security,Voting,我试图创建自定义AccessDecisionVoter,并在调用它时在调试中停止它 我在每种方法中都加了一个断点,但什么都没有发生 spring-security.xml: <bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased"> <property name="decisionVoters"> <list>


我试图创建自定义AccessDecisionVoter,并在调用它时在调试中停止它

我在每种方法中都加了一个断点,但什么都没有发生

spring-security.xml:

<bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased">
  <property name="decisionVoters">
     <list>
          <bean class="com.affiliates.server.security.voters.VoterTest">
              <property name="brandsApi"  ref="brandsApi"/>
          </bean>
        </list>
  </property>
VoterTest.java(带断点的空文件)

public类VoterTest实现AccessDecisionVoter{
私人IBrandsApi brandsApi;
公共IBrandsApi getBrandsApi(){
返回brandsApi;
}
公共资源管理局(IBrandsApi brandsApi){
this.brandsApi=brandsApi;
}
@凌驾
公共布尔支持(ConfigAttribute){
System.out.println(“此处”);
返回false;
}
@凌驾
公共布尔支持(类clazz){
System.out.println(“此处”);
返回false;
}
@凌驾
公共整数投票(身份验证、对象、,
集合属性){
System.out.println(“此处”);
返回0;
}
}
顺便说一句,在应用程序加载/运行期间没有引发异常
谢谢

您需要使用自定义的AccessDecisionManager,否则将使用默认的AccessDecisionManager。你可以用它来做这个

<global-method-security access-decision-manager-ref="accessDecisionManager"/>

有关这方面的更多信息,请参阅


还有一件事:您的投票者中的
supports()
方法可能会返回
true
否则将不会调用
vote()

您有吗?是的,我可以使用annotation和@Autowire spring beans,谢谢
    public class VoterTest implements AccessDecisionVoter {
private IBrandsApi brandsApi;

    public IBrandsApi getBrandsApi() {
        return brandsApi;
    }

    public void setBrandsApi(IBrandsApi brandsApi) {
        this.brandsApi = brandsApi;
    }

        @Override
        public boolean supports(ConfigAttribute attribute) {
            System.out.println("here");
            return false;

        }

        @Override
        public boolean supports(Class<?> clazz) {
            System.out.println("here");
            return false;
        }

        @Override
        public int vote(Authentication authentication, Object object,
                Collection<ConfigAttribute> attributes) {
            System.out.println("here");
            return 0;
        }
    }
<global-method-security access-decision-manager-ref="accessDecisionManager"/>