public void Execute(ValidateUserNamePasswordParams parameters) { CredentialProxy credentials; lock (lockObject) { credentialCache.TryGetValue(parameters.UserName, out credentials); } if (credentials != null) { if (CredentialProxy.IsValid(parameters.UserName, parameters.Password, credentials)) { return; } else { lock (lockObject) { credentialCache.Remove(parameters.UserName); } } } ValidateUser(parameters); lock (lockObject) { credentialCache.Add(parameters.UserName, new CredentialProxy(parameters.UserName, parameters.Password)); } }
public static bool IsValid(string userName, string password, CredentialProxy p) { if (p.timeOut >= DateTime.Now) { if ((p.userName == userName) && (p.password == password)) { return(true); } } return(false); }