在Spring3中增加security与 Spring2.5有些不同,主要是MethodSecurityInterceptor和FilterSecurityInterceptor中在SPING3中有改变导致,还有就是在SPING3中,类的位置有些调整,所以需要进行修正,详细见附件!
下面把spring-security的配置放在下面,供参考:
<bean id="methodSecurityInterceptor"
class="org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor">
<property name="accessDecisionManager">
<ref bean="accessDecisionManager" />
</property>
<!-- 自行定义那些方法需要什么权限访问 -->
<property name="securityMetadataSource">
<ref bean="databaseMethodDefinitionSource" />
</property>
<!-- 定义认证 -->
<property name="authenticationManager">
<ref bean="authenticationManager" />
</property>
</bean>
<bean id="databaseMethodDefinitionSource"
class="com.cigna.cmc.spring.security.MethodFilterSecurityMetadataSource" />
<bean id="filterSecurityInterceptor"
class="org.springframework.security.web.access.intercept.FilterSecurityInterceptor">
<property name="authenticationManager" ref="authenticationManager" />
<property name="accessDecisionManager" ref="accessDecisionManager" />
<!-- 获取访问被访问的资源所需要的权限(authority) -->
<property name="securityMetadataSource" ref="UrlFilterSecurityMetadataSource" />
</bean>
<bean id="UrlFilterSecurityMetadataSource"
class="com.cigna.cmc.spring.security.UrlFilterSecurityMetadataSource">
</bean>