在SpringWebService中添加SpringSecurity@Secured注释将禁用Web服务端点



问题:当我在web服务方法中添加@Secured注释时,端点被禁用意味着我在调用ws端点时出现未找到端点映射错误

背景:我的Spring Web服务是安全的,可以使用UsernameToken和Timestamp对消费者进行身份验证,这在我添加@secured以强制执行基于角色的授权之前是绝对有效的。拦截器在spring-ws-servlet.xml中使用<sws:interceptors>。框架版本:

  • springws:2.0.5版本
  • spring ws-security:2.0.5.版本
  • 弹簧安全:3.0.7.RELEASE
  • wss4j:1.5.12

这是我尝试做的事情的样本。

终点:


...
    @Endpoint
    public class XYZEndpoint implements XYZService{
        @Override
        @PayloadRoot(localPart = XYZ_REQUEST, namespace = NAMESPACE_XYZ)
        //@Secured({"ROLE_XYZ"})
        public XYZResponse produceXYZ(XYZRequest request) {
                    ...
            return new XYZResponse();
        }
    }
...

我使用下面的全局方法安全性来启用@securited注释,如spring文档所述。

spring-ws-servlet.xml


...
    <security:global-method-security secured-annotations="enabled" />
....

我遇到了同样的问题,能够用解决它

<security:global-method-security proxy-target-class="true" secured-annotations="enabled"/> 

最新更新