password
= null;
user = null;
bool
isValidUsername = false;
// it's a good security practice to
be defensive
// and assume that the user is initially invalid
if (username.Equals("admin"))
{
password = "secret-password123";
isValidUsername
= true;
user = DigestHelper.MakeSimpleUser("Administrator");
//
'admin' is a valid username for our application.
// The Client password should be 'secret-password123'
// We are also associating the name 'Administrator'
// with the identity of the Client
}
else if (username.Equals("mickey"))
{
password
= "mouse-password";
isValidUsername
= true;
user = DigestHelper.MakeSimpleUser("MickeyMouse");
//
'mickey' is also a valid username for our application.
// The Client password should be 'mouse-password'
// We are also associating the name 'MickeyMouse'
// with the identity of the Client
}
else
{
password
= null;
isValidUsername = false;
user = null;
//
We do not know any other users.
// Therefore, the Username is not valid!
// Therefore, password =
null and user
= null
}
return
isValidUsername;
//
return the outcome of our simple validation