【问题标题】:Axis2/rampart cryptography problem with signaturePropFilesignaturePropFile 的 Axis2/rampart 加密问题
【发布时间】:2011-03-17 21:05:42
【问题描述】:

我对必须使用 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

知道为什么会出现这个错误吗?

【问题讨论】:

    标签: java web-services axis2 ws-security rampart


    【解决方案1】:

    我发现我必须将client.propertiesmn_keystore.ks 添加到 wss4j-1.5.8.jar。我不知道这是否是设计使然。我的偏好是将这两个文件都放在这个 .jar 库中。

    编辑:在其他环境中,我尝试使用单独的client.properties 并且成功了!现在wss4j-1.5.8.jar 和原来一样,没有配置和密钥库。我不知道为什么这行得通,而且这在以前没有用:(

    EDIT2:当 Eclipse 运行应用程序时,它可能不会将项目目录添加到 claaspath。我放弃了将 .properies 文件添加到一些 .jar 中,现在我使用:从菜单中选择 Run->Debug Configurations,找到您的 Java 应用程序及其类路径选项卡。然后选择“用户条目”并单击右侧面板中的“高级”按钮,然后选择“添加外部文件夹”。现在添加包含 .properties 文件的目录。

    【讨论】:

      猜你喜欢
      • 2011-09-15
      • 2011-12-05
      • 2011-07-02
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 2019-04-10
      • 2015-02-01
      相关资源
      最近更新 更多