public async Task <CheckPasswordResult> Check( string password, string ruleSetName = null, string rankingSetName = null, bool isCheckHaveIBeenPwned = false) { RuleSet ruleSet = await this.ruleSetService.GetRuleSet(ruleSetName); RankingSet rankingSet = await this.rankingSetService.GetRankingSet(rankingSetName); // Test Password RuleSetTestResult ruleSetTestResults = ruleSet.Test(password); // Normalize Score int normalizedScore = this.scoreNormalizer.Normalize( ruleSetTestResults.IsSuccess ? ruleSetTestResults : null, ruleSet, rankingSet); // Interpret KeyValuePair <int, string>?interpretedRanking = rankingSet.GetClosestRanking(normalizedScore); PNDPassword pndPassword = null; if (isCheckHaveIBeenPwned) { // Check if pass has been pwned on the external website pndPassword = await this.pndService.HaveIBeenPND(password); } return(new CheckPasswordResult( score: interpretedRanking?.Key, ranking: interpretedRanking?.Value, rankingSet: rankingSet, ruleSet: ruleSet, isSuccess: ruleSetTestResults.IsSuccess, pndPassword: pndPassword, rulesPassed: ruleSetTestResults.RulesPassed, rulesFailed: ruleSetTestResults.RulesFailed, rulesRecommendations: ruleSetTestResults.RulesRecommendations)); }
public CheckPasswordResult( int?score, string ranking, RankingSet rankingSet, RuleSet ruleSet, bool isSuccess, PNDPassword pndPassword, Rule[] rulesPassed, Rule[] rulesFailed, Rule[] rulesRecommendations) { Score = score; Ranking = ranking; RankingSet = rankingSet; RuleSet = ruleSet; IsSuccess = isSuccess; PNDPassword = pndPassword; RulesPassed = rulesPassed; RulesFailed = rulesFailed; RulesRecommendations = rulesRecommendations; }