2014-01-24 35 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

我知道这是对我很有帮助;)