2010-09-20 55 views
3

我正在嘗試使用Apache CXF編寫「Secure Hello World」Web服務;我應該注意到,我對Java和WS- *有點新鮮。使用Apache CXF對SOAP消息進行簽名和加密

基本上,我想要做的是一個hello-world Web服務,帶有soap消息,並從此web服務使用x.509證書進行簽名和加密。

我已經閱讀the tutorial on Apache CXF site about WS-Security但是;我想使用WS-SecurityPolicy而不是攔截器。

任何人都可以指向正確的方向嗎?

回答

0

由於Web服務通過HTTP工作,因此可以使用HTTPS協議保護它們。

這是一種資源,可以幫助一點,你在正確的方向:Using JAX-WS-Based Web Services with SSL

雖然這個資源是JAX-WS,你會發現,它的很多將結轉到Apache CXF。

乾杯。

4

下面是關於使用Apache CXF與細節博客:Adding X.509 security headers to Apache CXF SOAP calls (WS-SecurityPolicy method)

此外,還有一個tutorial與配置爲使用WS-安全法源代碼。

編輯:修復斷開的鏈接,添加到教程的鏈接。

現在有關於CXF site上的WS-SecurityPolicy的各種設置的良好概述,並且它引用了上面的鏈接。

簡而言之(如果鏈接再次被刪除),WS-SecurityPolicy的配置與CXF wiki上描述的CXF interceptor method類似,只是在cxf.xml和cxf-servlet.xml中進行了一些更改:

cxf.xml

<jaxws:client name="{http://myport" createdFromAPI="true"> 
      <!-- You will need to add the corresponding values to a properties file --> 
      <jaxws:properties> 
       <entry key="ws-security.callback-handler" value="client.ClientKeystorePasswordCallback"/>   
       <entry key="ws-security.encryption.properties" value=keystore.properties"/> 
       <entry key="ws-security.signature.properties" value="keystore.properties"/> 
       <entry key="ws-security.encryption.username" value="myservicekey"/> 
      </jaxws:properties> 

CXF-servlet.xml中

<jaxws:properties> 
      <entry key="ws-security.callback-handler"> 
       <ref bean="myPasswordCallback"/> 
      </entry> 
      <entry key="ws-security.encryption.properties" value="serviceKeystore.properties"/> 
      <entry key="ws-security.signature.properties" value="serviceKeystore.properties"/> 
      <entry key="ws-security.encryption.username" value="useReqSigCert"/> 
     </jaxws:properties> 
+0

遺憾的是所提供的鏈接確實不再工作,使這個答案沒有用的。 – LdSe 2014-03-11 16:56:21

+0

顯然他們在JRoller網站上做了一些修改,所以網址改變了。我確實找到了原始文檔,並在此過程中注意到他們甚至在Apache CXF網站上包含了更多關於此的文檔,並且包含了我上面提到的教程的鏈接。 – michaelok 2014-03-11 21:02:12

相關問題