WCF 客户端使用 username_token 和消息保护客户端策略将消息加密到 JAVA WS

发布于 2024-09-04 19:27:44 字数 12516 浏览 11 评论 0原文

我正在尝试创建一个 WCF 客户端应用程序,该应用程序正在使用 JAVA WS,该 JAVA WS 使用 username_token 和消息保护客户端策略。服务器上安装了私钥,并且从 JKS 密钥库文件导出了公共证书文件。我已通过 MMC 将公钥安装到个人证书下的证书存储中。

我正在尝试创建一个绑定,该绑定将加密消息并将用户名作为有效负载的一部分传递。我已经研究和尝试不同的配置大约一天了。我在msdn论坛上发现了类似的情况:

http://social.msdn.microsoft.com/Forums/en/wcf/thread/ce4b1bf5-8357-4e15-beb7-2e71b27d7415

是我在 app.config 中使用的配置

 <customBinding>
   <binding name="certbinding">
                <security authenticationMode="UserNameOverTransport">
                  <secureConversationBootstrap />
                </security>
                <httpsTransport requireClientCertificate="true" />
              </binding>
    </customBinding>

  <endpoint address="https://localhost:8443/ZZZService?wsdl"
              binding="customBinding" bindingConfiguration="cbinding"   contract="XXX.YYYPortType"
              name="ServiceEndPointCfg" />

这 是我正在使用的客户端代码,这是我设置客户端证书的位置:

            EndpointAddress endpointAddress = new EndpointAddress(url + "?wsdl");
            P6.WCF.Project.ProjectPortTypeClient proxy = new P6.WCF.Project.ProjectPortTypeClient("ServiceEndPointCfg", endpointAddress);
            proxy.ClientCredentials.UserName.UserName = UserName;

    proxy.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "67 87 ba 28 80 a6 27 f8 01 a6 53 2f 4a 43 3b 47 3e 88 5a c1");

           var projects = proxy.ReadProjects(readProjects);

这是我得到的 .NET 客户端错误: 错误日志: 安全信息无效。

在 Java WS 端,我跟踪日志:

严重:已启用加密,但请求中没有加密密钥。

我跟踪了 SOAP 标头和有效负载,并确认加密密钥不存在。

Headers: {expect=[100-continue], content-type=[text/xml; charset=utf-8], connection=[Keep-Alive], host=[localhost:8443], Content-Length=[731], vsdebuggercausalitydata=[uIDPo6hC1kng3ehImoceZNpAjXsAAAAAUBpXWdHrtkSTXPWB7oOvGZwi7MLEYUZKuRTz1XkJ3soACQAA], SOAPAction=[""], Content-Type=[text/xml; charset=utf-8]}


Payload: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><o:UsernameToken u:Id="uuid-5809743b-d6e1-41a3-bc7c-66eba0a00998-1"><o:Username>admin</o:Username><o:Password>admin</o:Password></o:UsernameToken></o:Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ReadProjects xmlns="http://xmlns.dev.com/WS/Project/V1"><Field>ObjectId</Field><Filter>Id='WS-Demo'</Filter></ReadProjects></s:Body></s:Envelope>

我还尝试了其他一些绑定,但没有成功:

  <basicHttpBinding>
    <binding name="basicHttp">
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="Certificate"/>
      </security>
    </binding>            
  </basicHttpBinding>  

      <wsHttpBinding>
        <binding name="wsBinding">
          <security mode="Message">
            <message clientCredentialType="UserName"  negotiateServiceCredential="false" />
          </security>  

        </binding>
      </wsHttpBinding>

非常感谢您的帮助!谢谢!


update2:

更多信息,我能够获得更多信息,但仍然没有雪茄:(

我修改了app.config绑定部分,将authenticationMode设置为UserNameForCertificate,并指定textMessageEncoding以使用Soap1.1

   <binding name="certbinding">
    <security authenticationMode="UserNameForCertificate" includeTimestamp="false">
     <secureConversationBootstrap />
    </security>
    <textMessageEncoding messageVersion="Soap11" />
    <httpsTransport requireClientCertificate="true" />
   </binding>

修改端点条目以包含身份以绕过某些证书由于 dns 条目不匹配而引起的警告,这让我

<client>
 <endpoint address="https://localhost:8443/p6ws/services/ProjectService?wsdl"
   binding="customBinding" bindingConfiguration="certbinding" contract="P6.WCF.Project.ProjectPortType"
   name="ProjectServiceEndPointCfg">
  <identity>
   <dns value="localhost"/>
  </identity>
 </endpoint>

在客户端代码 ServiceCertificate 中

    P6.WCF.Project.ProjectPortTypeClient proxy = new P6.WCF.Project.ProjectPortTypeClient("ProjectServiceEndPointCfg");
    proxy.ClientCredentials.UserName.UserName = UserName;

    proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerOrChainTrust;
    proxy.ClientCredentials.ServiceCertificate.Authentication.TrustedStoreLocation = System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine;

    proxy.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "67 87 ba 28 80 a6 27 f8 01 a6 53 2f 4a 43 3b 47 3e 88 5a c1");
    proxy.ClientCredentials.ServiceCertificate.SetDefaultCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "67 87 ba 28 80 a6 27 f8 01 a6 53 2f 4a 43 3b 47 3e 88 5a c1");

进一步指定现在跟踪 SOAP 我收到一条加密消息:

有效负载:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="uuid-c011a1a6-3878-4bbd-b6d1-84c7bf1539fe-2"><u:Created>2010-06-07T22:22:52.250Z</u:Created><u:Expires>2010-06-07T22:27:52.250Z</u:Expires></u:Timestamp><e:EncryptedKey Id="uuid-c011a1a6-3878-4bbd-b6d1-84c7bf1539fe-1" xmlns:e="http://www.w3.org/2001/04/xmlenc#"><e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" xmlns="http://www.w3.org/2000/09/xmldsig#"/></e:EncryptionMethod><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><o:SecurityTokenReference><o:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1">Z4e6KICmJ/gBplMvSkM7Rz6IWsE=</o:KeyIdentifier></o:SecurityTokenReference></KeyInfo><e:CipherData><e:CipherValue>Ddoi36zRBd+82HQ5rPFxhNXu1nCI8qxRiMtTIm2ldE69AgVbdRtXsHiLKXN6Tsk96U4NjVG/OkCELn7PLHX2CGY/+MH7fDro667RMdOyjlLBzjefO1m/JLTrdGPaHEQmVub/UtriIvwCm4sY8YE35g6Ej8FhABgqQlsvwBi6f3g=</e:CipherValue></e:CipherData></e:EncryptedKey><c:DerivedKeyToken u:Id="_0" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc"><o:SecurityTokenReference><o:Reference URI="#uuid-c011a1a6-3878-4bbd-b6d1-84c7bf1539fe-1"/></o:SecurityTokenReference><c:Offset>0</c:Offset><c:Length>24</c:Length><c:Nonce>kA1uT+jG8DCnw4PWLCpBJA==</c:Nonce></c:DerivedKeyToken><c:DerivedKeyToken u:Id="_1" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc"><o:SecurityTokenReference><o:Reference URI="#uuid-c011a1a6-3878-4bbd-b6d1-84c7bf1539fe-1"/></o:SecurityTokenReference><c:Nonce>9Y5iCPnq9mKvRzE91EbecA==</c:Nonce></c:DerivedKeyToken><e:ReferenceList xmlns:e="http://www.w3.org/2001/04/xmlenc#"><e:DataReference URI="#_3"/><e:DataReference URI="#_4"/><e:DataReference URI="#_5"/></e:ReferenceList><e:EncryptedData Id="_5" Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:e="http://www.w3.org/2001/04/xmlenc#"><e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><o:SecurityTokenReference><o:Reference URI="#_1"/></o:SecurityTokenReference></KeyInfo><e:CipherData><e:CipherValue>UE2UhcjwBsETg0Ndu26Gwdvp1UQk6sLJTT8KtSO7B5oykoBGazhrzu5XAQMCQfnlnZM+u8Gq3BLiEtIHb3SWue3i18yr20z8ZwVoHwI/TSNBjdOcfvyD7PF2YxFg/wYMKgY8dnRi8XVO/zWmVLbyd2GT7N1GoaaknkdECjWjVrkdsKlP8/AyprxgRnNJmqTcXUUoamwEeMeU0Y8qfKj3sUreVmPEXOe646JP2SF6pTyVnKSEjL1+TDbhiwOemienKZyNFj+C+JuUQLp/89Cb3hYedb6jWm7JZ1YO8bUy6CqI9Ux6mFxR2n12sDDZ1o1RoxEbR7jHsJJTP0MU2O6TmU4AquJgcldHS60joZy8iCXg24NHoERVI6BnQrEN4WT19E/HkInsUVQSBYTYpRTI1ZyimOX6Y9dgGDxH7tKY4fY=</e:CipherValue></e:CipherData></e:EncryptedData><e:EncryptedData Id="_4" Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:e="http://www.w3.org/2001/04/xmlenc#"><e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><o:SecurityTokenReference><o:Reference URI="#_1"/></o:SecurityTokenReference></KeyInfo><e:CipherData><e:CipherValue>qxX35B+cNLG64jgBkmop3+G1rVaQuJnkEyzENod9BvRzXAyqApPX7d3hW3KicJYdk077Ks+AXZE26HO85BqwsdxeNfx1ECXM6YdpxZzHtgqMMfGhaEZI3fh4dgxw3XLnEPa+D2N2lG4qPpxKk/s1M19acAKkaCcgu3NRZbuSHx+jXt3+oZjhITSz5ij5n7FlvKLzyI78/TOWJSrrIOuDBn9mBg1M4TL24USzt1iCGOWQjESSLkQR4u047t5TOZ14SHpdyyr9ZRc+f0QiDZi6Eg2nf+zP5dwSBuqO6KDf0Ws+4jr/g3Y8fczKcbl/gBm0TS/v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8Ocegkp51efkHPd/ZVck0hX7l+u5aqGONngBd/ylYbv2+TMzCV7bJAvD/Khlvs2vLUN8KYyT8jmuBF1PygiyEJ9bXhf6B3xCnc6REtVwZa76l5MiyOQ+8pBPOHbmiFUD0CdbsiBjlQVwh+G/bAkCvV1qXOCK89MKHiaMro7CTrdplTJi5z7X/Pm2/Cfbe14ieXfm8SZ0Bnb+hVW17x+EgXOyxTywBW6sJlQqZAXtg55RlIvds3whZnD8btOQcwy71oZx7r+lscjjQjBL1OucJ05b525iJMIF41EI1iJ7sc1x39Vm0dNAtGh9fubWpUnyRimGMiLV3MNtjws7OzQsun/aLLHqqSy4lAQ0drDc4OCvOeBsCUgI=</e:CipherValue></e:CipherData></e:EncryptedData></o:Security></s:Header><s:Body u:Id="_2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><e:EncryptedData Id="_3" Type="http://www.w3.org/2001/04/xmlenc#Content" xmlns:e="http://www.w3.org/2001/04/xmlenc#"><e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><o:Reference URI="#_1"/></o:SecurityTokenReference></KeyInfo><e:CipherData><e:CipherValue>07kyxqZy7AXCol4rmwkY9wDC4LVTFqVlGMD7smF5F68L00ndc6yEvuvTKJlb9wN1u0gPfgpIpvMBL2+aio8r2e/uHiseFSEGJhiOtWjpZutmaRkZyJ8xkph2sOO1EUxWUb3X+c32PMTs2RxCGncMBQczf/zXCv9IzWCxZymv8mcIkY2F95N2/6aqWCAqOQxnbOHAH6H13hHv/RCw6kHBNV7abtoY3q9xIFfh98nkf4a5u+jfl8KzMtsSI86kiLCVgMSfS8wSHVdhimkfwT+WSk1PJAqw47WR5ZsbGdHWofbS4fc59djSIwkaWZaJ5Z4biS3rbqSuPzk76F3ItLMWXQ==</e:CipherValue></e:CipherData></e:EncryptedData></s:Body></s:Envelope>

但是在 JAVA WS 端我收到此错误消息:

org.apache.cxf.binding.soap.SoapFault: 尝试时未找到用户名令牌 执行身份验证。

JAVA Ws 使用的规范期望加密消息并将用户名作为有效负载的一部分传递。

关于如何确保用户名现在也能通过有什么建议吗?正如您在上面的客户端代码中一样,我正在设置用户名。

            proxy.ClientCredentials.UserName.UserName = UserName;

I am trying to create a WCF client APP that is consuming a JAVA WS that uses username_token with message protection client policy. There is a private key that is installed on the server and a public certificate file was exported from the JKS keystore file. I have installed the public key into certificate store via MMC under Personal certificates.

I am trying to create a binding that will encrypt the message and pass the username as part of the payload. I have been researching and trying the different configurations for about a day now. I found a similar situation on the msdn forum:

http://social.msdn.microsoft.com/Forums/en/wcf/thread/ce4b1bf5-8357-4e15-beb7-2e71b27d7415

This is the configuration that I am using in my app.config

 <customBinding>
   <binding name="certbinding">
                <security authenticationMode="UserNameOverTransport">
                  <secureConversationBootstrap />
                </security>
                <httpsTransport requireClientCertificate="true" />
              </binding>
    </customBinding>

  <endpoint address="https://localhost:8443/ZZZService?wsdl"
              binding="customBinding" bindingConfiguration="cbinding"   contract="XXX.YYYPortType"
              name="ServiceEndPointCfg" />

And this is the client code that I am using, this is where I am setting the client certificate:

            EndpointAddress endpointAddress = new EndpointAddress(url + "?wsdl");
            P6.WCF.Project.ProjectPortTypeClient proxy = new P6.WCF.Project.ProjectPortTypeClient("ServiceEndPointCfg", endpointAddress);
            proxy.ClientCredentials.UserName.UserName = UserName;

    proxy.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "67 87 ba 28 80 a6 27 f8 01 a6 53 2f 4a 43 3b 47 3e 88 5a c1");

           var projects = proxy.ReadProjects(readProjects);

This is the .NET CLient error I get:
Error Log:
Invalid security information.

On the Java WS side I trace the log :

SEVERE: Encryption is enabled but there is no encrypted key in the request.

I traced the SOAP headers and payload and did confirm the encrypted key is not there.

Headers: {expect=[100-continue], content-type=[text/xml; charset=utf-8], connection=[Keep-Alive], host=[localhost:8443], Content-Length=[731], vsdebuggercausalitydata=[uIDPo6hC1kng3ehImoceZNpAjXsAAAAAUBpXWdHrtkSTXPWB7oOvGZwi7MLEYUZKuRTz1XkJ3soACQAA], SOAPAction=[""], Content-Type=[text/xml; charset=utf-8]}


Payload: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><o:UsernameToken u:Id="uuid-5809743b-d6e1-41a3-bc7c-66eba0a00998-1"><o:Username>admin</o:Username><o:Password>admin</o:Password></o:UsernameToken></o:Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ReadProjects xmlns="http://xmlns.dev.com/WS/Project/V1"><Field>ObjectId</Field><Filter>Id='WS-Demo'</Filter></ReadProjects></s:Body></s:Envelope>

I have also tryed some other bindings but with no success:

  <basicHttpBinding>
    <binding name="basicHttp">
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="Certificate"/>
      </security>
    </binding>            
  </basicHttpBinding>  

      <wsHttpBinding>
        <binding name="wsBinding">
          <security mode="Message">
            <message clientCredentialType="UserName"  negotiateServiceCredential="false" />
          </security>  

        </binding>
      </wsHttpBinding>

Your help will be greatly aprreciatted! Thanks!


update2:

More information, I was able to get further but still no cigar :(

I modified the app.config binding section the authenticationMode to UserNameForCertificate and specified the textMessageEncoding to use Soap1.1

   <binding name="certbinding">
    <security authenticationMode="UserNameForCertificate" includeTimestamp="false">
     <secureConversationBootstrap />
    </security>
    <textMessageEncoding messageVersion="Soap11" />
    <httpsTransport requireClientCertificate="true" />
   </binding>

modified the endpoint entry to include identity to get around some certificates warning caused due to mismatch of dns entries, that got me further.

<client>
 <endpoint address="https://localhost:8443/p6ws/services/ProjectService?wsdl"
   binding="customBinding" bindingConfiguration="certbinding" contract="P6.WCF.Project.ProjectPortType"
   name="ProjectServiceEndPointCfg">
  <identity>
   <dns value="localhost"/>
  </identity>
 </endpoint>

Specified in the client code ServiceCertificate

    P6.WCF.Project.ProjectPortTypeClient proxy = new P6.WCF.Project.ProjectPortTypeClient("ProjectServiceEndPointCfg");
    proxy.ClientCredentials.UserName.UserName = UserName;

    proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerOrChainTrust;
    proxy.ClientCredentials.ServiceCertificate.Authentication.TrustedStoreLocation = System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine;

    proxy.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "67 87 ba 28 80 a6 27 f8 01 a6 53 2f 4a 43 3b 47 3e 88 5a c1");
    proxy.ClientCredentials.ServiceCertificate.SetDefaultCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "67 87 ba 28 80 a6 27 f8 01 a6 53 2f 4a 43 3b 47 3e 88 5a c1");

Now tracing the SOAP I get an encrypted message:

Payload:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="uuid-c011a1a6-3878-4bbd-b6d1-84c7bf1539fe-2"><u:Created>2010-06-07T22:22:52.250Z</u:Created><u:Expires>2010-06-07T22:27:52.250Z</u:Expires></u:Timestamp><e:EncryptedKey Id="uuid-c011a1a6-3878-4bbd-b6d1-84c7bf1539fe-1" xmlns:e="http://www.w3.org/2001/04/xmlenc#"><e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" xmlns="http://www.w3.org/2000/09/xmldsig#"/></e:EncryptionMethod><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><o:SecurityTokenReference><o:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1">Z4e6KICmJ/gBplMvSkM7Rz6IWsE=</o:KeyIdentifier></o:SecurityTokenReference></KeyInfo><e:CipherData><e:CipherValue>Ddoi36zRBd+82HQ5rPFxhNXu1nCI8qxRiMtTIm2ldE69AgVbdRtXsHiLKXN6Tsk96U4NjVG/OkCELn7PLHX2CGY/+MH7fDro667RMdOyjlLBzjefO1m/JLTrdGPaHEQmVub/UtriIvwCm4sY8YE35g6Ej8FhABgqQlsvwBi6f3g=</e:CipherValue></e:CipherData></e:EncryptedKey><c:DerivedKeyToken u:Id="_0" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc"><o:SecurityTokenReference><o:Reference URI="#uuid-c011a1a6-3878-4bbd-b6d1-84c7bf1539fe-1"/></o:SecurityTokenReference><c:Offset>0</c:Offset><c:Length>24</c:Length><c:Nonce>kA1uT+jG8DCnw4PWLCpBJA==</c:Nonce></c:DerivedKeyToken><c:DerivedKeyToken u:Id="_1" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc"><o:SecurityTokenReference><o:Reference URI="#uuid-c011a1a6-3878-4bbd-b6d1-84c7bf1539fe-1"/></o:SecurityTokenReference><c:Nonce>9Y5iCPnq9mKvRzE91EbecA==</c:Nonce></c:DerivedKeyToken><e:ReferenceList xmlns:e="http://www.w3.org/2001/04/xmlenc#"><e:DataReference URI="#_3"/><e:DataReference URI="#_4"/><e:DataReference URI="#_5"/></e:ReferenceList><e:EncryptedData Id="_5" Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:e="http://www.w3.org/2001/04/xmlenc#"><e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><o:SecurityTokenReference><o:Reference URI="#_1"/></o:SecurityTokenReference></KeyInfo><e:CipherData><e:CipherValue>UE2UhcjwBsETg0Ndu26Gwdvp1UQk6sLJTT8KtSO7B5oykoBGazhrzu5XAQMCQfnlnZM+u8Gq3BLiEtIHb3SWue3i18yr20z8ZwVoHwI/TSNBjdOcfvyD7PF2YxFg/wYMKgY8dnRi8XVO/zWmVLbyd2GT7N1GoaaknkdECjWjVrkdsKlP8/AyprxgRnNJmqTcXUUoamwEeMeU0Y8qfKj3sUreVmPEXOe646JP2SF6pTyVnKSEjL1+TDbhiwOemienKZyNFj+C+JuUQLp/89Cb3hYedb6jWm7JZ1YO8bUy6CqI9Ux6mFxR2n12sDDZ1o1RoxEbR7jHsJJTP0MU2O6TmU4AquJgcldHS60joZy8iCXg24NHoERVI6BnQrEN4WT19E/HkInsUVQSBYTYpRTI1ZyimOX6Y9dgGDxH7tKY4fY=</e:CipherValue></e:CipherData></e:EncryptedData><e:EncryptedData Id="_4" Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:e="http://www.w3.org/2001/04/xmlenc#"><e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><o:SecurityTokenReference><o:Reference URI="#_1"/></o:SecurityTokenReference></KeyInfo><e:CipherData><e:CipherValue>qxX35B+cNLG64jgBkmop3+G1rVaQuJnkEyzENod9BvRzXAyqApPX7d3hW3KicJYdk077Ks+AXZE26HO85BqwsdxeNfx1ECXM6YdpxZzHtgqMMfGhaEZI3fh4dgxw3XLnEPa+D2N2lG4qPpxKk/s1M19acAKkaCcgu3NRZbuSHx+jXt3+oZjhITSz5ij5n7FlvKLzyI78/TOWJSrrIOuDBn9mBg1M4TL24USzt1iCGOWQjESSLkQR4u047t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XMznAogPRhueKvJ1u+TzEeqMZntdYNRqL6iY/eMhZJbiwaCh74+V3ccg79R1c6L0/CIMHX0cdxpteUJbMVk8Ocegkp51efkHPd/ZVck0hX7l+u5aqGONngBd/ylYbv2+TMzCV7bJAvD/Khlvs2vLUN8KYyT8jmuBF1PygiyEJ9bXhf6B3xCnc6REtVwZa76l5MiyOQ+8pBPOHbmiFUD0CdbsiBjlQVwh+G/bAkCvV1qXOCK89MKHiaMro7CTrdplTJi5z7X/Pm2/Cfbe14ieXfm8SZ0Bnb+hVW17x+EgXOyxTywBW6sJlQqZAXtg55RlIvds3whZnD8btOQcwy71oZx7r+lscjjQjBL1OucJ05b525iJMIF41EI1iJ7sc1x39Vm0dNAtGh9fubWpUnyRimGMiLV3MNtjws7OzQsun/aLLHqqSy4lAQ0drDc4OCvOeBsCUgI=</e:CipherValue></e:CipherData></e:EncryptedData></o:Security></s:Header><s:Body u:Id="_2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><e:EncryptedData Id="_3" Type="http://www.w3.org/2001/04/xmlenc#Content" xmlns:e="http://www.w3.org/2001/04/xmlenc#"><e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><o:Reference URI="#_1"/></o:SecurityTokenReference></KeyInfo><e:CipherData><e:CipherValue>07kyxqZy7AXCol4rmwkY9wDC4LVTFqVlGMD7smF5F68L00ndc6yEvuvTKJlb9wN1u0gPfgpIpvMBL2+aio8r2e/uHiseFSEGJhiOtWjpZutmaRkZyJ8xkph2sOO1EUxWUb3X+c32PMTs2RxCGncMBQczf/zXCv9IzWCxZymv8mcIkY2F95N2/6aqWCAqOQxnbOHAH6H13hHv/RCw6kHBNV7abtoY3q9xIFfh98nkf4a5u+jfl8KzMtsSI86kiLCVgMSfS8wSHVdhimkfwT+WSk1PJAqw47WR5ZsbGdHWofbS4fc59djSIwkaWZaJ5Z4biS3rbqSuPzk76F3ItLMWXQ==</e:CipherValue></e:CipherData></e:EncryptedData></s:Body></s:Envelope>

However on the JAVA WS side I get this error message:

org.apache.cxf.binding.soap.SoapFault:
Username token not found while trying
to perform authentication.

And the spec that the JAVA Ws uses expects to encrypt the message and pass the username as part of the payload.

Any suggestions on how to make sure the username also gets passed now? As you on the above client code I am setting the UserName.

            proxy.ClientCredentials.UserName.UserName = UserName;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文