blob: 2db82b18e3923e5a0391bbc296cfc506dd343ba5 [file] [log] [blame]
Jeff Thompson41471912013-09-12 16:21:50 -07001/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07002 * Copyright (C) 2013 Regents of the University of California.
Jeff Thompson06e787d2013-09-12 19:00:55 -07003 * @author: Yingdi Yu <yingdi@cs.ucla.edu>
Jeff Thompson7687dc02013-09-13 11:54:07 -07004 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson41471912013-09-12 16:21:50 -07005 * See COPYING for copyright and distribution information.
6 */
7
8#ifndef NDN_IDENTITY_MANAGER_HPP
9#define NDN_IDENTITY_MANAGER_HPP
10
Jeff Thompson7b79eb62013-09-12 18:48:29 -070011#include "../../data.hpp"
Jeff Thompson86e1d752013-09-17 17:22:38 -070012#include "private-key-storage.hpp"
Jeff Thompson41471912013-09-12 16:21:50 -070013
14namespace ndn {
15
Jeff Thompsonffa36f92013-09-20 08:42:41 -070016/**
17 * An IdentityManager is the interface of operations related to identity, keys, and certificates.
18 */
Jeff Thompson41471912013-09-12 16:21:50 -070019class IdentityManager {
20public:
Jeff Thompson86e1d752013-09-17 17:22:38 -070021 IdentityManager(const ptr_lib::shared_ptr<PrivateKeyStorage> &privateKeyStorage)
22 : privateKeyStorage_(privateKeyStorage)
23 {
24 }
25
Jeff Thompson41471912013-09-12 16:21:50 -070026 /**
Jeff Thompson86e1d752013-09-17 17:22:38 -070027 * Sign data packet based on the certificate name.
Jeff Thompson41471912013-09-12 16:21:50 -070028 * Note: the caller must make sure the timestamp in data is correct, for example with
29 * data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0).
30 * @param data The Data object to sign and update its signature.
31 * @param certificateName The Name identifying the certificate which identifies the signing key.
32 * @param wireFormat The WireFormat for calling encodeData, or WireFormat::getDefaultWireFormat() if omitted.
33 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070034 void
Jeff Thompson86e1d752013-09-17 17:22:38 -070035 signByCertificate(Data& data, const Name& certificateName, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat());
36
37private:
38 ptr_lib::shared_ptr<PrivateKeyStorage> privateKeyStorage_;
Jeff Thompson41471912013-09-12 16:21:50 -070039};
40
41}
42
43#endif