31 const time::nanoseconds&
34 static time::nanoseconds lifetime = time::seconds(3600);
39 : m_certsByTime(m_certs.get<0>())
40 , m_certsByName(m_certs.get<1>())
41 , m_maxLifetime(maxLifetime)
50 if (notAfterTime < now) {
57 << time::duration_cast<time::seconds>(removalTime - now));
58 m_certs.insert(Entry(cert, removalTime));
65 if (certPrefix.
size() > 0 && certPrefix[-1].isImplicitSha256Digest()) {
66 NDN_LOG_INFO(
"Certificate search using name with the implicit digest is not yet supported");
68 auto itr = m_certsByName.lower_bound(certPrefix);
69 if (itr == m_certsByName.end() || !certPrefix.
isPrefixOf(itr->getCertName()))
78 NDN_LOG_DEBUG(
"Certificate search using ChildSelector is not supported, searching as if selector not specified");
80 if (interest.
getName().
size() > 0 && interest.
getName()[-1].isImplicitSha256Digest()) {
81 NDN_LOG_INFO(
"Certificate search using name with implicit digest is not yet supported");
85 for (
auto i = m_certsByName.lower_bound(interest.
getName());
88 const auto& cert = i->cert;
97 CertificateCache::refresh()
101 auto cIt = m_certsByTime.begin();
102 while (cIt != m_certsByTime.end() && cIt->removalTime < now) {
103 m_certsByTime.erase(cIt);
104 cIt = m_certsByTime.begin();
const Name & getName() const
Copyright (c) 2013-2016 Regents of the University of California.
The certificate following the certificate format naming convention.
ValidityPeriod getValidityPeriod() const
Get validity period of the certificate.
represents an Interest packet
#define NDN_LOG_DEBUG(expression)
log at DEBUG level
#define NDN_LOG_INIT(name)
declare a log module
static time_point now() noexcept
const Certificate * find(const Name &certPrefix) const
Get certificate given key name.
int getChildSelector() const
const Name & getName() const
Get name of the Data packet.
Represents a container for verified certificates.
CertificateCache(const time::nanoseconds &maxLifetime=getDefaultLifetime())
Create an object for certificate cache.
std::pair< time::system_clock::TimePoint, time::system_clock::TimePoint > getPeriod() const
Get the stored validity period.
size_t size() const
Get the number of components.
Name abstraction to represent an absolute name.
#define NDN_LOG_INFO(expression)
log at INFO level
bool matchesData(const Data &data) const
Check if Interest can be satisfied by data.
std::string toIsoString(const system_clock::TimePoint &timePoint)
Convert to the ISO string representation of the time (YYYYMMDDTHHMMSS,fffffffff)
static const time::nanoseconds & getDefaultLifetime()
void insert(const Certificate &cert)
Insert certificate into cache.
bool isPrefixOf(const Name &name) const
Check if the N components of this name are the same as the first N components of the given name...