NetNamedPipeSecurity.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / NetNamedPipeSecurity.cs / 1 / NetNamedPipeSecurity.cs

                            //---------------------------------------------------------------------------- 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//---------------------------------------------------------------------------
namespace System.ServiceModel
{ 
    using System.Net.Security;
    using System.ServiceModel.Channels; 
 
    public sealed class NetNamedPipeSecurity
    { 
        internal const NetNamedPipeSecurityMode DefaultMode = NetNamedPipeSecurityMode.Transport;
        NetNamedPipeSecurityMode mode;
        NamedPipeTransportSecurity transport = new NamedPipeTransportSecurity();
 
        internal NetNamedPipeSecurity()
        { 
            this.mode = DefaultMode; 
        }
 
        NetNamedPipeSecurity(NetNamedPipeSecurityMode mode, NamedPipeTransportSecurity transport)
        {
            this.mode = mode;
            this.transport = transport == null ? new NamedPipeTransportSecurity() : transport; 
        }
 
        public NetNamedPipeSecurityMode Mode 
        {
            get { return this.mode; } 
            set
            {
                if (!NetNamedPipeSecurityModeHelper.IsDefined(value))
                { 
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value"));
                } 
                this.mode = value; 
            }
        } 

        public NamedPipeTransportSecurity Transport
        {
            get { return this.transport; } 
        }
 
        internal WindowsStreamSecurityBindingElement CreateTransportSecurity() 
        {
            if (mode == NetNamedPipeSecurityMode.Transport) 
            {
                return this.transport.CreateTransportProtectionAndAuthentication();
            }
            else 
            {
                return null; 
            } 
        }
 
        internal static bool TryCreate(WindowsStreamSecurityBindingElement wssbe, NetNamedPipeSecurityMode mode, out NetNamedPipeSecurity security)
        {
            security = null;
            NamedPipeTransportSecurity transportSecurity = new NamedPipeTransportSecurity(); 
            if (mode == NetNamedPipeSecurityMode.Transport)
            { 
                if (!NamedPipeTransportSecurity.IsTransportProtectionAndAuthentication(wssbe, transportSecurity)) 
                    return false;
            } 
            security = new NetNamedPipeSecurity(mode, transportSecurity);
            return true;
        }
    } 
}
 
 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK