使用wss安全性创建SOAP客户端

时间:2015-09-01 09:17:35

标签: java soap jax-ws webservice-client ws-security

我需要创建一个访问安全服务的服务客户端。

我已经使用cxf在maven上创建了一个来自wsdl文件的服务存根,现在我正在尝试对SOAP标头进行签名,但我无法在soap请求中显示任何标题。

我试图在谷歌上找到任何示例,但发现的少数几个没有在请求中提供任何标题。

我还尝试包含cxf-rt-ws-security但我无法从中获取所有依赖项,因为它说找不到net.sf.ehcache:ehcache:jar:2.9.0

非常感谢任何帮助。

至于我试图进入soap请求的标题,它应该是这样的:

    <soapenv:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
        <xenc:EncryptedKey Id="EncKeyId-679555506">
            <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
            <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                <wsse:SecurityTokenReference>
                    <ds:X509Data>
                        <ds:X509IssuerSerial>
                            <ds:X509IssuerName>CN=Service</ds:X509IssuerName>
                            <ds:X509SerialNumber>1208931986</ds:X509SerialNumber>
                        </ds:X509IssuerSerial>
                    </ds:X509Data>
                </wsse:SecurityTokenReference>
            </ds:KeyInfo>
            <xenc:CipherData>
                <xenc:CipherValue>*****</xenc:CipherValue>
            </xenc:CipherData>
            <xenc:ReferenceList>
                <xenc:DataReference URI="#EncDataId-160481262" />
            </xenc:ReferenceList>
        </xenc:EncryptedKey>
        <wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 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="CertId--168360">*****</wsse:BinarySecurityToken>
        <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-1901480989">
            <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="#id-160481262">
                    <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 Id="KeyId-274944844">
                <wsse:SecurityTokenReference xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="STRId--395421404">
                    <wsse:Reference URI="#CertId--168360" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" />
                </wsse:SecurityTokenReference>
            </ds:KeyInfo>
        </ds:Signature>
    </wsse:Security>
    <wsa:To>http://www.example.com/ExampleService?wsdl</wsa:To>
    <wsa:MessageID>*****</wsa:MessageID>
    <wsa:Action>http://www.example.com/ExampleService/check</wsa:Action>
</soapenv:Header>

0 个答案:

没有答案