All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
group-manager.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_GROUP_MANAGER_HPP
24 #define NDN_GROUP_MANAGER_HPP
25 
26 #include "../security/certificate/identity-certificate.hpp"
27 #include "group-manager-db.hpp"
28 
29 // Give friend access to the tests.
30 class TestGroupManager_CreateDKeyData_Test;
31 class TestGroupManager_CreateEKeyData_Test;
32 class TestGroupManager_CalculateInterval_Test;
33 
34 namespace ndn {
35 
36 class KeyChain;
37 
43 class GroupManager {
44 public:
60  (const Name& prefix, const Name& dataType,
61  const ptr_lib::shared_ptr<GroupManagerDb>& database, uint32_t keySize,
62  int freshnessHours, KeyChain* keyChain);
63 
80  void
82  (MillisecondsSince1970 timeSlot,
83  std::vector<ptr_lib::shared_ptr<Data> >& result,
84  bool needRegenerate = true);
85 
93  void
94  addSchedule(const std::string& scheduleName, const Schedule& schedule)
95  {
96  database_->addSchedule(scheduleName, schedule);
97  }
98 
105  void
106  deleteSchedule(const std::string& scheduleName)
107  {
108  database_->deleteSchedule(scheduleName);
109  }
110 
119  void
120  updateSchedule(const std::string& scheduleName, const Schedule& schedule)
121  {
122  database_->updateSchedule(scheduleName, schedule);
123  }
124 
136  void
137  addMember(const std::string& scheduleName, const Data& memberCertificate)
138  {
139  IdentityCertificate cert(memberCertificate);
140  database_->addMember
141  (scheduleName, cert.getPublicKeyName(), cert.getPublicKeyInfo().getKeyDer());
142  }
143 
150  void
151  removeMember(const Name& identity)
152  {
153  database_->deleteMember(identity);
154  }
155 
163  void
164  updateMemberSchedule(const Name& identity, const std::string& scheduleName)
165  {
166  database_->updateMemberSchedule(identity, scheduleName);
167  }
168 
175  void
176  cleanEKeys() { database_->cleanEKeys(); }
177 
178 private:
179  // Give friend access to the tests.
180  friend TestGroupManager_CreateDKeyData_Test;
181  friend TestGroupManager_CreateEKeyData_Test;
182  friend TestGroupManager_CalculateInterval_Test;
183 
193  Interval
194  calculateInterval
195  (MillisecondsSince1970 timeSlot, std::map<Name, Blob>& memberKeys);
196 
204  void
205  generateKeyPair(Blob& privateKeyBlob, Blob& publicKeyBlob);
206 
215  ptr_lib::shared_ptr<Data>
216  createEKeyData
217  (const std::string& startTimeStamp, const std::string& endTimeStamp,
218  const Blob& publicKeyBlob);
219 
233  ptr_lib::shared_ptr<Data>
234  createDKeyData
235  (const std::string& startTimeStamp, const std::string& endTimeStamp,
236  const Name& keyName, const Blob& privateKeyBlob, const Blob& certificateKey);
237 
246  void
247  addEKey(const Name& eKeyName, const Blob& publicKey, const Blob& privateKey)
248  {
249  database_->addEKey(eKeyName, publicKey, privateKey);
250  }
251 
260  void
261  getEKey(const Name& eKeyName, Blob& publicKey, Blob& privateKey)
262  {
263  database_->getEKey(eKeyName, publicKey, privateKey);
264  }
265 
272  void
273  deleteEKey(const Name& eKeyName)
274  {
275  database_-> deleteEKey(eKeyName);
276  }
277 
278  Name namespace_;
279  ptr_lib::shared_ptr<GroupManagerDb> database_;
280  uint32_t keySize_;
281  int freshnessHours_;
282  KeyChain* keyChain_;
283  static const uint64_t MILLISECONDS_IN_HOUR = 3600 * 1000;
284 };
285 
286 }
287 
288 #endif
A GroupManager manages keys and schedules for group members in a particular namespace.
Definition: group-manager.hpp:43
An Interval defines a time duration which contains a start timestamp and an end timestamp.
Definition: interval.hpp:36
void deleteSchedule(const std::string &scheduleName)
Delete the schedule with the given scheduleName.
Definition: group-manager.hpp:106
void updateMemberSchedule(const Name &identity, const std::string &scheduleName)
Change the name of the schedule for the given member's identity name.
Definition: group-manager.hpp:164
Schedule is used to manage the times when a member can access data using two sets of RepetitiveInterv...
Definition: schedule.hpp:43
Definition: data.hpp:37
void removeMember(const Name &identity)
Remove a member with the given identity name.
Definition: group-manager.hpp:151
Definition: identity-certificate.hpp:30
void getGroupKey(MillisecondsSince1970 timeSlot, std::vector< ptr_lib::shared_ptr< Data > > &result, bool needRegenerate=true)
Create a group key for the interval into which timeSlot falls.
Definition: group-manager.cpp:48
void addSchedule(const std::string &scheduleName, const Schedule &schedule)
Add a schedule with the given scheduleName.
Definition: group-manager.hpp:94
KeyChain is the main class of the security library.
Definition: key-chain.hpp:53
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
A Blob holds a pointer to an immutable byte array implemented as const std::vector<uint8_t>.
Definition: blob.hpp:42
GroupManager(const Name &prefix, const Name &dataType, const ptr_lib::shared_ptr< GroupManagerDb > &database, uint32_t keySize, int freshnessHours, KeyChain *keyChain)
Create a group manager with the given values.
Definition: group-manager.cpp:34
double MillisecondsSince1970
The calendar time represented as the number of milliseconds since 1/1/1970.
Definition: common.hpp:119
void addMember(const std::string &scheduleName, const Data &memberCertificate)
Add a new member with the given memberCertificate into a schedule named scheduleName.
Definition: group-manager.hpp:137
void updateSchedule(const std::string &scheduleName, const Schedule &schedule)
Update the schedule with scheduleName and replace the old object with the given schedule.
Definition: group-manager.hpp:120
void cleanEKeys()
Delete all the EKeys in the database.
Definition: group-manager.hpp:176