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" |
| 31 | #include <ndn-cxx/face.hpp> |
| 32 | #include <ndn-cxx/security/key-chain.hpp> |
| 33 | #include <ndn-cxx/security/validator-config.hpp> |
| 34 | |
| 35 | namespace nsl { |
| 36 | |
| 37 | class Logger |
| 38 | { |
| 39 | public: |
| 40 | class Error : public std::runtime_error |
| 41 | { |
| 42 | public: |
| 43 | explicit |
| 44 | Error(const std::string& what) |
| 45 | : std::runtime_error(what) |
| 46 | { |
| 47 | } |
| 48 | }; |
| 49 | |
| 50 | public: |
| 51 | Logger(ndn::Face& face, const std::string& configFile); |
| 52 | |
| 53 | NonNegativeInteger |
| 54 | addSelfSignedCert(ndn::IdentityCertificate& cert, const Timestamp& timestamp); |
| 55 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 56 | NDN_DELOREAN_PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
Yingdi Yu | 6ff3193 | 2015-03-23 13:30:07 -0700 | [diff] [blame] | 57 | void |
| 58 | initializeKeys(); |
| 59 | |
| 60 | void |
| 61 | loadConfiguration(const std::string& filename); |
| 62 | |
| 63 | void |
| 64 | onSubTreeInterest(const ndn::InterestFilter& interestFilter, const Interest& interest); |
| 65 | |
| 66 | void |
| 67 | onLeafInterest(const ndn::InterestFilter& interestFilter, const Interest& interest); |
| 68 | |
| 69 | void |
| 70 | onLogRequestInterest(const ndn::InterestFilter& interestFilter, const Interest& interest); |
| 71 | |
| 72 | void |
| 73 | requestValidatedCallback(const shared_ptr<const Interest>& interest); |
| 74 | |
| 75 | void |
| 76 | dataReceivedCallback(const Interest& interest, Data& data, |
| 77 | const NonNegativeInteger& signerSeqNo, |
| 78 | const Interest& reqInterest); |
| 79 | |
| 80 | void |
| 81 | dataTimeoutCallback(const Interest& interest, int nRetrials, |
| 82 | const NonNegativeInteger& signerSeqNo, |
| 83 | const Interest& reqInterest); |
| 84 | |
| 85 | void |
| 86 | makeLogResponse(const Interest& reqInterest, const LoggerResponse& response); |
| 87 | |
| 88 | const Name& |
| 89 | getLoggerName() const |
| 90 | { |
| 91 | return m_loggerName; |
| 92 | } |
| 93 | |
| 94 | const Name& |
| 95 | getTreePrefix() const |
| 96 | { |
| 97 | return m_treePrefix; |
| 98 | } |
| 99 | |
| 100 | const Name& |
| 101 | getLeafPrefix() const |
| 102 | { |
| 103 | return m_leafPrefix; |
| 104 | } |
| 105 | |
| 106 | const Name& |
| 107 | getLogPrefix() const |
| 108 | { |
| 109 | return m_logPrefix; |
| 110 | } |
| 111 | |
| 112 | Db& |
| 113 | getDb() |
| 114 | { |
| 115 | return m_db; |
| 116 | } |
| 117 | |
| 118 | private: |
| 119 | static const int N_DATA_FETCHING_RETRIAL; |
| 120 | |
| 121 | private: |
| 122 | ndn::Face& m_face; |
| 123 | Name m_loggerName; |
| 124 | Name m_treePrefix; |
| 125 | Name m_leafPrefix; |
| 126 | Name m_logPrefix; |
| 127 | |
| 128 | Db m_db; |
| 129 | MerkleTree m_merkleTree; |
| 130 | |
| 131 | ndn::KeyChain m_keyChain; |
| 132 | shared_ptr<ndn::IdentityCertificate> m_dskCert; |
| 133 | |
| 134 | ndn::ValidatorConfig m_validator; |
| 135 | PolicyChecker m_policyChecker; |
| 136 | }; |
| 137 | |
| 138 | } // namespace nsl |
| 139 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 140 | #endif // NDN_DELOREAN_CORE_LOGGER_HPP |