NetTcpSecurity 類別

定義

指定以 NetTcpBinding 設定之端點所用的傳輸層級與訊息層級安全性型別。

public ref class NetTcpSecurity sealed
public sealed class NetTcpSecurity
type NetTcpSecurity = class
Public NotInheritable Class NetTcpSecurity
繼承
NetTcpSecurity

範例

下列程式碼示範如何從 NetTcpBinding 擷取 NetTcpSecurity 物件,並印出它所包含的各種設定:

using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService)))
{
    serviceHost.Open();
    ServiceEndpointCollection endpoints = serviceHost.Description.Endpoints;
    ServiceEndpoint endpoint = endpoints.Find(typeof(ICalculator));

    NetTcpBinding binding = (NetTcpBinding) endpoint.Binding;

    NetTcpSecurity security = binding.Security;
    MessageSecurityOverTcp msTcp = security.Message;

    Console.WriteLine("Dumping NetTcpSecurity object:");
    Console.WriteLine("\tMessageSecurityOverTcp:");
    Console.WriteLine("\t\tAlgorithm Suite: {0}", msTcp.AlgorithmSuite);
    Console.WriteLine("\t\tClient Credential Type: {0}", msTcp.ClientCredentialType);

    Console.WriteLine("\tSecurity Mode: {0}", security.Mode);

    TcpTransportSecurity tsTcp = security.Transport;
    Console.WriteLine("\tTcpTransportSecurity:");
    Console.WriteLine("\t\tClient Credential Type: {0}", tsTcp.ClientCredentialType);
    Console.WriteLine("\t\tProtectionLevel: {0}", tsTcp.ProtectionLevel);

    // The service can now be accessed.
    Console.WriteLine("The service is ready.");
    Console.WriteLine("Press <ENTER> to terminate service.");
    Console.WriteLine();
    Console.ReadLine();
}

備註

每個標準繫結程序提供了控制傳輸安全性需求的參數。 這些參數通常會包含安全性模式,此模式會指定是否採用訊息層級或傳輸層級安全性,以及選擇用戶端認證型別。 根據這些參數所代表的選取選項,會以適當安全性來建構通道堆疊。

由 Windows Communication Foundation (WCF) 提供的系統提供繫結程序,是設計成符合某些最常見案例需求的一組繫結程序。 這些每個繫結程序都允許特定目標案例的安全性需求規格。

NetTcpSecurity 提供 的安全性規格 NetTcpBinding 。 這是一個安全、可靠且最佳的繫結,適用於跨電腦通訊。 根據預設,它會產生執行階段通訊堆疊,可支援 TCP 訊息傳遞、Windows 安全性 (提供訊息安全性與驗證)、WS-ReliableMessaging (提升可靠性) 以及二進位訊息編碼。

這個類別是由 NetTcpBinding 具現化,而且可以透過稱為 Security 的唯讀屬性來存取。 由於這是唯讀屬性,因此您無法變更傳回的物件。 如果您想要控制物件的建立 NetTcpSecurity ,您可以從 衍生類別 NetTcpBinding

建構函式

NetTcpSecurity()

初始化 NetTcpSecurity 類別的新執行個體。

屬性

Message

取得以 NetTcpBinding 設定之服務的訊息層級安全性需求的型別。

Mode

取得或設定以 NetTcpBinding 設定的端點是否使用訊息層級安全性與傳輸層級安全性。

Transport

取得以 NetTcpBinding 設定之端點的訊息層級安全性需求的型別。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於