All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
pib-key-impl.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_PIB_KEY_IMPL_HPP
24 #define NDN_PIB_KEY_IMPL_HPP
25 
26 #include <ndn-cpp/security/pib/pib-certificate-container.hpp>
27 #include <ndn-cpp/security/security-common.hpp>
28 
29 // Give friend access to the tests.
30 class TestPibKeyImpl_CertificateOperation_Test;
31 
32 namespace ndn {
33 
39 class PibKeyImpl {
40 public:
51  (const Name& keyName, const uint8_t* keyEncoding, size_t keyEncodingLength,
52  const ptr_lib::shared_ptr<PibImpl>& pibImpl);
53 
61  PibKeyImpl(const Name& keyName, const ptr_lib::shared_ptr<PibImpl>& pibImpl);
62 
63  /*
64  * Get the key name.
65  * @return The key name.
66  */
67  const Name&
68  getName() const { return keyName_; }
69 
74  const Name&
75  getIdentityName() const { return identityName_; }
76 
81  KeyType
82  getKeyType() const { return keyType_; }
83 
88  const Blob&
89  getPublicKey() const { return keyEncoding_; }
90 
100  void
101  addCertificate(const CertificateV2& certificate);
102 
110  void
111  removeCertificate(const Name& certificateName);
112 
120  ptr_lib::shared_ptr<CertificateV2>
121  getCertificate(const Name& certificateName);
122 
132  ptr_lib::shared_ptr<CertificateV2>&
133  setDefaultCertificate(const Name& certificateName);
134 
144  ptr_lib::shared_ptr<CertificateV2>&
146  {
147  addCertificate(certificate);
148  return setDefaultCertificate(certificate.getName());
149  }
150 
156  ptr_lib::shared_ptr<CertificateV2>&
158 
159 private:
160  friend class PibKey;
161  // Give friend access to the tests.
162  friend TestPibKeyImpl_CertificateOperation_Test;
163 
164  // Disable the copy constructor and assignment operator.
165  PibKeyImpl(const PibKeyImpl& other);
166  PibKeyImpl& operator=(const PibKeyImpl& other);
167 
168  Name identityName_;
169  Name keyName_;
170  Blob keyEncoding_;
171  KeyType keyType_;
172 
173  ptr_lib::shared_ptr<CertificateV2> defaultCertificate_;
174 
175  PibCertificateContainer certificates_;
176 
177  ptr_lib::shared_ptr<PibImpl> pibImpl_;
178 };
179 
180 }
181 
182 #endif
A PibCertificateContainer is used to search/enumerate the certificates of a key.
Definition: pib-certificate-container.hpp:44
CertificateV2 represents a certificate following the certificate format naming convention.
Definition: certificate-v2.hpp:81
KeyType
Definition: security-common.hpp:50
The PibKey class provides access to a key at the second level in the PIB's Identity-Key-Certificate h...
Definition: pib-key.hpp:43
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<uint8_t>.
Definition: blob.hpp:42
PibKeyImpl provides the backend implementation for PibKey.
Definition: pib-key-impl.hpp:39
ptr_lib::shared_ptr< CertificateV2 > & setDefaultCertificate(const Name &certificateName)
Set the existing certificate with name certificateName as the default certificate.
Definition: pib-key-impl.cpp:98
void removeCertificate(const Name &certificateName)
Remove the certificate with name certificateName.
Definition: pib-key-impl.cpp:80
const Blob & getPublicKey() const
Get the public key encoding.
Definition: pib-key-impl.hpp:89
ptr_lib::shared_ptr< CertificateV2 > & getDefaultCertificate()
Get the default certificate for this Key.
Definition: pib-key-impl.cpp:108
ptr_lib::shared_ptr< CertificateV2 > getCertificate(const Name &certificateName)
Get the certificate with name certificateName.
Definition: pib-key-impl.cpp:91
KeyType getKeyType() const
Get the key type.
Definition: pib-key-impl.hpp:82
void addCertificate(const CertificateV2 &certificate)
Add the certificate.
Definition: pib-key-impl.cpp:73
ptr_lib::shared_ptr< CertificateV2 > & setDefaultCertificate(const CertificateV2 &certificate)
Add the certificate and set it as the default certificate of the key.
Definition: pib-key-impl.hpp:145
PibKeyImpl(const Name &keyName, const uint8_t *keyEncoding, size_t keyEncodingLength, const ptr_lib::shared_ptr< PibImpl > &pibImpl)
Create a PibKeyImpl with keyName.
Definition: pib-key-impl.cpp:34
const Name & getIdentityName() const
Get the name of the identity this key belongs to.
Definition: pib-key-impl.hpp:75