AsymmetricSecurityBindingElement 类

定义

表示一个自定义绑定元素,它支持使用不对称加密的通道安全。Represents a custom binding element that supports channel security using asymmetric encryption. 此绑定元素会使用发送方的身份验证令牌来签署消息,并使用接收方的令牌来加密消息。This binding element signs the message using the sender's authentication token and encrypts the message using the recipient's token.

public ref class AsymmetricSecurityBindingElement sealed : System::ServiceModel::Channels::SecurityBindingElement, System::ServiceModel::Description::IPolicyExportExtension
public sealed class AsymmetricSecurityBindingElement : System.ServiceModel.Channels.SecurityBindingElement, System.ServiceModel.Description.IPolicyExportExtension
type AsymmetricSecurityBindingElement = class
    inherit SecurityBindingElement
    interface IPolicyExportExtension
Public NotInheritable Class AsymmetricSecurityBindingElement
Inherits SecurityBindingElement
Implements IPolicyExportExtension
继承
AsymmetricSecurityBindingElement
实现

示例

下面的示例演示如何使用此类来创建将此类纳入为安全绑定因素的自定义绑定。The following example shows how to use this class to create a custom binding that includes this class as a security binding element. 有关此示例中的代码的详细信息, 请参阅如何:一致引用 x.509 证书For more information about the code in this example, see How to: Consistently Reference X.509 Certificates.

       public Binding CreateClientBinding()
       {
           AsymmetricSecurityBindingElement abe =
               (AsymmetricSecurityBindingElement)SecurityBindingElement.
               CreateMutualCertificateBindingElement(
               MessageSecurityVersion.
               WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10);

           abe.SetKeyDerivation(false);
           
           X509SecurityTokenParameters istp =
              abe.InitiatorTokenParameters as X509SecurityTokenParameters;
           if (istp != null)
           {
               istp.X509ReferenceStyle =
               X509KeyIdentifierClauseType.IssuerSerial;
           }
           X509SecurityTokenParameters rstp =
           abe.RecipientTokenParameters as X509SecurityTokenParameters;
           if (rstp != null)
           {
               rstp.X509ReferenceStyle =
               X509KeyIdentifierClauseType.IssuerSerial;
           }

           HttpTransportBindingElement transport = 
               new HttpTransportBindingElement();

           return new CustomBinding(abe, transport);
       }
Public Function CreateClientBinding() As Binding
    Dim abe As AsymmetricSecurityBindingElement = CType(SecurityBindingElement.CreateMutualCertificateBindingElement(MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10), AsymmetricSecurityBindingElement)

    abe.SetKeyDerivation(False)

    Dim istp As X509SecurityTokenParameters = TryCast(abe.InitiatorTokenParameters, X509SecurityTokenParameters)
    If istp IsNot Nothing Then
        istp.X509ReferenceStyle = X509KeyIdentifierClauseType.IssuerSerial
    End If
    Dim rstp As X509SecurityTokenParameters = TryCast(abe.RecipientTokenParameters, X509SecurityTokenParameters)
    If rstp IsNot Nothing Then
        rstp.X509ReferenceStyle = X509KeyIdentifierClauseType.IssuerSerial
    End If

    Dim transport As New HttpTransportBindingElement()

    Return New CustomBinding(abe, transport)
End Function

注解

自定义绑定包含以特定顺序排列的绑定元素集合:首先添加表示绑定堆栈顶部的元素,其次是绑定堆栈中的下一个元素,依此类推。A custom binding contains a collection of binding elements arranged in a specific order: the element that represents the top of the binding stack is added first, the next element down in the binding stack, is added second, and so forth.

将此类添加到绑定中To add this class to a binding

  1. 创建 BindingElementCollectionCreate a BindingElementCollection.

  2. 在绑定堆栈中创建将位于此绑定元素之上的自定义绑定元素,比如可选的 TransactionFlowBindingElementReliableSessionBindingElementCreate custom binding elements that is above this binding element in the binding stack, such as the optional TransactionFlowBindingElement and ReliableSessionBindingElement.

  3. 使用 BindingElementCollection 方法,按照上述顺序将已创建的元素添加到 InsertItem(Int32, BindingElement)Add the created elements in the preceding order to the BindingElementCollection using the InsertItem(Int32, BindingElement) method.

  4. 创建 AsymmetricSecurityBindingElement 的实例,并将其添加到集合。Create an instance of AsymmetricSecurityBindingElement and add it to the collection.

  5. 将任何其他自定义绑定元素添加到集合,比如 TcpTransportBindingElementAdd any additional custom binding elements to the collection, such as TcpTransportBindingElement.

使用此类之前,你应该确定标准绑定是否能够满足你的安全需求。Before using this class, you should determine if a standard binding meets your security requirements.

备注

在创建此对象的实例后,您应该将其基类 SecurityBindingElement 的属性视为不可变的。Once an instance of this object is created, you should treat the properties of its base class SecurityBindingElement as immutable. 对某些属性调用 set 可能会产生不可预知的效果:绑定的行为可能就好像属性保留了其旧值一样,并出现运行时错误,该错误是问题的唯一迹象。Calling set on some properties may have unpredictable effects: the binding may behave as if the property retained its old value, with a run-time failure being the only indication of an issue. 已知具有此行为的两个属性为 KeyTypeMessageSecurityVersionTwo properties known to behave this way are KeyType and MessageSecurityVersion. 其他某些属性可能也是如此。There may be other properties this is true of.

构造函数

AsymmetricSecurityBindingElement()

创建此类的实例。Creates an instance of this class.

AsymmetricSecurityBindingElement(SecurityTokenParameters)

使用指定的接收方令牌参数初始化 AsymmetricSecurityBindingElement 类的新实例。Initializes a new instance of AsymmetricSecurityBindingElement with the specified recipient token parameters.

AsymmetricSecurityBindingElement(SecurityTokenParameters, SecurityTokenParameters)

使用指定的接收方和发起方令牌参数初始化 AsymmetricSecurityBindingElement 的新实例。Initializes a new instance of AsymmetricSecurityBindingElement with the specified recipient and initiator token parameters.

属性

AllowInsecureTransport

获取或设置一个值,该值指示是否能通过不安全传输(如 HTTP)发送混合模式安全消息。Gets or sets a value that indicates whether mixed-mode secured messages can be sent over an unsecured transport such as HTTP.

(继承自 SecurityBindingElement)
AllowSerializedSigningTokenOnReply

获取或设置一个值,该值指示是否允许在答复消息上序列化签名令牌。Gets or sets a value that indicates whether serializing a signing token on a reply message is allowed.

DefaultAlgorithmSuite

获取或设置消息加密和密钥换行算法。Gets or sets the message encryption and key-wrap algorithms.

(继承自 SecurityBindingElement)
EnableUnsecuredResponse

获取或设置一个值,该值指示 WCF 是否能发送和接收对安全请求的不安全响应。Gets or sets a value that indicates whether WCF can send and receive unsecured responses to secured requests.

(继承自 SecurityBindingElement)
EndpointSupportingTokenParameters

获取支持令牌参数的终结点。Gets the endpoint that supports token parameters.

(继承自 SecurityBindingElement)
IncludeTimestamp

获取或设置一个值,该值指示是否每条消息都包含时间戳。Gets or sets a value that indicates whether time stamps are included in each message.

(继承自 SecurityBindingElement)
InitiatorTokenParameters

指定发起方的令牌定义。Specifies the token definition for the initiator.

KeyEntropyMode

获取或设置用于创建密钥的熵来源。Gets or sets the source of entropy used to create keys.

(继承自 SecurityBindingElement)
LocalClientSettings

获取由客户端使用的特定于本地安全设置的绑定属性。Gets the binding properties specific to local security settings used by the client.

(继承自 SecurityBindingElement)
LocalServiceSettings

获取由客户端使用的特定于本地安全设置的绑定属性。Gets the binding properties specific to local security settings used by the service.

(继承自 SecurityBindingElement)
MessageProtectionOrder

获取或设置此绑定的消息加密和签名的顺序。Gets or sets the order of message encryption and signing for this binding.

MessageSecurityVersion

获取或设置消息安全版本。Gets or sets the message security version.

(继承自 SecurityBindingElement)
OperationSupportingTokenParameters

获取操作支持令牌参数的集合。Gets the collection of operation supporting token parameters.

(继承自 SecurityBindingElement)
OptionalEndpointSupportingTokenParameters

获取服务终结点的可选支持令牌参数。Gets the optional supporting token parameters for the service endpoint.

(继承自 SecurityBindingElement)
OptionalOperationSupportingTokenParameters

获取可选操作支持令牌参数的集合。Gets the collection of optional operation supporting token parameters.

(继承自 SecurityBindingElement)
ProtectTokens

获取或设置安全绑定元素是否保护令牌。Gets or sets whether the security binding element protects tokens.

(继承自 SecurityBindingElement)
RecipientTokenParameters

指定接收方的令牌定义。Specifies the token definition for the recipient.

RequireSignatureConfirmation

获取或设置一个值,该值指示是否必须确认消息签名。Gets or sets a value that indicates whether message signatures must be confirmed.

SecurityHeaderLayout

获取或设置此绑定的安全头中的元素排序。Gets or sets the ordering of the elements in the security header for this binding.

(继承自 SecurityBindingElement)

方法

BuildChannelFactory<TChannel>(BindingContext)

基于 SecurityBindingElement 设置和传入的绑定上下文创建通道工厂。Creates a channel factory based on the SecurityBindingElement settings and the binding context passed in. 创建的通道工厂为 SOAP 消息安全通道工厂,其内部有到对应绑定上下文的通道工厂的引用(包括传输通道工厂)。The channel factory created is a SOAP message security channel factory, which internally has a reference to the channel factory that corresponds to the binding context, (which includes the transport channel factory).

(继承自 SecurityBindingElement)
BuildChannelFactoryCore<TChannel>(BindingContext)

实现时创建指定类型的通道工厂。When implemented, creates a channel factory of a specified type.

(继承自 SecurityBindingElement)
BuildChannelListener<TChannel>(BindingContext)

基于 SecurityBindingElement 设置和传入的绑定上下文创建通道侦听器。Creates a channel listener based on the SecurityBindingElement settings and the binding context passed in.

(继承自 SecurityBindingElement)
BuildChannelListenerCore<TChannel>(BindingContext)

实现时创建指定类型的通道侦听器。When implemented, creates a channel listener of a specified type.

(继承自 SecurityBindingElement)
CanBuildChannelFactory<TChannel>(BindingContext)

确定是否可生成指定类型的通道工厂。Determines whether a channel factory of the specified type can be built.

(继承自 SecurityBindingElement)
CanBuildChannelListener<TChannel>(BindingContext)

确定是否可生成指定类型的通道侦听器。Determines whether a channel listener of the specified type can be built.

(继承自 SecurityBindingElement)
Clone()

创建此类的新实例(从当前类初始化)。Creates a new instance of this class initialized from the current one.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetProperty<T>(BindingContext)

BindingContext 中获取指定的对象。Gets a specified object from the BindingContext.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
SetKeyDerivation(Boolean)

设置一个值,该值指示是否需要派生密钥。Sets a value that indicates whether derived keys are required.

ToString()

返回表示此 AsymmetricSecurityBindingElement 实例的字符串。Returns a string that represents this AsymmetricSecurityBindingElement instance.

显式界面实现

IPolicyExportExtension.ExportPolicy(MetadataExporter, PolicyConversionContext)

导出关于绑定的自定义策略断言,将其添加到 Web 服务描述语言 (WSDL) 信息中。Exports a custom policy assertion about bindings, which is added to the Web Services Description Language (WSDL) information.

适用于