MCPcopy Create free account
hub / github.com/apple/foundationdb / Rule

Method Rule

flow/TLSConfig.actor.cpp:539–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

537}
538
539TLSPolicy::Rule::Rule(std::string input) {
540 int s = 0;
541
542 while (s < input.size()) {
543 int eq = input.find('=', s);
544
545 if (eq == input.npos)
546 throw std::runtime_error("parse_verify");
547
548 MatchType mt = MatchType::EXACT;
549 if (input[eq - 1] == '>')
550 mt = MatchType::PREFIX;
551 if (input[eq - 1] == '<')
552 mt = MatchType::SUFFIX;
553 std::string term = input.substr(s, eq - s - (mt == MatchType::EXACT ? 0 : 1));
554
555 if (term.find("Check.") == 0) {
556 if (eq + 2 > input.size())
557 throw std::runtime_error("parse_verify");
558 if (eq + 2 != input.size() && input[eq + 2] != ',')
559 throw std::runtime_error("parse_verify");
560 if (mt != MatchType::EXACT)
561 throw std::runtime_error("parse_verify: cannot prefix match Check");
562
563 bool* flag;
564
565 if (term == "Check.Valid")
566 flag = &verify_cert;
567 else if (term == "Check.Unexpired")
568 flag = &verify_time;
569 else
570 throw std::runtime_error("parse_verify");
571
572 if (input[eq + 1] == '0')
573 *flag = false;
574 else if (input[eq + 1] == '1')
575 *flag = true;
576 else
577 throw std::runtime_error("parse_verify");
578
579 s = eq + 3;
580 } else {
581 std::map<int, Criteria>* criteria = &subject_criteria;
582
583 if (term.find('.') != term.npos) {
584 auto scoped = splitPair(term, '.');
585
586 if (scoped.first == "S" || scoped.first == "Subject")
587 criteria = &subject_criteria;
588 else if (scoped.first == "I" || scoped.first == "Issuer")
589 criteria = &issuer_criteria;
590 else if (scoped.first == "R" || scoped.first == "Root")
591 criteria = &root_criteria;
592 else
593 throw std::runtime_error("parse_verify");
594
595 term = scoped.second;
596 }

Callers

nothing calls this directly

Calls 9

substrMethod · 0.80
splitPairFunction · 0.70
de4514Function · 0.70
abbrevToNIDFunction · 0.70
locationForNIDFunction · 0.70
CriteriaClass · 0.50
sizeMethod · 0.45
findMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected