Yingdi Yu | 6ff3193 | 2015-03-23 13:30:07 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, Regents of the University of California |
Yingdi Yu | 6ff3193 | 2015-03-23 13:30:07 -0700 | [diff] [blame] | 4 | * |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame] | 5 | * This file is part of NDN DeLorean, An Authentication System for Data Archives in |
| 6 | * Named Data Networking. See AUTHORS.md for complete list of NDN DeLorean authors |
| 7 | * and contributors. |
Yingdi Yu | 6ff3193 | 2015-03-23 13:30:07 -0700 | [diff] [blame] | 8 | * |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame] | 9 | * NDN DeLorean is free software: you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU General Public License as published by the Free Software |
| 11 | * Foundation, either version 3 of the License, or (at your option) any later |
| 12 | * version. |
Yingdi Yu | 6ff3193 | 2015-03-23 13:30:07 -0700 | [diff] [blame] | 13 | * |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame] | 14 | * NDN DeLorean is distributed in the hope that it will be useful, but WITHOUT ANY |
| 15 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 16 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. |
Yingdi Yu | 6ff3193 | 2015-03-23 13:30:07 -0700 | [diff] [blame] | 17 | * |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame] | 18 | * You should have received a copy of the GNU General Public License along with NDN |
| 19 | * DeLorean, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
Yingdi Yu | 6ff3193 | 2015-03-23 13:30:07 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame] | 22 | #ifndef NDN_DELOREAN_CORE_LOGGER_HPP |
| 23 | #define NDN_DELOREAN_CORE_LOGGER_HPP |
Yingdi Yu | 6ff3193 | 2015-03-23 13:30:07 -0700 | [diff] [blame] | 24 | |
| 25 | #include "common.hpp" |
| 26 | #include "logger-response.hpp" |
| 27 | #include "db.hpp" |
| 28 | #include "policy-checker.hpp" |
| 29 | #include "merkle-tree.hpp" |
| 30 | #include "util/non-negative-integer.hpp" |
Alexander Afanasyev | 49e2e4c | 2017-05-06 13:42:57 -0700 | [diff] [blame] | 31 | |
Yingdi Yu | 6ff3193 | 2015-03-23 13:30:07 -0700 | [diff] [blame] | 32 | #include <ndn-cxx/face.hpp> |
| 33 | #include <ndn-cxx/security/key-chain.hpp> |
| 34 | #include <ndn-cxx/security/validator-config.hpp> |
| 35 | |
Alexander Afanasyev | 49e2e4c | 2017-05-06 13:42:57 -0700 | [diff] [blame] | 36 | namespace ndn { |
| 37 | namespace delorean { |
Yingdi Yu | 6ff3193 | 2015-03-23 13:30:07 -0700 | [diff] [blame] | 38 | |
| 39 | class Logger |
| 40 | { |
| 41 | public: |
| 42 | class Error : public std::runtime_error |
| 43 | { |
| 44 | public: |
| 45 | explicit |
| 46 | Error(const std::string& what) |
| 47 | : std::runtime_error(what) |
| 48 | { |
| 49 | } |
| 50 | }; |
| 51 | |
| 52 | public: |
| 53 | Logger(ndn::Face& face, const std::string& configFile); |
| 54 | |
| 55 | NonNegativeInteger |
| 56 | addSelfSignedCert(ndn::IdentityCertificate& cert, const Timestamp& timestamp); |
| 57 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame] | 58 | NDN_DELOREAN_PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
Yingdi Yu | 6ff3193 | 2015-03-23 13:30:07 -0700 | [diff] [blame] | 59 | void |
| 60 | initializeKeys(); |
| 61 | |
| 62 | void |
| 63 | loadConfiguration(const std::string& filename); |
| 64 | |
| 65 | void |
| 66 | onSubTreeInterest(const ndn::InterestFilter& interestFilter, const Interest& interest); |
| 67 | |
| 68 | void |
| 69 | onLeafInterest(const ndn::InterestFilter& interestFilter, const Interest& interest); |
| 70 | |
| 71 | void |
| 72 | onLogRequestInterest(const ndn::InterestFilter& interestFilter, const Interest& interest); |
| 73 | |
| 74 | void |
| 75 | requestValidatedCallback(const shared_ptr<const Interest>& interest); |
| 76 | |
| 77 | void |
| 78 | dataReceivedCallback(const Interest& interest, Data& data, |
| 79 | const NonNegativeInteger& signerSeqNo, |
| 80 | const Interest& reqInterest); |
| 81 | |
| 82 | void |
| 83 | dataTimeoutCallback(const Interest& interest, int nRetrials, |
| 84 | const NonNegativeInteger& signerSeqNo, |
| 85 | const Interest& reqInterest); |
| 86 | |
| 87 | void |
| 88 | makeLogResponse(const Interest& reqInterest, const LoggerResponse& response); |
| 89 | |
| 90 | const Name& |
| 91 | getLoggerName() const |
| 92 | { |
| 93 | return m_loggerName; |
| 94 | } |
| 95 | |
| 96 | const Name& |
| 97 | getTreePrefix() const |
| 98 | { |
| 99 | return m_treePrefix; |
| 100 | } |
| 101 | |
| 102 | const Name& |
| 103 | getLeafPrefix() const |
| 104 | { |
| 105 | return m_leafPrefix; |
| 106 | } |
| 107 | |
| 108 | const Name& |
| 109 | getLogPrefix() const |
| 110 | { |
| 111 | return m_logPrefix; |
| 112 | } |
| 113 | |
| 114 | Db& |
| 115 | getDb() |
| 116 | { |
| 117 | return m_db; |
| 118 | } |
| 119 | |
| 120 | private: |
| 121 | static const int N_DATA_FETCHING_RETRIAL; |
| 122 | |
| 123 | private: |
| 124 | ndn::Face& m_face; |
| 125 | Name m_loggerName; |
| 126 | Name m_treePrefix; |
| 127 | Name m_leafPrefix; |
| 128 | Name m_logPrefix; |
| 129 | |
| 130 | Db m_db; |
| 131 | MerkleTree m_merkleTree; |
| 132 | |
| 133 | ndn::KeyChain m_keyChain; |
| 134 | shared_ptr<ndn::IdentityCertificate> m_dskCert; |
| 135 | |
| 136 | ndn::ValidatorConfig m_validator; |
| 137 | PolicyChecker m_policyChecker; |
| 138 | }; |
| 139 | |
Alexander Afanasyev | 49e2e4c | 2017-05-06 13:42:57 -0700 | [diff] [blame] | 140 | } // namespace delorean |
| 141 | } // namespace ndn |
Yingdi Yu | 6ff3193 | 2015-03-23 13:30:07 -0700 | [diff] [blame] | 142 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame] | 143 | #endif // NDN_DELOREAN_CORE_LOGGER_HPP |