有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

带有signaturePropFile的java 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对象打开。我试着把这个 文件位于不同的目录中,或将其名称更改为使用完整路径(都带有斜杠, 和反斜杠,而我的工作窗口)但没有任何帮助

我的客户。属性文件看起来像:

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

知道我为什么会犯这个错误吗


共 (1) 个答案

  1. # 1 楼答案

    我发现我必须将client.propertiesmn_keystore.ks添加到 wss4j-1.5.8.jar。我不知道这是不是故意的。我倾向于将这两个文件都从这个.jar库中取出

    编辑:在其他环境中,我尝试使用单独的client.properties并成功!现在wss4j-1.5.8.jar与原来一样,没有配置和密钥库。我不知道为什么这项工作,而这项工作在早些时候没有起作用:(

    EDIT2:当Eclipse运行应用程序时,它可能不会将项目目录添加到claaspath。我辞去了添加的职务。属性文件。现在我使用jar:从菜单中选择Run->;调试配置,找到Java应用程序及其类路径选项卡。然后选择“用户条目”并单击右侧面板中的“高级”按钮,然后选择“添加外部文件夹”。现在用.properties文件添加目录