| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_PINSETS_H_ | 5 #ifndef NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_PINSETS_H_ |
| 6 #define NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_PINSETS_H_ | 6 #define NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_PINSETS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
| 14 #include "net/tools/transport_security_state_generator/cert_util.h" | 15 #include "net/tools/transport_security_state_generator/cert_util.h" |
| 15 #include "net/tools/transport_security_state_generator/pinset.h" | 16 #include "net/tools/transport_security_state_generator/pinset.h" |
| 16 #include "net/tools/transport_security_state_generator/spki_hash.h" | 17 #include "net/tools/transport_security_state_generator/spki_hash.h" |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 | 20 |
| 20 namespace transport_security_state { | 21 namespace transport_security_state { |
| 21 | 22 |
| 22 // Contains SPKIHashes and their names. The names are used to reference | 23 // Contains SPKIHashes and their names. The names are used to reference |
| 23 // the hashes from Pinset's. | 24 // the hashes from Pinset's. |
| 24 using SPKIHashMap = std::map<std::string, SPKIHash>; | 25 using SPKIHashMap = std::map<std::string, SPKIHash>; |
| 25 using PinsetMap = std::map<std::string, std::unique_ptr<Pinset>>; | 26 using PinsetMap = std::map<std::string, std::unique_ptr<Pinset>>; |
| 26 | 27 |
| 27 class Pinsets { | 28 class Pinsets { |
| 28 public: | 29 public: |
| 29 Pinsets(); | 30 Pinsets(); |
| 30 ~Pinsets(); | 31 ~Pinsets(); |
| 31 | 32 |
| 32 void RegisterSPKIHash(base::StringPiece name, const SPKIHash& hash); | 33 void RegisterSPKIHash(base::StringPiece name, const SPKIHash& hash); |
| 33 void RegisterPinset(std::unique_ptr<Pinset> set); | 34 void RegisterPinset(std::unique_ptr<Pinset> set); |
| 34 | 35 |
| 36 // Removes all Pinsets whose name is not in |except_these|. Also removes the |
| 37 // SPKI Hashes that are no longer referenced by the remaining pinsets. |
| 38 void FilterPinsets(const std::set<std::string>& except_these); |
| 39 |
| 35 size_t size() const { return pinsets_.size(); } | 40 size_t size() const { return pinsets_.size(); } |
| 36 size_t spki_size() const { return spki_hashes_.size(); } | 41 size_t spki_size() const { return spki_hashes_.size(); } |
| 37 | 42 |
| 38 const SPKIHashMap& spki_hashes() const { return spki_hashes_; } | 43 const SPKIHashMap& spki_hashes() const { return spki_hashes_; } |
| 39 const PinsetMap& pinsets() const { return pinsets_; } | 44 const PinsetMap& pinsets() const { return pinsets_; } |
| 40 | 45 |
| 41 private: | 46 private: |
| 42 // Contains all SPKI hashes found in the input pins file. | 47 // Contains all SPKI hashes found in the input pins file. |
| 43 SPKIHashMap spki_hashes_; | 48 SPKIHashMap spki_hashes_; |
| 44 | 49 |
| 45 // Contains all pinsets in the input JSON file. | 50 // Contains all pinsets in the input JSON file. |
| 46 PinsetMap pinsets_; | 51 PinsetMap pinsets_; |
| 47 | 52 |
| 48 DISALLOW_COPY_AND_ASSIGN(Pinsets); | 53 DISALLOW_COPY_AND_ASSIGN(Pinsets); |
| 49 }; | 54 }; |
| 50 | 55 |
| 51 } // namespace transport_security_state | 56 } // namespace transport_security_state |
| 52 | 57 |
| 53 } // namespace net | 58 } // namespace net |
| 54 | 59 |
| 55 #endif // NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_PINSETS_H_ | 60 #endif // NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_PINSETS_H_ |
| OLD | NEW |