SspiSecurityTokenParameters.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 / Tokens / SspiSecurityTokenParameters.cs / 1 / SspiSecurityTokenParameters.cs

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

 
namespace System.ServiceModel.Security.Tokens
{ 
    using System.IdentityModel.Selectors; 
    using System.ServiceModel.Channels;
    using System.ServiceModel; 
    using System.IdentityModel.Tokens;
    using System.ServiceModel.Security;
    using System.Text;
    using System.Globalization; 

    public class SspiSecurityTokenParameters : SecurityTokenParameters 
    { 
        internal const bool defaultRequireCancellation = false;
 
        bool requireCancellation = defaultRequireCancellation;
        BindingContext issuerBindingContext;

 
        protected SspiSecurityTokenParameters(SspiSecurityTokenParameters other)
            : base(other) 
        { 
            this.requireCancellation = other.requireCancellation;
            if (other.issuerBindingContext != null) 
            {
                this.issuerBindingContext = other.issuerBindingContext.Clone();
            }
        } 

 
        public SspiSecurityTokenParameters() 
            : this(defaultRequireCancellation)
        { 
            // empty
        }

        public SspiSecurityTokenParameters(bool requireCancellation) 
            : base()
        { 
            this.requireCancellation = requireCancellation; 
        }
 
        internal protected override bool HasAsymmetricKey { get { return false; } }

        public bool RequireCancellation
        { 
            get
            { 
                return this.requireCancellation; 
            }
            set 
            {
                this.requireCancellation = value;
            }
        } 

        internal BindingContext IssuerBindingContext 
        { 
            get
            { 
                return this.issuerBindingContext;
            }
            set
            { 
                if (value != null)
                { 
                    value = value.Clone(); 
                }
                this.issuerBindingContext = value; 
            }
        }

        internal protected override bool SupportsClientAuthentication { get { return true; } } 
        internal protected override bool SupportsServerAuthentication { get { return true; } }
        internal protected override bool SupportsClientWindowsIdentity { get { return true; } } 
 
        protected override SecurityTokenParameters CloneCore()
        { 
            return new SspiSecurityTokenParameters(this);
        }

        internal protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause(SecurityToken token, SecurityTokenReferenceStyle referenceStyle) 
        {
            if (token is GenericXmlSecurityToken) 
                return base.CreateGenericXmlTokenKeyIdentifierClause(token, referenceStyle); 
            else
                return this.CreateKeyIdentifierClause(token, referenceStyle); 
        }

        protected internal override void InitializeSecurityTokenRequirement(SecurityTokenRequirement requirement)
        { 
            requirement.TokenType = ServiceModelSecurityTokenTypes.Spnego;
            requirement.RequireCryptographicToken = true; 
            requirement.KeyType = SecurityKeyType.SymmetricKey; 
            requirement.Properties[ServiceModelSecurityTokenRequirement.SupportSecurityContextCancellationProperty] = this.RequireCancellation;
            if (this.IssuerBindingContext != null) 
            {
                requirement.Properties[ServiceModelSecurityTokenRequirement.IssuerBindingContextProperty] = this.IssuerBindingContext.Clone();
            }
            requirement.Properties[ServiceModelSecurityTokenRequirement.IssuedSecurityTokenParametersProperty] = this.Clone(); 
        }
 
        public override string ToString() 
        {
            StringBuilder sb = new StringBuilder(); 
            sb.AppendLine(base.ToString());

            sb.Append(String.Format(CultureInfo.InvariantCulture, "RequireCancellation: {0}", this.RequireCancellation.ToString()));
 
            return sb.ToString();
        } 
    } 
}

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