2010-07-19 35 views
0

我必須使用WS-Security的WebService客戶端有問題。 我的客戶是用axis2寫的。當我不啓用 加密(當然與我的服務器模擬器)。我啓用了加密 通過向axis.xmlAxis2 /採用signaturePropFile的壘門密碼問題

<!--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 as File object。我試圖把這個 文件放在不同的目錄中,或者改變它的名字來使用完整路徑(當我在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 

任何想法,爲什麼我得到這個錯誤?

回答

2

我發現我必須添加client.propertiesmn_keystore.kswss4j-1.5.8.jar。我不知道這是否是設計。我的首選是從這個.jar庫中獲取這兩個文件。

編輯:在其他環境我嘗試了單獨的client.properties它的工作!現在wss4j-1.5.8.jar是原始的,沒有配置和密鑰庫。我不知道爲什麼這個工作,這沒有奏效早些時候:(

EDIT2:當Eclipse中運行的應用程序,它可能不會增加項目目錄claaspath我從加入.properies文件一些的.jar辭職現在我使用:從菜單中選擇Run-> Debug Configurations,找到您的Java應用程序及其類路徑選項卡,然後選擇「User Entries」並從右側面板點擊「Advanced」按鈕,選擇「Add External Folder」。與您的.properties文件。