Breyta

Deila með


NetTcpSecurity Class

Definition

Specifies the types of transport-level and message-level security used by an endpoint configured with a NetTcpBinding.

public ref class NetTcpSecurity sealed
public sealed class NetTcpSecurity
type NetTcpSecurity = class
Public NotInheritable Class NetTcpSecurity
Inheritance
NetTcpSecurity

Examples

The following code shows how to retrieve the NetTcpSecurity object from a NetTcpBinding and prints out the various settings it contains:

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();
}

Remarks

Each of the standard bindings provides parameters for controlling the transfer security requirements. These parameters typically include the security mode that specified whether message-level or transport-level security is used and the choice of client credential type. Based on the choice of options these parameters present, a channel stack is constructed with appropriate security.

The system-provided bindings supplied by Windows Communication Foundation (WCF) are a set designed to meet some of the most common scenario requirements. Each of these bindings allows the specification of security requirements for some specific targeted scenarios.

NetTcpSecurity provides the security specifications for NetTcpBinding. This is a secure, reliable, optimized binding suitable for cross-machine communication. By default it generates a run-time communication stack that supports TCP for message delivery and Windows Security for message security and authentication, WS-ReliableMessaging for reliability, and binary message encoding.

This class is instantiated by the NetTcpBinding, and can be accessed by a read-only property called Security. Because this property is read-only you cannot make changes to the returned object. If you want to control the creation of the NetTcpSecurity object, you can derive a class from NetTcpBinding.

Constructors

NetTcpSecurity()

Initializes a new instance of the NetTcpSecurity class.

Properties

Message

Gets the type of message-level security requirements for a service configured with a NetTcpBinding.

Mode

Gets or sets whether message-level security and transport-level security are used by an endpoint configured with a NetTcpBinding.

Transport

Gets the type of message-level security requirements for an endpoint configured with a NetTcpBinding.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to