我正在尝试创建自定义 AccessDecisionVoter 并在它被调用时将其停止在调试中。
我在每种方法中都设置了一个断点,但没有发生任何事情。
弹簧安全.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>
IBrandsApi.java
public interface IBrandsApi {
IHibernateBean getByPK(Integer id);
@Secured({ "ROLE_BRAND_ADMIN" })
IHibernateBean update(IHibernateBean brand);
@Secured({ "ROLE_BRAND_ADMIN" })
IHibernateBean insert(IHibernateBean brand);
@Secured({ "ROLE_BRAND_ADMIN" })
ResultContainer getAll(IFilter filter);
@Secured({ "ROLE_ADMIN" })
Integer delete(IFilter filter);
}
VoterTest.java(带断点的空文件)
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;
}
}
顺便说一句,在应用程序加载/运行期间没有抛出异常谢谢