private void textButtonOk_Click(object sender, EventArgs e) { try { _isOk = false; if (string.IsNullOrEmpty(textBoxInput.Text)) { MessageHelper.Popup(WinformRes.Input + ValidationRes.CanNotBeNull); return; } if (VerificationRule.IsNullOrEmpty()) { _isOk = true; } else { _isOk = GetHelper.VerifyPassword(textBoxInput.Text, VerificationRule, VerificationParams); } if (_isOk) { _inputText = textBoxInput.Text; Close(); } } catch (Exception ex) { MessageHelper.Popup(ex.Message); } }
private void TextInputDialog_Load(object sender, EventArgs e) { if (VerificationRule.ToLower().Contains("password")) { textBoxInput.PasswordChar = '*'; } }
public VerificationAttribute (string guideline, string checkpoint, VerificationReportLevel reportLevel, int priority, string message, VerificationRule rule, string conditionalProperty) { }
protected void AddVerificationRule(VerificationRule rule) { if (!_queryValidationRules.ContainsKey(rule.Key)) { _queryValidationRules[rule.Key] = new List <VerificationRule>(); } _queryValidationRules[rule.Key].Add(rule); }
private static VerificationRule GetCalendarChainRules(VerificationRule innerSuccessRules) { return(new CalendarHashChainInputHashVerificationRule() // Int-03 .OnSuccess(new CalendarHashChainAggregationTimeRule() // Int-04 .OnSuccess(new CalendarHashChainRegistrationTimeRule() // Int-05 .OnSuccess(new CalendarHashChainAlgorithmObsoleteRule() // Int-16 .OnSuccess(innerSuccessRules))))); }
private static VerificationRule GetInputVerificationRules(VerificationRule innerSuccessRules) { return(new InputHashAlgorithmVerificationRule() // Gen-04 .OnSuccess(new DocumentHashVerificationRule() // Gen-01 .OnSuccess(new DocumentHashLevelVerificationRule() // Gen-03 .OnSuccess(new InputHashAlgorithmDeprecatedRule() // Int-13 .OnSuccess(innerSuccessRules))))); }
private static VerificationRule GetRfc3161Rules(VerificationRule innerSuccessRules) { return(new Rfc3161RecordHashAlgorithmDeprecatedRule() // Int-14 .OnSuccess(new Rfc3161RecordOutputHashAlgorithmDeprecatedRule() // Int-17 .OnSuccess(new Rfc3161RecordChainIndexRule() // Int-12 .OnSuccess(new Rfc3161RecordOutputHashVerificationRule() // Int-01 .OnSuccess(new Rfc3161RecordAggregationTimeRule() // Int-02 .OnSuccess(innerSuccessRules)))))); }
public VerificationAttribute(string guideline, string checkpoint, VerificationReportLevel reportLevel, int priority, string message, VerificationRule rule, string conditionalProperty) { }
private static VerificationRule GetAggregationChainRules(VerificationRule innerSuccessRules) { return(new AggregationHashChainIndexSuccessorRule() // Int-12 .OnSuccess(new AggregationHashChainMetadataRule() // Int-11 .OnSuccess(new AggregationHashChainAlgorithmDeprecatedRule() // Int-15 .OnSuccess(new AggregationHashChainConsistencyRule() // Int-01 .OnSuccess(new AggregationHashChainTimeConsistencyRule() // Int-02 .OnSuccess(new AggregationHashChainShapeRule() // Int-10 .OnSuccess(innerSuccessRules))))))); }
private VerificationResult DoVerification(IVerificationContext context, bool writeLog = true) { VerificationRule verificationRule = FirstRule; List <VerificationResult> verificationResults = new List <VerificationResult>(); try { while (verificationRule != null) { VerificationPolicy policy = verificationRule as VerificationPolicy; VerificationResult result = policy != null?policy.DoVerification(context, false) : verificationRule.Verify(context); verificationResults.Add(result); verificationRule = verificationRule.NextRule(result.ResultCode); } } catch (Exception e) { KsiVerificationException ksiVerificationException = e as KsiVerificationException; VerificationResult resultFromException = ksiVerificationException?.VerificationResult; // if inner policy has thrown an exception and verification result is set within the exception then add this result to result list. // otherwise add a new result. verificationResults.Add(resultFromException ?? new VerificationResult(verificationRule?.GetRuleName(), VerificationResultCode.Na)); VerificationResult result = new VerificationResult(GetRuleName(), verificationResults); // write log only when topmost policy if (writeLog) { Logger.Warn("Error occured on rule {0}: {1}{2}{3}", verificationRule?.GetRuleName(), e, Environment.NewLine, result); throw; } if (resultFromException != null) { ksiVerificationException.VerificationResult = result; throw ksiVerificationException; } throw new KsiVerificationException(e.Message, e) { VerificationResult = result }; } VerificationResult verificationResult = new VerificationResult(GetRuleName(), verificationResults); // write log only when topmost policy if (writeLog) { Logger.Debug(Environment.NewLine + verificationResult); } return(verificationResult); }
protected override void OnLoad(EventArgs e) { Title = "(*Fudge)"; Session["requested_url"] = Request.RawUrl; if (_requiresLogin) { ErrorHelper.RequireLogin(); } //register menu item on page load ClientScript.RegisterStartupScript(typeof(Page), "startup", String.Format("current={0};", (int)_selectedMenuItem), true); var pageBody = Master.FindControl <HtmlGenericControl>("body"); if (pageBody != null) { pageBody.Attributes["onload"] = "handleLoad()"; } string badKey = String.Empty; int badRule = 0; //check each rule foreach (var rule in _queryValidationRules) { for (int i = 0; i < rule.Value.Count; i++) { VerificationRule r = rule.Value[i]; if (r.Required && (Request.IsQueryStringNull(r.Key) || !r.Rule(Request.QueryString[r.Key]))) { badRule = i; badKey = rule.Key; break; } else if (!r.Required && !Request.IsQueryStringNull(r.Key) && !r.Rule(Request.QueryString[r.Key])) { badRule = i; badKey = rule.Key; break; } } } if (String.IsNullOrEmpty(badKey)) { base.OnLoad(e); } else { var contentPanel = Master.FindControl <Panel>("contentPanel"); contentPanel.Visible = false; var message = Master.FindControl <HtmlGenericControl>("message"); message.Visible = true; message.InnerText = _queryValidationRules[badKey][badRule].ErrorMessage; } }
public IActionResult InsertRule(FormType type, string alias) { var dvr = new DataVerificationRule(); DB.DataVerificationRules.Add(dvr); var vr = new VerificationRule { Alias = alias, RuleId = dvr.Id, Type = type }; DB.VerificationRules.Add(vr); DB.SaveChanges(); DB.Database.ExecuteSqlCommand("UPDATE \"Form\" SET \"Status\"={0}, \"VerificationJson\" = {1} WHERE \"Type\" = {2}", VerificationStatus.Pending, "[]", type); return(RedirectToAction("EditRule", "Data", new { id = vr.Id })); }
/* constructor that implies * ConditionalProperty = String.Empty * VerificationConditionalOperator.Equals * ConditionalValue = String.Empty * GuidelineUrl = String.Empty */ /* * public VerificationAttribute ( * string guideline, * string checkpoint, * VerificationReportLevel reportLevel, * int priority, * string message, * VerificationRule rule) : * this(guideline, * checkpoint, * reportLevel, * priority, * message, * rule, * String.Empty, //ConditionalProperty * VerificationConditionalOperator.Equals, * String.Empty, //ConditionalValue * String.Empty) { //GuidelineUrl * } * */ /*specifying just a ConditionalProperty implies: * VerificationConditionalOperator.NotEquals * ConditionalValue = String.Empty * GuidelineUrl = String.Empty */ public VerificationAttribute( string guideline, string checkpoint, VerificationReportLevel reportLevel, int priority, string message, VerificationRule rule, string conditionalProperty) : this(guideline, checkpoint, reportLevel, priority, message, rule, conditionalProperty, VerificationConditionalOperator.NotEquals, String.Empty, /*ConditionalValue*/ String.Empty /*GuidelineUrl*/) { }
/*implies GuidelineUrl = String.Empty */ internal VerificationAttribute( string guideline, string checkpoint, VerificationReportLevel reportLevel, int priority, string message, VerificationRule rule, string conditionalProperty, VerificationConditionalOperator conditionalOperator, string conditionalValue) : this(guideline, checkpoint, reportLevel, priority, message, rule, conditionalProperty, conditionalOperator, conditionalValue, String.Empty /*GuidelineUrl*/) { }
public VerificationAttribute( string guideline, string checkpoint, VerificationReportLevel reportLevel, int priority, string message, VerificationRule rule, string conditionalProperty, VerificationConditionalOperator conditionalOperator, string conditionalValue, string guidelineUrl) { _guideline = guideline; _checkpoint = checkpoint; _reportLevel = reportLevel; _priority = priority; _message = message; _rule = rule; _conditionalProperty = conditionalProperty; _conditionalOperator = conditionalOperator; _conditionalValue = conditionalValue; _guidelineUrl = guidelineUrl; }
private void textButtonOk_Click(object sender, EventArgs e) { try { IsOk = false; var dt = dateTimePicker.Value; if (!VerificationRule.IsNullOrEmpty()) { if (VerificationRule.ToLower() == "CanNotBeFutureTime".ToLower()) { if (dt.ToUtcTime().IsFutureTime()) { MessageHelper.Popup(WinformRes.Input + ValidationRes.CanNotBeFutureTime); return; } } else if (VerificationRule.ToLower() == "CanNotBePastTime".ToLower()) { if (dt.ToUtcTime().IsPastTime()) { MessageHelper.Popup(WinformRes.Input + ValidationRes.CanNotBePastTime); return; } } else if (VerificationRule.ToLower() == "CanNotBeEarlierThan".ToLower()) { var dt1 = DateTime.ParseExact(VerificationParams, dateTimePicker.CustomFormat, System.Globalization.CultureInfo.CurrentCulture); if (dt < dt1) { MessageHelper.Popup(string.Format(WinformRes.Input + ValidationRes.CanNotBeEarlierThan, VerificationParams)); return; } } else if (VerificationRule.ToLower() == "CanNotBeLaterThan".ToLower()) { var dt1 = DateTime.ParseExact(VerificationParams, dateTimePicker.CustomFormat, System.Globalization.CultureInfo.CurrentCulture); if (dt > dt1) { MessageHelper.Popup(string.Format(WinformRes.Input + ValidationRes.CanNotBeLaterThan, VerificationParams)); return; } } else if (VerificationRule.ToLower() == "ShouldBeBetween".ToLower()) { var verificationParamArry = VerificationParams.GetSubParamArray(true, false); var dt1 = DateTime.ParseExact(verificationParamArry[0], dateTimePicker.CustomFormat, System.Globalization.CultureInfo.CurrentCulture); var dt2 = DateTime.ParseExact(verificationParamArry[1], dateTimePicker.CustomFormat, System.Globalization.CultureInfo.CurrentCulture); if (dt1 > dt2) { MessageHelper.Popup(WinformRes.VerificationParamsHaveProblem); Close(); } if (!(dt > dt1 & dt < dt2)) { MessageHelper.Popup(string.Format(WinformRes.Input + ValidationRes.ShouldBeBetween, verificationParamArry[0], verificationParamArry[1])); return; } } } InputText = dateTimePicker.Text; InputDateTime = dateTimePicker.Value; IsOk = true; Close(); } catch (Exception ex) { MessageHelper.Popup(ex.Message); } }
/* constructor that implies * ConditionalProperty = String.Empty * VerificationConditionalOperator.Equals * ConditionalValue = String.Empty * GuidelineUrl = String.Empty */ /* public VerificationAttribute ( string guideline, string checkpoint, VerificationReportLevel reportLevel, int priority, string message, VerificationRule rule) : this(guideline, checkpoint, reportLevel, priority, message, rule, String.Empty, //ConditionalProperty VerificationConditionalOperator.Equals, String.Empty, //ConditionalValue String.Empty) { //GuidelineUrl } */ /*specifying just a ConditionalProperty implies: * VerificationConditionalOperator.NotEquals * ConditionalValue = String.Empty * GuidelineUrl = String.Empty */ public VerificationAttribute ( string guideline, string checkpoint, VerificationReportLevel reportLevel, int priority, string message, VerificationRule rule, string conditionalProperty) : this(guideline, checkpoint, reportLevel, priority, message, rule, conditionalProperty, VerificationConditionalOperator.NotEquals, String.Empty, /*ConditionalValue*/ String.Empty /*GuidelineUrl*/) { }
/*implies GuidelineUrl = String.Empty */ internal VerificationAttribute ( string guideline, string checkpoint, VerificationReportLevel reportLevel, int priority, string message, VerificationRule rule, string conditionalProperty, VerificationConditionalOperator conditionalOperator, string conditionalValue) : this(guideline, checkpoint, reportLevel, priority, message, rule, conditionalProperty, conditionalOperator, conditionalValue, String.Empty /*GuidelineUrl*/) { }