2011-12-06 83 views
1

在WebSphere v7中,我很難用X509基於證書的WS-Security。X509在WebSphere中使用spring-ws和XWS攔截器的WS-Security

下面是一個小背景: 我們在我們的應用程序中使用spring-ws,並且我們允許UsernameToken配置文件安全性或X509安全性。兩個正在使用XWS安全攔截器,運行關XWS安全框架的實施:

http://docs.oracle.com/cd/E17802_01/webservices/webservices/docs/1.6/tutorial/doc/XWS-SecurityIntro4.html

我們在客戶端&在服務器端實現安全,無論使用XWSS攔截。有兩個問題:

  1. 從WebSphere返回的「http://www.w3.org/2001/10/xml-exc-c14n#」或任何CanonicalizationMethod的javax.xml.crypto類不兼容與XWSS攔截器。我們看到這個錯誤在服務器端的消息日誌:

11年12月5日17:26:41:098 EST 00000023 XwsSecurityInW¯¯org.springframework.ws.soap.security.AbstractWsSecurityInterceptor handleValidationException莫非不驗證請求:com.sun.xml.wss.XWSSecurityException:javax.xml.crypto.MarshalException:java.security.NoSuchAlgorithmException:爲TransformService配置的類:com.ibm.xml.crypto.dsig.dom.transform.ExcC14nTransformer not a TransformService;嵌套異常爲com.sun.xml.wss.XWSSecurityException:com.sun.xml.wss.XWSSecurityException:javax.xml.crypto.MarshalException:java.security.NoSuchAlgorithmException:爲TransformService配置的類:com.ibm.xml.crypto。 dsig.dom.transform.ExcC14nTransformer不是TransformService

我認爲這裏要做的最好的事情是覆蓋哪個實現用於解密這些類型。我們在我們的war文件中包含了xmldsig-1.0.jar(在classloader設置爲parent-last的情況下進行部署)。有人知道覆蓋這個的方法嗎?我嘗試在運行時環境中的java.security中指定「org.jcp.xml.dsig.internal.dom.XMLDSigRI」,但那不起作用。我們在我們的應用程序中包含了xmldsig-1.0.jar。

這看起來像是IBM的JRE & Sun的JRE之間的兼容性問題。 XWSS攔截器是由Sun編寫的,所以他們可能會認爲某些事情是理所當然的。

  1. 我們正在對客戶端試圖插入簽名請求所需的頭部元素一個NullPointerException。我們爲我們的DOM實現使用了xerces,但這似乎是沿着SOAPFactory的界限。我嘗試將屬性「javax.xml.soap.SOAPFactory」設置爲「com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl」,但似乎沒有解決問題。以下是堆棧跟蹤:

    [12/3/11 13:39:52:560 EST] 00000027 XwsSecurityIn E org.springframework.ws.soap.security.AbstractWsSecurityInterceptor handleSecurementException無法保護響應:java.lang.NullPointerException ;嵌套異常是com.sun.xml.wss.XWSSecurityException:java.lang.NullPointerException org.springframework.ws.soap.security.xwss.XwsSecuritySecurementException:java.lang.NullPointerException;嵌套的例外是com.sun.xml.wss.XWSSecurityException:顯示java.lang.NullPointerException

    ...

    引起的:在COM顯示java.lang.NullPointerException :com.sun.xml.wss.XWSSecurityException .sun.xml.wss.impl.misc.XWSSProcessor2_0Impl.secureOutboundMessage(XWSSProcessor2_0Impl。java:98) at org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor.secureMessage(XwsSecurityInterceptor.java:135) ... 86更多 引起:java.lang.NullPointerException at com.sun.xml .wss.core.Timestamp.getAsSoapElement(Timestamp.java:265) at com.sun.xml.wss.core.SecurityHeader.insertHeaderBlock(SecurityHeader.java:90) at com.sun.xml.wss.impl.filter .TimestampFilter.process(TimestampFilter.java:149) at com.sun.xml.wss.impl.HarnessUtil.processWSSPolicy(HarnessUtil.java:87) at com.sun.xml.wss.impl.HarnessUtil.processDeep(HarnessUtil .java:237) at com.sun.xml.wss.impl.SecurityAnnotator.processMessagePolicy(SecurityAnnotator.java:162) at com.sun.xml.wss.impl.SecurityAnnotator.secureMessage(SecurityAnnotator.java:137) at com.sun.xml.wss.impl.misc.XWSSProcessor2_0Impl.secureOutboundMessage(XWSSProcessor2_0Impl.java:96) ... 87更多

我試着設置我的策略配置來禁用時間戳,但是後來我在不同的元素上得到了NPE。我不相信的配置是難辭其咎的,但在這裏它是無論如何:

<?xml version="1.0" encoding="UTF-8"?> 
<SecurityConfiguration xmlns="http://java.sun.com/xml/ns/xwss/config" dumpMessages="true"> 
    <Sign includeTimestamp="false"> 
     <X509Token certificateAlias="1"/> 
    </Sign> 
</SecurityConfiguration> 

我已經測試了這個在JBoss &碼頭,並都工作正常。任何援助將不勝感激......

回答