我的SOAP服务器正在接收SOAP消息,其中必须理解标头设置为1.
为了理解我正在使用wss4j拦截器的标题。
我的sign.properties文件是:
org.apache.ws.security.crypto.provider=org.apache.wss4j.common.crypto.Merlin
org.apache.ws.security.crypto.merlin.truststore.type=jks
org.apache.ws.security.crypto.merlin.truststore.password=changeit
org.apache.ws.security.crypto.merlin.truststore.file=keystore/truststore.jks
我的端点xml:
<jaxws:inInterceptors>
<bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="Timestamp Signature"/>
<entry key="signaturePropFile" value="XXXXXX/WEB-INF/classes/etc/sign.properties"/>
<entry key="passwordCallbackClass" value="XX.XX.XX.XXXXXX.lifecycleapp.UTPasswordCallback"/>
</map>
</constructor-arg>
</bean>
</jaxws:inInterceptors>
但是我收到错误&#34; org.apache.wss4j.common.ext.WSSecurityException:没有提供加密属性文件来验证签名&#34;
我假设它是一个简单的事情,如果没有正确地解决signaturePropFile,但我尝试给出完整的文件路径但是返回了相同的结果。
非常感谢任何帮助。
答案 0 :(得分:3)
首先启用DEBUG / FINE日志记录。它会准确地告诉你问题是什么......可能它无法加载你给出的路径。我建议尝试以下方法:
<entry key="signaturePropFile" value="classes/etc/sign.properties"/>
科尔姆。
答案 1 :(得分:1)
这件事发生在我身上,因为我试图使用HashMap
代替Properties
地图。
即代替以下
Map<String, Object> outProps = new HashMap<>(7);
outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.SIGNATURE);
outProps.put(WSHandlerConstants.USER, CLIENT_SSL_CERT_ALIAS);
outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new ClientPasswordCallback(privateKeyPassword));
outProps.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
outProps.put(WSHandlerConstants.SIGNATURE_PARTS, "{Element}{" + "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" + "}Timestamp");
Properties signingCryptProperties = new Properties();
// Reference: http://camel.465427.n5.nabble.com/Dynamically-set-WSS4J-interceptor-properties-td5551391.html
signingCryptProperties.put("org.apache.ws.security.crypto.provider", "org.apache.ws.security.components.crypto.Merlin");
signingCryptProperties.put("org.apache.ws.security.crypto.merlin.keystore.password", keystorePassword);
signingCryptProperties.put("org.apache.ws.security.crypto.merlin.keystore.file", "client.jks");
signingCryptProperties.put("org.apache.ws.security.crypto.merlin.keystore.type", "JKS");
outProps.put(SIG_PROP_REF_ID, signingCryptProperties);
outProps.put(WSHandlerConstants.SIG_PROP_REF_ID, SIG_PROP_REF_ID);
WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
我曾尝试将signingCryptProperties
设为HashMap
像这样
Map<String, String> signingCryptProperties = new HashMap<String, String>()
导致WSSecurityEngine: No crypto property file supplied to verify signature
WSSEcurityException