Created
December 28, 2011 09:01
-
-
Save JoanComasFdz/1527187 to your computer and use it in GitHub Desktop.
Basic custom UserNamePasswordValidator implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomValidator : UserNamePasswordValidator | |
{ | |
public override void Validate(string user_name, string password) | |
{ | |
if (string.IsNullOrEmpty(user_name) || string.IsNullOrEmpty(password)) | |
throw new SecurityTokenException("Username and password required"); | |
if (!(user_name == "test" && password == "test")) | |
throw new SecurityTokenException("Wrong username or password."); | |
// Not throwing exceptions indicates | |
// Credentials accepted | |
Console.WriteLine(string.Format("{0} has authed correct.", user_name)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment