Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

NetTcpSecurity Class

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

System.Object
  System.ServiceModel.NetTcpSecurity

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
public sealed class NetTcpSecurity

The NetTcpSecurity type exposes the following members.

  NameDescription
Public methodSupported in .NET for Windows Store appsNetTcpSecurityInitializes a new instance of the NetTcpSecurity class.
Top
  NameDescription
Public propertySupported in .NET for Windows Store appsMessageGets the type of message-level security requirements for a service configured with a NetTcpBinding.
Public propertySupported in .NET for Windows Store appsModeGets or sets whether message-level security and transport-level security are used by an endpoint configured with a NetTcpBinding.
Public propertySupported in .NET for Windows Store appsTransportGets the type of message-level security requirements for an endpoint configured with a NetTcpBinding.
Top
  NameDescription
Public methodSupported in .NET for Windows Store appsEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodSupported in .NET for Windows Store appsGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodSupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported in .NET for Windows Store appsToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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.

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

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Store apps

Supported in: Windows 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.