我需要验证一个签名的SOAP消息,提取证书,并根据LDAP目录对证书进行身份验证,这使得信任存储变得不必要。现在我已经使用了WSS4J一段时间了,但是总是使用本地的信任商店。查看一下正式文档并搜索一下,我找不到任何类似于我的场景的参考。我想知道在这种情况下是否可以继续使用WSS4J。
发布于 2017-11-22 09:49:50
是的,您可以在这个用例中使用WSS4J。在签署证书时,WSS4J默认使用SignatureTrustValidator来验证信任:
您可以通过以下方法将自己的实现插入其中:
如果您在WSS4J中使用CXF,则可以设置一个自定义配置常量,该常量指向Validator实现以获得签名。
发布于 2018-11-14 00:27:00
我也面临着同样的问题,并以这样的方式解决了它:
@EnableWs
@Configuration
public class WsConfiguration extends WsConfigurerAdapter {
@Bean
public Wss4jSecurityInterceptor securityInterceptor() throws Exception {
Wss4jSecurityInterceptor securityInterceptor = new Wss4jSecurityInterceptor();
securityInterceptor.setValidationActions("Signature");
WSSConfig wssConfig = WSSConfig.getNewInstance();
wssConfig.setValidator(new QName("http://www.w3.org/2000/09/xmldsig#", "Signature"), MySignatureTrustValidator.class);
securityInterceptor.setWssConfig(wssConfig);
//the rest of configuration
}注意,MySignatureTrustValidator必须实现Validator
https://stackoverflow.com/questions/47419704
复制相似问题