| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_TOOLS_DOMAIN_SECURITY_PRELOAD_GENERATOR_PRELOADED_STATE_GENERATOR_H_ |
| 6 #define NET_TOOLS_DOMAIN_SECURITY_PRELOAD_GENERATOR_PRELOADED_STATE_GENERATOR_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <map> |
| 11 #include <memory> |
| 12 #include <string> |
| 13 |
| 14 #include "net/tools/domain_security_preload_generator/domain_security_entry.h" |
| 15 #include "net/tools/domain_security_preload_generator/pinset.h" |
| 16 #include "net/tools/domain_security_preload_generator/pinsets.h" |
| 17 #include "net/tools/domain_security_preload_generator/trie/trie_writer.h" |
| 18 |
| 19 namespace net { |
| 20 |
| 21 namespace { |
| 22 |
| 23 class Template { |
| 24 public: |
| 25 Template(const std::string& tpl) : template_(tpl) {} |
| 26 ~Template() {} |
| 27 |
| 28 bool ReplaceTag(const std::string& name, const std::string& value) { |
| 29 std::string tag = "[[" + name + "]]"; |
| 30 |
| 31 size_t start_pos = template_.find(tag); |
| 32 if (start_pos == std::string::npos) { |
| 33 return false; |
| 34 } |
| 35 |
| 36 template_.replace(start_pos, tag.length(), value); |
| 37 return true; |
| 38 } |
| 39 |
| 40 const std::string& GetOutput() const { return template_; } |
| 41 |
| 42 private: |
| 43 std::string template_; |
| 44 }; |
| 45 |
| 46 } // namespace |
| 47 |
| 48 class PreloadedStateGenerator { |
| 49 public: |
| 50 PreloadedStateGenerator(); |
| 51 ~PreloadedStateGenerator(); |
| 52 |
| 53 std::string Generate(const std::string& preload_template, |
| 54 const DomainSecurityEntries& entries, |
| 55 const DomainIDList& domain_ids, |
| 56 const Pinsets& pinsets, |
| 57 bool verbose); |
| 58 |
| 59 private: |
| 60 void ProcessDomainIds(const DomainIDList& domain_ids, NameIDMap* map); |
| 61 void ProcessSPKIHashes(const Pinsets& pinset); |
| 62 void ProcessExpectCTURIs(const DomainSecurityEntries& entries, |
| 63 NameIDMap* expect_ct_report_uri_map); |
| 64 void ProcessExpectStapleURIs(const DomainSecurityEntries& entries, |
| 65 NameIDMap* expect_staple_report_uri_map); |
| 66 void ProcessPinsets(const Pinsets& pinset, NameIDMap* pinset_map); |
| 67 |
| 68 std::unique_ptr<Template> template_; |
| 69 }; |
| 70 |
| 71 } // namespace net |
| 72 |
| 73 #endif // NET_TOOLS_DOMAIN_SECURITY_PRELOAD_GENERATOR_PRELOADED_STATE_GENERATOR
_H_ |
| OLD | NEW |