【问题标题】:Adding Spring Security @Secured annotation with the Spring Web Service disables Web Service endpoint使用 Spring Web Service 添加 Spring Security @Secured 注解会禁用 Web Service 端点
【发布时间】:2013-02-03 13:47:24
【问题描述】:

问题:当我在 Web 服务方法中添加 @Secured 注释时,端点被禁用意味着我在调用 ws 端点时得到 No endpoint mapping found 错误。

背景:我的 Spring Web Service 可以使用 UsernameToken 和 Timestamp 对消费者进行安全验证,这在我添加 @Secured 以强制执行基于角色的授权之前工作得非常好。拦截器使用 在 spring-ws-servlet.xml 中配置。 框架版本:

  • spring ws:2.0.5.RELEASE
  • spring ws 安全性:2.0.5.RELEASE
  • spring 安全性: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();
        }
    }

...

我正在使用下面的 global-method-security 来启用 @Secured 注释,如 spring 文档所述。

spring-ws-servlet.xml


...

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

....

【问题讨论】:

  • 你试过用soapaction代替payload吗?
  • 这是典型的 Spring 问题,具有 自动检测处理程序基于方面的功能,例如 @Secured@Transactional
  • 我想通了。我使用抽象类而不是接口来让@Secured 工作。

标签: authentication soap spring-security authorization spring-ws


【解决方案1】:

我遇到了同样的问题,可以用

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

【讨论】:

    猜你喜欢
    • 2020-01-26
    • 1970-01-01
    • 2016-05-25
    • 2014-08-25
    • 2021-07-08
    • 1970-01-01
    • 1970-01-01
    • 2014-03-09
    • 1970-01-01
    相关资源
    最近更新 更多