SessionSymmetricTransportSecurityProtocolFactory.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 / Security / SessionSymmetricTransportSecurityProtocolFactory.cs / 1 / SessionSymmetricTransportSecurityProtocolFactory.cs

                            //---------------------------------------------------------- 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------

namespace System.ServiceModel.Security 
{
    using System.ServiceModel.Security.Tokens; 
    using System.ServiceModel; 

    class SessionSymmetricTransportSecurityProtocolFactory : TransportSecurityProtocolFactory 
    {
        SecurityTokenParameters securityTokenParameters;
        SessionDerivedKeySecurityTokenParameters derivedKeyTokenParameters;
 
        public SessionSymmetricTransportSecurityProtocolFactory()
            : base() 
        { 
        }
 
        public override bool SupportsReplayDetection
        {
            get
            { 
                return true;
            } 
        } 

        public SecurityTokenParameters SecurityTokenParameters 
        {
            get
            {
                return this.securityTokenParameters; 
            }
            set 
            { 
                ThrowIfImmutable();
                this.securityTokenParameters = value; 
            }
        }

        protected override SecurityProtocol OnCreateSecurityProtocol(EndpointAddress target, Uri via, object listenerSecurityState, TimeSpan timeout) 
        {
            if (this.ActAsInitiator) 
            { 
                return new InitiatorSessionSymmetricTransportSecurityProtocol(this, target, via);
            } 
            else
            {
                return new AcceptorSessionSymmetricTransportSecurityProtocol(this);
            } 
        }
 
        public override void OnOpen(TimeSpan timeout) 
        {
            base.OnOpen(timeout); 
            if (this.SecurityTokenParameters == null)
            {
                OnPropertySettingsError("SecurityTokenParameters", true);
            } 
            if (this.SecurityTokenParameters.RequireDerivedKeys)
            { 
                this.ExpectKeyDerivation = true; 
                this.derivedKeyTokenParameters = new SessionDerivedKeySecurityTokenParameters(this.ActAsInitiator);
            } 
        }

        internal SecurityTokenParameters GetTokenParameters()
        { 
            if (this.derivedKeyTokenParameters != null)
            { 
                return this.derivedKeyTokenParameters; 
            }
            else 
            {
                return this.securityTokenParameters;
            }
        } 
    }
} 

// 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