SignaturePropFile 的 Axis2/rampart 加密问题
我在使用必须使用 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
知道为什么我收到此错误吗?
I have problem with WebService client that has to use WS-Security.
My client is written with axis2
. It works when I do not enable
cryptography (of course with my server emulator). I enabled cryptography
by adding to 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>
Now, when I invoke client from Eclipse with arguments:
-Daxis2.xml=axis-repo/conf/axis2.xml -Daxis2.repo=axis-repo
I got:
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
I'm able to open client.properties
as File
object. I tried to put this
file in various directories or changed its name to use full path (both with slashes,
and backslashes while I work on Windows) but nothing helps.
My client.properties file looks like:
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
Any idea why I got this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现我必须将
client.properties
和mn_keystore.ks
添加到wss4j-1.5.8.jar
。我不知道这是否是设计使然。我的偏好是将这两个文件都放在.jar
库中。编辑:在其他环境中,我尝试使用单独的
client.properties
并且它有效!现在wss4j-1.5.8.jar
与原始版本一样,没有配置和密钥库。我不知道为什么这个可以工作,而且之前没有工作:(EDIT2:当 Eclipse 运行应用程序时,它可能不会将项目目录添加到 claaspath。我放弃了将 .properies 文件添加到某些 .jar现在我使用:从菜单中选择“运行”->“调试配置”,找到您的 Java 应用程序及其类路径选项卡,然后选择“用户条目”并单击右侧面板中的“高级”按钮,然后选择“立即添加外部文件夹”。添加包含
.properties
文件的目录。I have found that I have to add
client.properties
andmn_keystore.ks
towss4j-1.5.8.jar
. I don't know if it is by design. My preference is to have both files out of this.jar
library.EDIT: on other environment I tried with separate
client.properties
and it worked! Nowwss4j-1.5.8.jar
is as original, without configuration and keystore. I don't know why this work, and this not worked earlier :(EDIT2: when Eclipse run application it probably does not add project directory to claaspath. I resigned from adding .properies file to some .jar and now I use: from menu select Run->Debug Configurations, locate your Java application and its classpath tab. Then select "User Entries" and click the "Advanced" button from right panel, and select "Add External Folder". Now add directory with your
.properties
files.