key-impl.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_SECURITY_PIB_DETAIL_KEY_IMPL_HPP
23 #define NDN_SECURITY_PIB_DETAIL_KEY_IMPL_HPP
24 
25 #include "../../../data.hpp"
26 #include "../certificate-container.hpp"
27 #include "../../security-common.hpp"
28 
29 namespace ndn {
30 namespace security {
31 namespace pib {
32 
33 class PibImpl;
34 
35 namespace detail {
36 
45 class KeyImpl : noncopyable
46 {
47 public:
59  KeyImpl(const Name& keyName, const uint8_t* key, size_t keyLen, shared_ptr<PibImpl> impl);
60 
68  KeyImpl(const Name& keyName, shared_ptr<PibImpl> impl);
69 
71  const Name&
72  getName() const
73  {
74  return m_keyName;
75  }
76 
80  const Name&
81  getIdentity() const
82  {
83  return m_identity;
84  }
85 
89  KeyType
90  getKeyType() const
91  {
92  return m_keyType;
93  }
94 
98  const Buffer&
99  getPublicKey() const
100  {
101  return m_key;
102  }
103 
113  void
114  addCertificate(const v2::Certificate& certificate);
115 
120  void
121  removeCertificate(const Name& certName);
122 
129  getCertificate(const Name& certName) const;
130 
132  const CertificateContainer&
133  getCertificates() const;
134 
141  const v2::Certificate&
142  setDefaultCertificate(const Name& certName);
143 
150  const v2::Certificate&
151  setDefaultCertificate(const v2::Certificate& certificate);
152 
157  const v2::Certificate&
158  getDefaultCertificate() const;
159 
160 private:
161  Name m_identity;
162  Name m_keyName;
163  Buffer m_key;
164  KeyType m_keyType;
165 
166  mutable bool m_isDefaultCertificateLoaded;
167  mutable v2::Certificate m_defaultCertificate;
168 
169  CertificateContainer m_certificates;
170 
171  shared_ptr<PibImpl> m_impl;
172 };
173 
174 } // namespace detail
175 } // namespace pib
176 } // namespace security
177 } // namespace ndn
178 
179 #endif // NDN_SECURITY_PIB_DETAIL_KEY_IMPL_HPP
KeyType getKeyType() const
Get key type.
Definition: key-impl.hpp:90
Copyright (c) 2013-2016 Regents of the University of California.
Definition: common.hpp:74
KeyImpl(const Name &keyName, const uint8_t *key, size_t keyLen, shared_ptr< PibImpl > impl)
Create a KeyImpl with keyName.
Definition: key-impl.cpp:32
The certificate following the certificate format naming convention.
const v2::Certificate & setDefaultCertificate(const Name &certName)
Set an existing one with certName as the default certificate.
Definition: key-impl.cpp:114
const CertificateContainer & getCertificates() const
Get all the certificates for this key.
Definition: key-impl.cpp:106
Container of certificates of a key.
Name abstraction to represent an absolute name.
Definition: name.hpp:46
void removeCertificate(const Name &certName)
Remove a certificate with certName.
Definition: key-impl.cpp:87
const Name & getName() const
Get the name of the key.
Definition: key-impl.hpp:72
v2::Certificate getCertificate(const Name &certName) const
Get a certificate with certName.
Definition: key-impl.cpp:98
Backend instance of Key.
Definition: key-impl.hpp:45
const Buffer & getPublicKey() const
Get public key bits.
Definition: key-impl.hpp:99
void addCertificate(const v2::Certificate &certificate)
Add certificate.
Definition: key-impl.cpp:75
const Name & getIdentity() const
Get the name of the belonging identity.
Definition: key-impl.hpp:81
Class representing a general-use automatically managed/resized buffer.
Definition: buffer.hpp:44
const v2::Certificate & getDefaultCertificate() const
Get the default certificate for this Key.
Definition: key-impl.cpp:132