net.named_data.jndn.encrypt
public class Consumer extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Consumer.Friend
A class implements Friend if it has a method setConsumerFriendAccess
which setFriendAccess calls to set the FriendAccess object.
|
static class |
Consumer.FriendAccess
A friend class can call the methods of FriendAccess to access private
methods.
|
static interface |
Consumer.OnConsumeComplete |
static interface |
Consumer.OnPlainText |
Constructor and Description |
---|
Consumer(Face face,
KeyChain keyChain,
Name groupName,
Name consumerName,
ConsumerDb database)
Create a Consumer to use the given ConsumerDb, Face and other values.
|
Modifier and Type | Method and Description |
---|---|
void |
addDecryptionKey(Name keyName,
Blob keyBlob)
Add a new decryption key with keyName and keyBlob to the database.
|
void |
consume(Name contentName,
Consumer.OnConsumeComplete onConsumeComplete,
EncryptError.OnError onError)
Express an Interest to fetch the content packet with contentName, and
decrypt it, fetching keys as needed.
|
static void |
setFriendAccess(Consumer.Friend friend)
Call friend.setConsumerFriendAccess to pass an instance of
a FriendAccess class to allow a friend class to call private methods.
|
void |
setGroup(Name groupName)
Set the group name.
|
public Consumer(Face face, KeyChain keyChain, Name groupName, Name consumerName, ConsumerDb database)
face
- The face used for data packet and key fetching.keyChain
- The keyChain used to verify data packets.groupName
- The reading group name that the consumer belongs to.
This makes a copy of the Name.consumerName
- The identity of the consumer. This makes a copy of the
Name.database
- The ConsumerDb database for storing decryption keys.public final void consume(Name contentName, Consumer.OnConsumeComplete onConsumeComplete, EncryptError.OnError onError)
contentName
- The name of the content packet.onConsumeComplete
- When the content packet is fetched and decrypted,
this calls onConsumeComplete.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.onError
- This calls onError.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.public final void setGroup(Name groupName)
groupName
- The reading group name that the consumer belongs to.
This makes a copy of the Name.public final void addDecryptionKey(Name keyName, Blob keyBlob) throws ConsumerDb.Error
keyName
- The key name.keyBlob
- The encoded key.ConsumerDb.Error
- if a key with the same keyName already exists in
the database, or other database error.Error
- if the consumer name is not a prefix of the key name.public static void setFriendAccess(Consumer.Friend friend)
friend
- The friend class for calling setConsumerFriendAccess.
This uses friend.getClass() to make sure that it is a friend class.
Therefore, only a friend class gets an implementation of FriendAccess.Copyright © 2016. All rights reserved.