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

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Security.Tokens
{ 
    using System;
    using System.Security.Cryptography.X509Certificates; 
    using System.Runtime.CompilerServices; 
    using System.IdentityModel.Selectors;
    using System.IdentityModel.Tokens; 

    class SecurityTokenProviderContainer
    {
        SecurityTokenProvider tokenProvider; 

        public SecurityTokenProviderContainer(SecurityTokenProvider tokenProvider) 
        { 
            if (tokenProvider == null)
            { 
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("tokenProvider");
            }
            this.tokenProvider = tokenProvider;
        } 

        public SecurityTokenProvider TokenProvider 
        { 
            get { return this.tokenProvider; }
        } 

        [MethodImpl(MethodImplOptions.NoInlining)]
        public void Close(TimeSpan timeout)
        { 
            SecurityUtils.CloseTokenProviderIfRequired(this.tokenProvider, timeout);
        } 
 
        [MethodImpl(MethodImplOptions.NoInlining)]
        public void Open(TimeSpan timeout) 
        {
            SecurityUtils.OpenTokenProviderIfRequired(this.tokenProvider, timeout);
        }
 
        [MethodImpl(MethodImplOptions.NoInlining)]
        public void Abort() 
        { 
            SecurityUtils.AbortTokenProviderIfRequired(this.tokenProvider);
        } 

        [MethodImpl(MethodImplOptions.NoInlining)]
        public X509Certificate2 GetCertificate(TimeSpan timeout)
        { 
            X509SecurityToken token = this.tokenProvider.GetToken(timeout) as X509SecurityToken;
            if (token != null) 
            { 
                return token.Certificate;
            } 
            else
            {
                return null;
            } 
        }
    } 
} 

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