Axis2/rampart cryptography problem with signaturePropFile

泄露秘密 提交于 2019-12-12 03:41:11

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3280693/axis2-rampart-cryptography-problem-with-signaturepropfile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!