key.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_SECURITY_PIB_KEY_HPP
23 #define NDN_SECURITY_PIB_KEY_HPP
24 
26 #include "../security-common.hpp"
27 
28 namespace ndn {
29 namespace security {
30 
31 namespace v2 {
32 class KeyChain;
33 } // namespace v2
34 
35 namespace pib {
36 
37 namespace detail {
38 class KeyImpl;
39 } // namespace detail
40 
49 class Key
50 {
51 public:
70  Key();
71 
77  explicit
78  Key(weak_ptr<detail::KeyImpl> impl);
79 
80  /*
81  * @brief Get key name.
82  */
83  const Name&
84  getName() const;
85 
89  const Name&
90  getIdentity() const;
91 
95  KeyType
96  getKeyType() const;
97 
101  const Buffer&
102  getPublicKey() const;
103 
110  getCertificate(const Name& certName) const;
111 
115  const CertificateContainer&
116  getCertificates() const;
117 
122  const v2::Certificate&
123  getDefaultCertificate() const;
124 
128  operator bool() const;
129 
133  bool
134  operator!() const;
135 
136 NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // write operations should be private
142  void
143  addCertificate(const v2::Certificate& certificate) const;
144 
149  void
150  removeCertificate(const Name& certName) const;
151 
158  const v2::Certificate&
159  setDefaultCertificate(const Name& certName) const;
160 
167  const v2::Certificate&
168  setDefaultCertificate(const v2::Certificate& certificate) const;
169 
170 private:
176  shared_ptr<detail::KeyImpl>
177  lock() const;
178 
179 private:
180  weak_ptr<detail::KeyImpl> m_impl;
181 
182  friend class v2::KeyChain;
183 };
184 
185 } // namespace pib
186 
187 using pib::Key;
188 
189 namespace v2 {
190 
194 Name
195 constructKeyName(const Name& identity, const name::Component& keyId);
196 
200 bool
201 isValidKeyName(const Name& keyName);
202 
206 Name
207 extractIdentityFromKeyName(const Name& keyName);
208 
209 } // namespace v2
210 
211 } // namespace security
212 } // namespace ndn
213 
214 #endif // NDN_SECURITY_PIB_KEY_HPP
const Name & getName() const
Definition: key.cpp:38
Copyright (c) 2013-2016 Regents of the University of California.
Definition: common.hpp:74
The certificate following the certificate format naming convention.
The interface of signing key management.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
bool isValidKeyName(const Name &keyName)
Check if keyName follow the naming conventions for the key name.
Definition: key.cpp:141
Container of certificates of a key.
const CertificateContainer & getCertificates() const
Get all certificates for this key.
Definition: key.cpp:80
A frontend handle of a key instance.
Definition: key.hpp:49
KeyType getKeyType() const
Get key type.
Definition: key.cpp:50
v2::Certificate getCertificate(const Name &certName) const
Get a certificate with certName.
Definition: key.cpp:74
Name abstraction to represent an absolute name.
Definition: name.hpp:46
const Buffer & getPublicKey() const
Get public key bits.
Definition: key.cpp:56
const v2::Certificate & getDefaultCertificate() const
Get the default certificate for this Key.
Definition: key.cpp:98
Component holds a read-only name component value.
Name constructKeyName(const Name &identity, const name::Component &keyId)
Construct key name based on the appropriate naming conventions.
Definition: key.cpp:131
const Name & getIdentity() const
Get the name of the belonging identity.
Definition: key.cpp:44
bool operator!() const
Check if the Key instance is invalid.
Definition: key.cpp:109
Name extractIdentityFromKeyName(const Name &keyName)
Extract identity namespace from the key name keyName.
Definition: key.cpp:148
Class representing a general-use automatically managed/resized buffer.
Definition: buffer.hpp:44
Key()
Default Constructor.
ndn security v2 KeyChain