X509WindowsSecurityToken.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 / IdentityModel / System / IdentityModel / Tokens / X509WindowsSecurityToken.cs / 1 / X509WindowsSecurityToken.cs

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

namespace System.IdentityModel.Tokens 
{
    using System.Security.Cryptography.X509Certificates; 
    using System.Security.Principal; 

    public class X509WindowsSecurityToken : X509SecurityToken 
    {
        WindowsIdentity windowsIdentity;
        bool disposed = false;
 
        public X509WindowsSecurityToken(X509Certificate2 certificate, WindowsIdentity windowsIdentity)
            : this(certificate, windowsIdentity, true) 
        { 
        }
 
        public X509WindowsSecurityToken(X509Certificate2 certificate, WindowsIdentity windowsIdentity, string id)
            : this(certificate, windowsIdentity, id, true)
        {
        } 

        internal X509WindowsSecurityToken(X509Certificate2 certificate, WindowsIdentity windowsIdentity, bool clone) 
            : this(certificate, windowsIdentity, SecurityUniqueId.Create().Value, clone) 
        {
        } 

        internal X509WindowsSecurityToken(X509Certificate2 certificate, WindowsIdentity windowsIdentity, string id, bool clone)
            : base(certificate, id, clone)
        { 
            if (windowsIdentity == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("windowsIdentity"); 
 
            this.windowsIdentity = clone ? SecurityUtils.CloneWindowsIdentityIfNecessary(windowsIdentity) : windowsIdentity;
        } 


        public WindowsIdentity WindowsIdentity
        { 
            get
            { 
                ThrowIfDisposed(); 
                return this.windowsIdentity;
            } 
        }

        public override void Dispose()
        { 
            try
            { 
                if (!this.disposed) 
                {
                    this.disposed = true; 
                    this.windowsIdentity.Dispose();
                }
            }
            finally 
            {
                base.Dispose(); 
            } 
        }
    } 
}

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