| Index: net/tools/domain_security_preload_generator/preloaded_state_generator.h
|
| diff --git a/net/tools/domain_security_preload_generator/preloaded_state_generator.h b/net/tools/domain_security_preload_generator/preloaded_state_generator.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c6a71ad8dc0a2ce52e0d9625e62a1faa392b9e5a
|
| --- /dev/null
|
| +++ b/net/tools/domain_security_preload_generator/preloaded_state_generator.h
|
| @@ -0,0 +1,73 @@
|
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef NET_TOOLS_DOMAIN_SECURITY_PRELOAD_GENERATOR_PRELOADED_STATE_GENERATOR_H_
|
| +#define NET_TOOLS_DOMAIN_SECURITY_PRELOAD_GENERATOR_PRELOADED_STATE_GENERATOR_H_
|
| +
|
| +#include <stdint.h>
|
| +
|
| +#include <map>
|
| +#include <memory>
|
| +#include <string>
|
| +
|
| +#include "net/tools/domain_security_preload_generator/domain_security_entry.h"
|
| +#include "net/tools/domain_security_preload_generator/pinset.h"
|
| +#include "net/tools/domain_security_preload_generator/pinsets.h"
|
| +#include "net/tools/domain_security_preload_generator/trie/trie_writer.h"
|
| +
|
| +namespace net {
|
| +
|
| +namespace {
|
| +
|
| +class Template {
|
| + public:
|
| + Template(const std::string& tpl) : template_(tpl) {}
|
| + ~Template() {}
|
| +
|
| + bool ReplaceTag(const std::string& name, const std::string& value) {
|
| + std::string tag = "[[" + name + "]]";
|
| +
|
| + size_t start_pos = template_.find(tag);
|
| + if (start_pos == std::string::npos) {
|
| + return false;
|
| + }
|
| +
|
| + template_.replace(start_pos, tag.length(), value);
|
| + return true;
|
| + }
|
| +
|
| + const std::string& GetOutput() const { return template_; }
|
| +
|
| + private:
|
| + std::string template_;
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +class PreloadedStateGenerator {
|
| + public:
|
| + PreloadedStateGenerator();
|
| + ~PreloadedStateGenerator();
|
| +
|
| + std::string Generate(const std::string& preload_template,
|
| + const DomainSecurityEntries& entries,
|
| + const DomainIDList& domain_ids,
|
| + const Pinsets& pinsets,
|
| + bool verbose);
|
| +
|
| + private:
|
| + void ProcessDomainIds(const DomainIDList& domain_ids, NameIDMap* map);
|
| + void ProcessSPKIHashes(const Pinsets& pinset);
|
| + void ProcessExpectCTURIs(const DomainSecurityEntries& entries,
|
| + NameIDMap* expect_ct_report_uri_map);
|
| + void ProcessExpectStapleURIs(const DomainSecurityEntries& entries,
|
| + NameIDMap* expect_staple_report_uri_map);
|
| + void ProcessPinsets(const Pinsets& pinset, NameIDMap* pinset_map);
|
| +
|
| + std::unique_ptr<Template> template_;
|
| +};
|
| +
|
| +} // namespace net
|
| +
|
| +#endif // NET_TOOLS_DOMAIN_SECURITY_PRELOAD_GENERATOR_PRELOADED_STATE_GENERATOR_H_
|
|
|