spring security中method的权限控制

在SPRING SECURITY中,当用户登陆成功后,会将该用户的权限放到Authentication对象中,而资源的控制权限定义是通过org.springframework.security.intercept.method.aopalliance.MethodSecurityInterceptor来进行的,该类通过设置objectDefinitionSource将资源和资源需要的权限获取到,通过accessDecisionManager来设置决策机制,这里通过org.springframework.security.vote.AuthenticatedVoter
根据Authentication对象中的权限和资源的权限进行比较,来判断该用户是否可以访问该方法,当与CXF进行结合时,主要是将用户认证放入到Authentication对象中,这个在CXF中可以通过org.springframework.ws.soap.security.wss4j.callback.SpringPlainTextPasswordValidationCallbackHandler进行注入,这样完整的WEBSERVICE认证和方法的资源控制就完成了!

<bean id="acegiHandler"
class="org.springframework.ws.soap.security.wss4j.callback.SpringPlainTextPasswordValidationCallbackHandler">
<property name="authenticationManager">
<ref bean="authenticationManager" />
</property>
</bean>

<aop:config>
<aop:pointcut id="securityPointcut"
expression="execution(** com.cigna.smsplatform.service..*.*(..))" />
<aop:advisor advice-ref="methodSecurityInterceptor"
pointcut-ref="securityPointcut" order="0" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="securityPointcut"
order="1" />

</aop:config>

<bean
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<value>baSendAlertTaskService</value>
</property>
<property name="interceptorNames">
<list>
<value>methodSecurityInterceptor</value>
</list>
</property>
</bean>

附件是从JAVAEYE中获取到的代码!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值