Skip to content

Instantly share code, notes, and snippets.

@JoanComasFdz
Created December 28, 2011 09:01
Show Gist options
  • Save JoanComasFdz/1527187 to your computer and use it in GitHub Desktop.
Save JoanComasFdz/1527187 to your computer and use it in GitHub Desktop.
Basic custom UserNamePasswordValidator implementation
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