All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Classes | Public Types | Public Member Functions | List of all members
ndn::Consumer Class Reference

A Consumer manages fetched group keys used to decrypt a data packet in the group-based encryption protocol. More...

#include <consumer.hpp>

Public Types

typedef func_lib::function
< void(const
ptr_lib::shared_ptr< Data >
&contentData, const Blob
&result)> 
OnConsumeComplete
 
typedef func_lib::function
< void(const Blob
&decryptedBlob)> 
OnPlainText
 

Public Member Functions

 Consumer (Face *face, KeyChain *keyChain, const Name &groupName, const Name &consumerName, const ptr_lib::shared_ptr< ConsumerDb > &database, const Link &cKeyLink=getNO_LINK(), const Link &dKeyLink=getNO_LINK())
 Create a Consumer to use the given ConsumerDb, Face and other values. More...
 
void consume (const Name &contentName, const OnConsumeComplete &onConsumeComplete, const EncryptError::OnError &onError, const Link &link=getNO_LINK())
 Express an Interest to fetch the content packet with contentName, and decrypt it, fetching keys as needed. More...
 
void setGroup (const Name &groupName)
 Set the group name. More...
 
void addDecryptionKey (const Name &keyName, const Blob &keyBlob)
 Add a new decryption key with keyName and keyBlob to the database. More...
 
void decryptContent (const Data &data, const OnPlainText &onPlainText, const EncryptError::OnError &onError)
 A utility method to decrypt the data packet, retrieving the C-KEY Data from the network if necessary. More...
 

Detailed Description

A Consumer manages fetched group keys used to decrypt a data packet in the group-based encryption protocol.

Note
This class is an experimental feature. The API may change.

Constructor & Destructor Documentation

ndn::Consumer::Consumer ( Face face,
KeyChain keyChain,
const Name groupName,
const Name consumerName,
const ptr_lib::shared_ptr< ConsumerDb > &  database,
const Link cKeyLink = getNO_LINK(),
const Link dKeyLink = getNO_LINK() 
)
inline

Create a Consumer to use the given ConsumerDb, Face and other values.

Parameters
faceThe face used for data packet and key fetching. This is only a pointer to a Face object which must remain valid for the life of this Consumer.
keyChainThe keyChain used to verify data packets. This is only a pointer to a KeyChain object which must remain valid for the life of this Consumer.
groupNameThe reading group name that the consumer belongs to. This makes a copy of the Name.
consumerNameThe identity of the consumer. This makes a copy of the Name.
databaseThe ConsumerDb database for storing decryption keys.
cKeyLink(optional) The Link object to use in Interests for C-KEY retrieval. This makes a copy of the Link object. If the Link object's getDelegations().size() is zero, don't use it. If omitted, don't use a Link object.
dKeyLink(optional) The Link object to use in Interests for D-KEY retrieval. This makes a copy of the Link object. If the Link object's getDelegations().size() is zero, don't use it. If omitted, don't use a Link object.

Member Function Documentation

void ndn::Consumer::addDecryptionKey ( const Name keyName,
const Blob keyBlob 
)
inline

Add a new decryption key with keyName and keyBlob to the database.

Parameters
keyNameThe key name.
keyBlobThe encoded key.
Exceptions
ConsumerDb::Errorif a key with the same keyName already exists in the database, or other database error.
runtime_errorif the consumer name is not a prefix of the key name.
void ndn::Consumer::consume ( const Name contentName,
const OnConsumeComplete &  onConsumeComplete,
const EncryptError::OnError onError,
const Link link = getNO_LINK() 
)
inline

Express an Interest to fetch the content packet with contentName, and decrypt it, fetching keys as needed.

Parameters
contentNameThe name of the content packet.
onConsumeCompleteWhen the content packet is fetched and decrypted, this calls onConsumeComplete(contentData, result) where contentData is the fetched Data packet and result is the decrypted plain text Blob. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.
onErrorThis calls onError(errorCode, message) for an error. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.
link(optional) The Link object to use in Interests for data retrieval. This makes a copy of the Link object. If the Link object's getDelegations().size() is zero, don't use it. If omitted, don't use a Link object.
void ndn::Consumer::decryptContent ( const Data data,
const OnPlainText &  onPlainText,
const EncryptError::OnError onError 
)
inline

A utility method to decrypt the data packet, retrieving the C-KEY Data from the network if necessary.

An application normally does not call this but calls the higher-level consume method.

Parameters
dataThe data packet. This does not verify the packet.
onPlainTextWhen the data packet is decrypted, this calls onPlainText(decryptedBlob) with the decrypted blob.
onErrorThis calls onError(errorCode, message) for an error.
void ndn::Consumer::setGroup ( const Name groupName)
inline

Set the group name.

Parameters
groupNameThe reading group name that the consumer belongs to. This makes a copy of the Name.

The documentation for this class was generated from the following files: