2014-01-24 29 views
3

我必須使用Web服務,並要求必須是這樣的:春天Web服務客戶端簽名與智能卡

<soapenv:Envelope xmlns:ds="http://www.w3.org/2000/09/xmldsig#" 
    xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pid="http://pid.purs.gov.rs"> 
    <soapenv:Header> 
     <wsse:Security> 
     <ds:Signature> 
      <ds:SignedInfo> 
       <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> 
       <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/> 
       <ds:Reference URI="#X509-sertifikatId"> 
        <ds:Transforms> 
        <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> 
        </ds:Transforms> 
        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> 
        <ds:DigestValue>...</ds:DigestValue> 
       </ds:Reference> 
       <ds:Reference URI="#id-1"> 
        <ds:Transforms> 
        <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> 
        </ds:Transforms> 
        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> 
        <ds:DigestValue>...</ds:DigestValue> 
       </ds:Reference> 
      </ds:SignedInfo> 
      <ds:SignatureValue>...</ds:SignatureValue> 
      <ds:KeyInfo> 
       <wsse:SecurityTokenReference> 
        <wsse:Reference URI="#X509-sertifikatId"/> 
       </wsse:SecurityTokenReference> 
      </ds:KeyInfo> 
     </ds:Signature> 
     <wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="X509-sertifikatId">...</wsse:BinarySecurityToken> 
     </wsse:Security> 
    </soapenv:Header> 
    <soapenv:Body wsu:Id="id-1"> 
     ... 
    </soapenv:Body> 
</soapenv:Envelope> 

整個身體部分必須簽名。

我發現了很多例子,但它們都使用本地光盤上的keystore,我必須使用智能卡簽名消息。據我瞭解,我可以將證書從智能卡導出到.cer文件,但它不會有私鑰。那麼有沒有辦法做到這一點,以及如何?

任何幫助將不勝感激。

回答

0

我建議你使用WSS4J,這裏的例子是很好的起點爲您的問題:

Link 1

Link 2

我知道這是對我很有幫助;)