24 #ifndef NDN_PRODUCER_HPP
25 #define NDN_PRODUCER_HPP
28 #include "../face.hpp"
29 #include "../security/key-chain.hpp"
30 #include "encrypt-error.hpp"
31 #include "producer-db.hpp"
42 typedef func_lib::function<
43 void(
const std::vector<ptr_lib::shared_ptr<Data> >& keys)> OnEncryptedKeys;
71 const ptr_lib::shared_ptr<ProducerDb>& database,
int repeatAttempts = 3)
72 : impl_(
new Impl(prefix, dataType, face, keyChain, database, repeatAttempts))
102 return impl_->createContentKey(timeSlot, onEncryptedKeys, onError);
123 impl_->produce(data, timeSlot, content, onError);
130 defaultOnError(EncryptError::ErrorCode errorCode,
const std::string& message);
137 class Impl :
public ptr_lib::enable_shared_from_this<Impl> {
145 const ptr_lib::shared_ptr<ProducerDb>& database,
int repeatAttempts);
167 KeyRequest(
int interests)
169 interestCount = interests;
173 std::map<Name, int> repeatAttempts;
174 std::vector<ptr_lib::shared_ptr<Data> > encryptedKeys;
198 const OnEncryptedKeys& onEncryptedKeys,
214 (
const ptr_lib::shared_ptr<const Interest>& interest,
233 (
const ptr_lib::shared_ptr<const Interest>& interest,
234 const ptr_lib::shared_ptr<NetworkNack>& networkNack,
236 const OnEncryptedKeys& onEncryptedKeys);
250 (
const ptr_lib::shared_ptr<KeyRequest>& keyRequest,
267 (
const ptr_lib::shared_ptr<const Interest>& interest,
269 const OnEncryptedKeys& onEncryptedKeys,
286 (
const Blob& encryptionKey,
const Name& eKeyName,
293 ExcludeEntry(
const Name::Component& component,
bool anyFollowsComponent)
294 : component_(component), anyFollowsComponent_(anyFollowsComponent)
298 Name::Component component_;
299 bool anyFollowsComponent_;
308 getExcludeEntries(
const Exclude& exclude, std::vector<ExcludeEntry>& entries);
316 setExcludeEntries(Exclude& exclude,
const std::vector<ExcludeEntry>& entries);
327 (
const std::vector<ExcludeEntry>& entries,
328 const Name::Component& component);
336 excludeAfter(Exclude& exclude,
const Name::Component& from);
344 excludeBefore(Exclude& exclude,
const Name::Component& to)
346 excludeRange(exclude, Name::Component(), to);
357 (Exclude& exclude,
const Name::Component& from,
const Name::Component& to);
362 std::map<Name, ptr_lib::shared_ptr<KeyInfo> > eKeyInfo_;
363 std::map<MillisecondsSince1970, ptr_lib::shared_ptr<KeyRequest> > keyRequests_;
364 ptr_lib::shared_ptr<ProducerDb> database_;
365 int maxRepeatAttempts_;
367 static const int START_TIME_STAMP_INDEX = -2;
368 static const int END_TIME_STAMP_INDEX = -1;
371 ptr_lib::shared_ptr<Impl> impl_;
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:36
A Producer manages content keys used to encrypt a data packet in the group-based encryption protocol...
Definition: producer.hpp:40
The Face class provides the main methods for NDN communication.
Definition: face.hpp:86
func_lib::function< void(ErrorCode errorCode, const std::string &message)> OnError
A method calls onError(errorCode, message) for an error.
Definition: encrypt-error.hpp:49
void produce(Data &data, MillisecondsSince1970 timeSlot, const Blob &content, const EncryptError::OnError &onError=defaultOnError)
Encrypt the given content with the content key that covers timeSlot, and update the data packet with ...
Definition: producer.hpp:120
Producer(const Name &prefix, const Name &dataType, Face *face, KeyChain *keyChain, const ptr_lib::shared_ptr< ProducerDb > &database, int repeatAttempts=3)
Create a Producer to use the given ProducerDb, Face and other values.
Definition: producer.hpp:70
KeyChain is the main class of the security library.
Definition: key-chain.hpp:45
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.
Definition: blob.hpp:42
double MillisecondsSince1970
The calendar time represented as the number of milliseconds since 1/1/1970.
Definition: common.hpp:117
static void defaultOnError(EncryptError::ErrorCode errorCode, const std::string &message)
The default OnError callback which does nothing.
Definition: producer.cpp:37
Name createContentKey(MillisecondsSince1970 timeSlot, const OnEncryptedKeys &onEncryptedKeys, const EncryptError::OnError &onError=defaultOnError)
Create the content key corresponding to the timeSlot.
Definition: producer.hpp:99