WCF 服务可以使用配置文件来保护服务的安全,该机制与
WSE 3.0 策略文件相似。在 WSE 3.0 中,当使用策略文件来保护 Web 服务的安全时,可以使用关守安全断言或自定义策略断言。关守安全断言严格映射到
WCF 安全绑定元素的身份验证模式。WCF 身份验证模式和 WSE 3.0 关守安全断言不仅名称相同或相似,而且还使用相同的凭据类型来保护消息的安全。例如,WSE
3.0 中的
<policies>
<policy name="MyPolicy">
<usernameForCertificate messageProtectionOrder="SignBeforeEncrypt"
requireDeriveKeys="true"/>
</policy>
</policies>
<customBinding>
<binding name="MyBinding">
<security authenticationMode="UserNameForCertificate"
messageProtectionOrder="SignBeforeEncrypt"
requireDerivedKeys="true"/>
</binding>
</customBinding>
若要将策略文件中指定的 WSE 3.0 Web 服务的安全设置迁移到 WCF,必须在配置文件中创建一个自定义绑定,并且必须将关守安全断言设置为它的等效身份验证模式。此外,当
WSE 3.0 客户端与服务进行通信时,必须将自定义绑定配置为使用 2004 年 8 月版 WS-Addressing
规范。当所迁移的 WCF 服务不需要与 WSE 3.0 客户端进行通信并且必须保持同等安全性时,请考虑使用
WCF 的具有适当安全设置的系统定义绑定,而不是创建自定义绑定。
WSE 3.0 关守安全断言 |
WCF 自定义绑定配置 |
<usernameOverTransportSecurity /> |
<customBinding>
<binding name="MyBinding">
<security authenticationMode="UserNameOverTransport" />
<textMessageEncoding messageVersion="Soap12WSAddressingAugust2004" />
</binding>
</customBinding>
|
<mutualCertificate10Security /> |
<customBinding>
<binding name="MyBinding">
<security messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary
2005WSSecurityPolicy11BasicSecurityProfile10" authenticationMode="MutualCertificate" />
<textMessageEncoding messageVersion="Soap12WSAddressingAugust2004" />
</binding>
</customBinding>
|
<usernameForCertificateSecurity /> |
<customBinding>
<binding name="MyBinding">
<security authenticationMode="UsernameForCertificate"/>
<textMessageEncoding messageVersion="Soap12WSAddressingAugust2004" />
</binding>
</customBinding>
|
<anonymousForCertificateSecurity /> |
<customBinding>
<binding name="MyBinding">
<security authenticationMode="AnonymousForCertificate"/>
<textMessageEncoding messageVersion="Soap12WSAddressingAugust2004" />
</binding>
</customBinding>
|
<kerberosSecurity /> |
<customBinding>
<binding name="MyBinding">
<security authenticationMode="Kerberos"/>
<textMessageEncoding messageVersion="Soap12WSAddressingAugust2004" />
</binding>
</customBinding>
|
<mutualCertificate11Security /> |
<customBinding>
<binding name="MyBinding">
<security authenticationMode="MutualCertificate"/>
<textMessageEncoding messageVersion="Soap12WSAddressingAugust2004" />
</binding>
</customBinding>
|