UserNamePasswordValidator.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / Selectors / UserNamePasswordValidator.cs / 1305376 / UserNamePasswordValidator.cs

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

namespace System.IdentityModel.Selectors 
{
    using System.IdentityModel.Tokens; 
    using System.Web.Security; 

    public abstract class UserNamePasswordValidator 
    {
        static UserNamePasswordValidator none;

        public static UserNamePasswordValidator None 
        {
            get 
            { 
                if (none == null)
                    none = new NoneUserNamePasswordValidator(); 
                return none;
            }
        }
 
        public static UserNamePasswordValidator CreateMembershipProviderValidator(MembershipProvider provider)
        { 
            if (provider == null) 
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("provider");
            return new MembershipProviderValidator(provider); 
        }

        public abstract void Validate(string userName, string password);
 
        class NoneUserNamePasswordValidator : UserNamePasswordValidator
        { 
            public override void Validate(string userName, string password) 
            {
            } 
        }

        class MembershipProviderValidator : UserNamePasswordValidator
        { 
            MembershipProvider provider;
 
            public MembershipProviderValidator(MembershipProvider provider) 
            {
                this.provider = provider; 
            }

            public override void Validate(string userName, string password)
            { 
                if (!this.provider.ValidateUser(userName, password))
                { 
                    throw  DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenValidationException( 
                        SR.GetString(SR.UserNameAuthenticationFailed, this.provider.GetType().Name)));
                } 
            }
        }
    }
} 

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

namespace System.IdentityModel.Selectors 
{
    using System.IdentityModel.Tokens; 
    using System.Web.Security; 

    public abstract class UserNamePasswordValidator 
    {
        static UserNamePasswordValidator none;

        public static UserNamePasswordValidator None 
        {
            get 
            { 
                if (none == null)
                    none = new NoneUserNamePasswordValidator(); 
                return none;
            }
        }
 
        public static UserNamePasswordValidator CreateMembershipProviderValidator(MembershipProvider provider)
        { 
            if (provider == null) 
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("provider");
            return new MembershipProviderValidator(provider); 
        }

        public abstract void Validate(string userName, string password);
 
        class NoneUserNamePasswordValidator : UserNamePasswordValidator
        { 
            public override void Validate(string userName, string password) 
            {
            } 
        }

        class MembershipProviderValidator : UserNamePasswordValidator
        { 
            MembershipProvider provider;
 
            public MembershipProviderValidator(MembershipProvider provider) 
            {
                this.provider = provider; 
            }

            public override void Validate(string userName, string password)
            { 
                if (!this.provider.ValidateUser(userName, password))
                { 
                    throw  DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenValidationException( 
                        SR.GetString(SR.UserNameAuthenticationFailed, this.provider.GetType().Name)));
                } 
            }
        }
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

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