IOdetteFileService IOdetteFileServiceFactory.CreateFileService(string destinationId, string password) { if (destinationId == this.destinationId) // case sensitive { // check the password var passwordHash = Config.GetAttribute("passwordHash", null); if (passwordHash == null) { if (!String.IsNullOrEmpty(password)) { Log.Warn("Password is empty, but a password is transmitted."); } } else if (!ProcsDE.PasswordCompare(password, passwordHash)) { Log.Warn("Wrong password for asked destination."); return(null); } return(new FileServiceSession(this, GetSessionId())); } else { return(null); } } // func CreateFileService
} // proc RefreshSecurityTokens private bool TestPassword(string testPassword) { var password = ConfigNode.GetAttribute <SecureString>("password"); if (password != null) { return(password.Compare(testPassword)); } else { var passwordHash = Config.GetAttribute("passwordHash", null); if (passwordHash == "*") { return(true); // allow all passwords } try { var tmp = ProcsDE.PasswordCompare(testPassword, passwordHash); if (!tmp) { Log.LogMsg(LogMsgType.Warning, String.Format("Autentification failed ({0}).", "Password")); } return(tmp); } catch (Exception e) { Log.LogMsg(LogMsgType.Error, "Autentification failed ({0}).", e.Message); return(false); } } } // func TestPassword
} // proc RefreshSecurityTokens private bool TestPassword(string testPassword) { var password = Config.GetAttribute("password", null); if (password != null) { return(password == testPassword); } else { try { var l = ProcsDE.PasswordCompare(testPassword, Config.GetAttribute("passwordHash", null)); if (!l) { Log.LogMsg(LogMsgType.Warning, String.Format("Autentification failed ({0}).", "Password")); } return(l); } catch (Exception e) { Log.LogMsg(LogMsgType.Error, "Autentification failed ({0}).", e.Message); return(false); } } } // func TestPassword
} // proc Dispose public override bool Equals(IIdentity other) { if (other is HttpListenerBasicIdentity basicIdentity) { if (String.Compare(userName, other.Name, StringComparison.OrdinalIgnoreCase) != 0) { return(false); } return(ProcsDE.PasswordCompare(basicIdentity.Password, passwordHash)); } else if (other is PpsBasicIdentity checkSql) { if (String.Compare(userName, checkSql.Name, StringComparison.OrdinalIgnoreCase) != 0) { return(false); } return(Procs.CompareBytes(passwordHash, checkSql.passwordHash)); } else { return(false); } } // func Equals