public void KnownHA1Digest() { logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name); logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name); var digest = HTTPDigest.DigestCalcHA1("user", "sipsorcery.cloud", "password"); logger.LogDebug($"Digest = {digest}."); Assert.Equal("f5732e14bef238badb2b4cb987d415f6", digest); logger.LogDebug("-----------------------------------------"); }
public async Task <IActionResult> Edit([Bind("SIPPassword")] SIPAccount sipAccount) { if (ModelState.IsValid) { var passwordHash = HTTPDigest.DigestCalcHA1(User.Identity.Name, _sipDefaultDomain, sipAccount.SIPPassword); await _sipAccountDataLayer.UpdatePassword(User.Identity.Name, _sipDefaultDomain, passwordHash); return(RedirectToAction(nameof(Account))); } else { var presetSIPAccount = await _sipAccountDataLayer.GetSIPAccount(User.Identity.Name, _sipDefaultDomain); presetSIPAccount.SIPPassword = sipAccount.SIPPassword; return(View(presetSIPAccount)); } }
public async Task <IActionResult> Create([Bind("SIPPassword")] SIPAccount sipAccount) { if (ModelState.IsValid) { _logger.LogInformation($"Attempting to create new SIP account for {User.Identity.Name}@{_sipDefaultDomain}."); var passwordHash = HTTPDigest.DigestCalcHA1(User.Identity.Name, _sipDefaultDomain, sipAccount.SIPPassword); var newAccount = await _sipAccountDataLayer.Create(User.Identity.Name, _sipDefaultDomain, passwordHash); TempData["Success"] = $"SIP account successfully created for username {newAccount.AOR}."; return(RedirectToAction(nameof(Account))); } else { var presetSIPAccount = new SIPAccount { Domain = new SIPDomain { Domain = _sipDefaultDomain }, SIPUsername = User.Identity.Name }; return(View(sipAccount)); } }