blob: f685495e562118fa5741c7fe7d09bd72d048fb90 [file] [log] [blame]
Yingdi Yu6ff31932015-03-23 13:30:07 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -07003 * Copyright (c) 2014-2017, Regents of the University of California
Yingdi Yu6ff31932015-03-23 13:30:07 -07004 *
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -07005 * 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 Yu6ff31932015-03-23 13:30:07 -07008 *
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -07009 * 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 Yu6ff31932015-03-23 13:30:07 -070013 *
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070014 * 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 Yu6ff31932015-03-23 13:30:07 -070017 *
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070018 * 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 Yu6ff31932015-03-23 13:30:07 -070020 */
21
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070022#ifndef NDN_DELOREAN_CORE_LOGGER_HPP
23#define NDN_DELOREAN_CORE_LOGGER_HPP
Yingdi Yu6ff31932015-03-23 13:30:07 -070024
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
35namespace nsl {
36
37class Logger
38{
39public:
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
50public:
51 Logger(ndn::Face& face, const std::string& configFile);
52
53 NonNegativeInteger
54 addSelfSignedCert(ndn::IdentityCertificate& cert, const Timestamp& timestamp);
55
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070056NDN_DELOREAN_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Yingdi Yu6ff31932015-03-23 13:30:07 -070057 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
118private:
119 static const int N_DATA_FETCHING_RETRIAL;
120
121private:
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 Afanasyevbe998ac2017-05-06 13:11:42 -0700140#endif // NDN_DELOREAN_CORE_LOGGER_HPP