【问题标题】:Spring SOAP WS: WssSoapFaultException implementing SimplePasswordValidationCallbackHandlerSpring SOAP WS:实现 SimplePasswordValidationCallbackHandler 的 WssSoapFaultException
【发布时间】:2021-06-28 02:53:17
【问题描述】:

我正在学习一个课程来回顾一些 Spring 概念,并且我正在尝试实现一个具有简单密码验证安全性的 SOAP WS。

我的bean配置如下

@EnableWs
@Configuration
public class WsdlConfigService extends WsConfigurerAdapter {

    // Other beans...
    
    @Bean
    public XwsSecurityInterceptor requestInterceptor() {
        XwsSecurityInterceptor interceptor = new XwsSecurityInterceptor();
        interceptor.setCallbackHandler(callbackHandler());
        interceptor.setPolicyConfiguration(new ClassPathResource("securityPolicy.xml"));
        return interceptor;
    }

    @Bean
    public SimplePasswordValidationCallbackHandler callbackHandler() { 
        SimplePasswordValidationCallbackHandler handler = new SimplePasswordValidationCallbackHandler();
        handler.setUsersMap(Collections.singletonMap("admin", "password"));
        return handler;
    }

    @Override
    public void addInterceptors(List<EndpointInterceptor> interceptors) {
        interceptors.add(requestInterceptor());
    }
}

securityPolicy.xml 配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<xwss:SecurityConfiguration xmlns:xwss="http://java.sun.com/xml/ns/xwss/config">
    <xwss:RequireUsernameToken passwordDigestRequired="false" nonceRequired="false" />
</xwss:SecurityConfiguration>

当我尝试测试端点安全性(我正在使用 Wizdler Chrome 扩展程序)时,我遇到了一个意外错误:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
            <faultcode>SOAP-ENV:Client</faultcode>
            <faultstring xml:lang="en">com.sun.xml.wss.impl.WssSoapFaultException: javax.security.auth.callback.UnsupportedCallbackException; nested exception is com.sun.xml.wss.XWSSecurityException: com.sun.xml.wss.impl.WssSoapFaultException: javax.security.auth.callback.UnsupportedCallbackException</faultstring>
        </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

在 Wizdler 界面中,由于 SimplePassWrodValidationCallbackHandler bean,我正在使用 WSSE PasswordText 身份验证。

我在这里做错了什么?我尝试使用 Spring Boot 版本 2.5.1(撰写本文时最新)和 2.4.5(课程中使用的版本)

如果您需要有关此问题的更多详细信息,请告诉我。提前感谢您的回答/cmets。

【问题讨论】:

    标签: java soap spring-ws


    【解决方案1】:

    最后我发现了错误:我使用了不正确的javax.security.auth.callback.CallbackHandler 实现:我使用的是org.springframework.ws.soap.security.wss4j2.callback.SimplePasswordValidationCallbackHandler,但正确的是org.springframework.ws.soap.security.xwss.callback.SimplePasswordValidationCallbackHandler

    这两个实现都来自 Spring 框架并且应该做同样的事情(根据文档),但由于某种原因不支持第一个。如果有人有更详细的信息,请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多