我对必须使用 WS-Security 的 WebService 客户端有疑问。我的客户是用axis2
. 当我不启用加密(当然使用我的服务器模拟器)时,它可以工作。我通过添加来启用加密axis.xml
:
<!--Signature and Encryption : Using the request's certificate-->
<module ref="rampart" />
<parameter name="OutflowSecurity">
<action>
<items>Signature</items>
<user>mn</user>
<passwordCallbackClass>PWCallback</passwordCallbackClass>
<signaturePropFile>client.properties</signaturePropFile>
<signatureKeyIdentifier>SKIKeyIdentifier</signatureKeyIdentifier>
<signatureParts>{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body</signatureParts>
</action>
</parameter>
现在,当我使用参数从 Eclipse 调用客户端时:
-Daxis2.xml=axis-repo/conf/axis2.xml -Daxis2.repo=axis-repo
我有:
org.apache.axis2.AxisFault: CryptoFactory: Cannot load properties: client.properties
at org.apache.rampart.handler.WSDoAllSender.processMessage(WSDoAllSender.java:67)
at org.apache.rampart.handler.WSDoAllHandler.invoke(WSDoAllHandler.java:72)
at org.apache.axis2.engine.Phase.invoke(Phase.java:318)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:251)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:416)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
...
Caused by: java.lang.RuntimeException: CryptoFactory: Cannot load properties: client.properties
at org.apache.ws.security.components.crypto.CryptoFactory.getProperties(CryptoFactory.java:258)
at org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:171)
at org.apache.ws.security.handler.WSHandler.loadSignatureCrypto(WSHandler.java:431)
at org.apache.ws.security.handler.WSHandler.doSenderAction(WSHandler.java:137)
at org.apache.rampart.handler.WSDoAllSender.processBasic(WSDoAllSender.java:201)
at org.apache.rampart.handler.WSDoAllSender.processMessage(WSDoAllSender.java:64)
... 9 more
Caused by: java.lang.NullPointerException
at org.apache.ws.security.components.crypto.CryptoFactory.getProperties(CryptoFactory.java:253)
... 14 more
我可以client.properties
作为File
对象打开。我尝试将此文件放在各种目录中或更改其名称以使用完整路径(在 Windows 上工作时都使用斜杠和反斜杠),但没有任何帮助。
我的 client.properties 文件如下所示:
org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=jks
org.apache.ws.security.crypto.merlin.keystore.password=mn
org.apache.ws.security.crypto.merlin.file=mn_keystore.ks
知道为什么我会收到此错误吗?