本文整理匯總了C#中System.IdentityModel.Selectors.UserNamePasswordValidator類的典型用法代碼示例。如果您正苦於以下問題:C# UserNamePasswordValidator類的具體用法?C# UserNamePasswordValidator怎麽用?C# UserNamePasswordValidator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
UserNamePasswordValidator類屬於System.IdentityModel.Selectors命名空間,在下文中一共展示了UserNamePasswordValidator類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Validate
public class MyCustomUserNameValidator : UserNamePasswordValidator
{
// This method validates users. It allows two users, test1 and test2
// with passwords 1tset and 2tset respectively.
// This code is for illustration purposes only and
// MUST NOT be used in a production environment because it is NOT secure.
public override void Validate(string userName, string password)
{
if (null == userName || null == password)
{
throw new ArgumentNullException();
}
if (!(userName == "test1" && password == "1tset") && !(userName == "test2" && password == "2tset"))
{
throw new SecurityTokenException("Unknown Username or Password");
}
}
}