问题描述
我正在尝试从需要在Keystore中使用数字证书(JKS)来授权肥皂请求的服务器中获取数据,除此之外,它还需要使用WSS传出配置进行基本授权。这些图像显示了我在SoapUI上成功测试Web服务所遵循的步骤。
下面的图像1和图像2显示了WS-Security配置(传出WS-Security配置)。图像1添加了时间戳记条目,图像2签名配置添加了密钥库(keystore.jks),密码和其他一些配置,以及正文和时间戳记的额外部分。
图像3集成了先前步骤中用于传出请求的WS-Security配置。
按照上述步骤完成的Soap UI请求。现在的要求是以编程方式实现这一目标。不幸的是,我的尝试没有成功。
任何人都可以指导我完成Spring Web服务中的这些步骤,或者向我推荐其他任何库(使用Java或PHP或任何其他语言)以连接到具有相似安全性的SOAP服务器。
以下是我尝试将Spring WS与Wss4j一起使用的代码段。
@Configuration
public class SoapClientConfig extends WsConfigurerAdapter {
@Bean
public Wss4jSecurityInterceptor securityInterceptor() throws Exception {
Wss4jSecurityInterceptor securityInterceptor = new Wss4jSecurityInterceptor();
securityInterceptor.setSecurementActions("Signature Timestamp");
securityInterceptor.setSecurementTimetoLive(300000);
securityInterceptor.setTimestampPrecisionInMilliseconds(true);
securityInterceptor.setSecurementUsername("key-alias");
securityInterceptor.setSecurementPassword("password");
securityInterceptor.setSecurementSignatureCrypto(getCryptofactorybean().getobject());
securityInterceptor.setSecurementSignatureKeyIdentifier("DirectReference");
securityInterceptor.setSecurementSignatureAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
securityInterceptor.setSecurementSignatureDigestAlgorithm("http://www.w3.org/2001/04/xmlenc#sha256");
securityInterceptor.setSecurementMustUnderstand(true);
securityInterceptor.setSecurementSignatureParts("{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body;{Content}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp");
return securityInterceptor;
}
@Bean
public Cryptofactorybean getCryptofactorybean() throws IOException {
Cryptofactorybean cryptofactorybean = new Cryptofactorybean();
cryptofactorybean.setKeyStorePassword("password");
cryptofactorybean.setKeyStoreLocation(new ClassPathResource("keystore.jks"));
return cryptofactorybean;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)