【发布时间】: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。
【问题讨论】: