30 : m_certsByTime(m_certs.get<0>())
31 , m_certsByName(m_certs.get<1>())
32 , m_maxLifetime(maxLifetime)
41 if (notAfterTime < now) {
46 auto removalTime = std::min(notAfterTime, now + m_maxLifetime);
48 << time::duration_cast<time::seconds>(removalTime - now));
49 m_certs.insert(Entry(cert, removalTime));
62 if (certPrefix.
size() > 0 && certPrefix[-1].isImplicitSha256Digest()) {
63 NDN_LOG_INFO(
"Certificate search using name with the implicit digest is not yet supported");
65 auto itr = m_certsByName.lower_bound(certPrefix);
66 if (itr == m_certsByName.end() || !certPrefix.
isPrefixOf(itr->getCertName()))
74 if (interest.
getName().
size() > 0 && interest.
getName()[-1].isImplicitSha256Digest()) {
75 NDN_LOG_INFO(
"Certificate search using name with implicit digest is not yet supported");
79 for (
auto i = m_certsByName.lower_bound(interest.
getName());
82 const auto& cert = i->cert;
91 CertificateCache::refresh()
95 auto cIt = m_certsByTime.begin();
96 while (cIt != m_certsByTime.end() && cIt->removalTime < now) {
97 m_certsByTime.erase(cIt);
98 cIt = m_certsByTime.begin();
const Name & getName() const noexcept
Get the Data name.
Represents an Interest packet.
const Name & getName() const noexcept
Get the Interest name.
bool matchesData(const Data &data) const
Check if this Interest can be satisfied by data.
Represents an absolute name.
size_t size() const noexcept
Returns the number of components.
bool isPrefixOf(const Name &other) const noexcept
Check if this name is a prefix of another name.
Represents a container for verified certificates.
void insert(const Certificate &cert)
Insert certificate into cache.
const Certificate * find(const Name &certPrefix) const
Get certificate given key name.
void clear()
Remove all certificates from cache.
CertificateCache(const time::nanoseconds &maxLifetime=getDefaultLifetime())
Create an object for certificate cache.
Represents an NDN certificate.
ValidityPeriod getValidityPeriod() const
Get validity period of the certificate.
std::pair< time::system_clock::time_point, time::system_clock::time_point > getPeriod() const
Get the stored validity period.
static time_point now() noexcept
#define NDN_LOG_DEBUG(expression)
Log at DEBUG level.
#define NDN_LOG_INFO(expression)
Log at INFO level.
#define NDN_LOG_INIT(name)
Define a non-member log module.
Contains the ndn-cxx security framework.
std::string toIsoString(const system_clock::time_point &timePoint)
Convert to the ISO 8601 string representation, basic format (YYYYMMDDTHHMMSS,fffffffff).
::boost::chrono::nanoseconds nanoseconds