identity-storage.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_IDENTITY_STORAGE_HPP
24 #define NDN_IDENTITY_STORAGE_HPP
25 
26 #include "../../name.hpp"
27 #include "../security-common.hpp"
28 
29 namespace ndn {
30 
31 class IdentityCertificate;
32 class Data;
33 
40 public:
42 
46  virtual
48 
54  virtual bool
55  doesIdentityExist(const Name& identityName) = 0;
56 
61  virtual void
62  addIdentity(const Name& identityName) = 0;
63 
68  virtual bool
69  revokeIdentity() = 0;
70 
77  Name
78  getNewKeyName(const Name& identityName, bool useKsk);
79 
85  virtual bool
86  doesKeyExist(const Name& keyName) = 0;
87 
95  virtual void
96  addKey(const Name& keyName, KeyType keyType, const Blob& publicKeyDer) = 0;
97 
103  virtual Blob
104  getKey(const Name& keyName) = 0;
105 
110  virtual void
111  activateKey(const Name& keyName) = 0;
112 
117  virtual void
118  deactivateKey(const Name& keyName) = 0;
119 
125  virtual bool
126  doesCertificateExist(const Name& certificateName) = 0;
127 
132  virtual void
133  addCertificate(const IdentityCertificate& certificate) = 0;
134 
142  virtual ptr_lib::shared_ptr<IdentityCertificate>
143  getCertificate(const Name &certificateName, bool allowAny = false) = 0;
144 
145 
146  /*****************************************
147  * Get/Set Default *
148  *****************************************/
149 
155  virtual Name
156  getDefaultIdentity() = 0;
157 
164  virtual Name
165  getDefaultKeyNameForIdentity(const Name& identityName) = 0;
166 
174  Name
175  getDefaultCertificateNameForIdentity(const Name& identityName);
176 
184  virtual Name
185  getDefaultCertificateNameForKey(const Name& keyName) = 0;
186 
194  virtual void
196  (const Name& identityName, std::vector<Name>& nameList, bool isDefault) = 0;
197 
203  virtual void
204  setDefaultIdentity(const Name& identityName) = 0;
205 
211  virtual void
212  setDefaultKeyNameForIdentity(const Name& keyName, const Name& identityNameCheck = Name()) = 0;
213 
219  virtual void
220  setDefaultCertificateNameForKey(const Name& keyName, const Name& certificateName) = 0;
221 
222  /*****************************************
223  * Delete Methods *
224  *****************************************/
225 
230  virtual void
231  deleteCertificateInfo(const Name& certificateName) = 0;
232 
237  virtual void
238  deletePublicKeyInfo(const Name& keyName) = 0;
239 
244  virtual void
245  deleteIdentityInfo(const Name& identity) = 0;
246 
247 private:
248  static bool lastTimestampIsInitialized_;
249  static uint64_t lastTimestamp_;
250 };
251 
252 }
253 
254 #endif
Copyright (C) 2013-2015 Regents of the University of California.
Definition: common.hpp:35
virtual bool doesIdentityExist(const Name &identityName)=0
Check if the specified identity already exists.
virtual void setDefaultIdentity(const Name &identityName)=0
Set the default identity.
virtual void addIdentity(const Name &identityName)=0
Add a new identity.
Definition: identity-certificate.hpp:30
Name getDefaultCertificateNameForIdentity(const Name &identityName)
Get the default certificate name for the specified identity.
Definition: identity-storage.cpp:69
virtual Name getDefaultCertificateNameForKey(const Name &keyName)=0
Get the default certificate name for the specified key.
Name getNewKeyName(const Name &identityName, bool useKsk)
Generate a name for a new key belonging to the identity.
Definition: identity-storage.cpp:41
virtual void deletePublicKeyInfo(const Name &keyName)=0
Delete a public key and related certificates.
virtual void setDefaultCertificateNameForKey(const Name &keyName, const Name &certificateName)=0
Set the default key name for the specified identity.
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:42
virtual void deleteCertificateInfo(const Name &certificateName)=0
Delete a certificate.
IdentityStorage is a base class for the storage of identity, public keys and certificates.
Definition: identity-storage.hpp:39
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
virtual bool doesKeyExist(const Name &keyName)=0
Check if the specified key already exists.
virtual void addKey(const Name &keyName, KeyType keyType, const Blob &publicKeyDer)=0
Add a public key to the identity storage.
virtual void addCertificate(const IdentityCertificate &certificate)=0
Add a certificate to the identity storage.
virtual void setDefaultKeyNameForIdentity(const Name &keyName, const Name &identityNameCheck=Name())=0
Set the default key name for the specified identity.
virtual void activateKey(const Name &keyName)=0
Activate a key.
virtual ptr_lib::shared_ptr< IdentityCertificate > getCertificate(const Name &certificateName, bool allowAny=false)=0
Get a certificate from the identity storage.
virtual Name getDefaultIdentity()=0
Get the default identity.
virtual void deleteIdentityInfo(const Name &identity)=0
Delete an identity and related public keys and certificates.
virtual ~IdentityStorage()
The virtual Destructor.
Definition: identity-storage.hpp:47
virtual bool doesCertificateExist(const Name &certificateName)=0
Check if the specified certificate already exists.
virtual Name getDefaultKeyNameForIdentity(const Name &identityName)=0
Get the default key name for the specified identity.
virtual bool revokeIdentity()=0
Revoke the identity.
virtual void getAllKeyNamesOfIdentity(const Name &identityName, std::vector< Name > &nameList, bool isDefault)=0
Append all the key names of a particular identity to the nameList.
virtual void deactivateKey(const Name &keyName)=0
Deactivate a key.
virtual Blob getKey(const Name &keyName)=0
Get the public key DER blob from the identity storage.