SignaturePropFile 的 Axis2/rampart 加密问题

发布于 2024-09-10 10:28:57 字数 2897 浏览 4 评论 0原文

我在使用必须使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

女中豪杰 2024-09-17 10:28:57

我发现我必须将 client.propertiesmn_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 and mn_keystore.ks to
wss4j-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! Now wss4j-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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文