Abstraction of validity period. More...
#include <validity-period.hpp>
Classes | |
class | Error |
Public Member Functions | |
ValidityPeriod () | |
Set validity period [UNIX epoch + 1 nanosecond, UNIX epoch] that is always invalid. More... | |
ValidityPeriod (const Block &block) | |
Create validity period from block . More... | |
ValidityPeriod (const time::system_clock::TimePoint ¬Before, const time::system_clock::TimePoint ¬After) | |
Create validity period [notBefore , notAfter ]. More... | |
bool | isValid (const time::system_clock::TimePoint &now=time::system_clock::now()) const |
Check if now falls within the validity period. More... | |
ValidityPeriod & | setPeriod (const time::system_clock::TimePoint ¬Before, const time::system_clock::TimePoint ¬After) |
Set validity period [notBefore , notAfter ]. More... | |
std::pair< time::system_clock::TimePoint, time::system_clock::TimePoint > | getPeriod () const |
Get the stored validity period. More... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder) const |
Fast encoding or block size estimation. More... | |
const Block & | wireEncode () const |
Encode ValidityPeriod into TLV block. More... | |
void | wireDecode (const Block &wire) |
Decode ValidityPeriod from TLV block. More... | |
bool | operator== (const ValidityPeriod &other) const |
bool | operator!= (const ValidityPeriod &other) const |
Abstraction of validity period.
Definition at line 37 of file validity-period.hpp.
ndn::security::ValidityPeriod::ValidityPeriod | ( | ) |
Set validity period [UNIX epoch + 1 nanosecond, UNIX epoch] that is always invalid.
Definition at line 42 of file validity-period.cpp.
Referenced by ndn::security::ValidityPeriod::Error::Error().
|
explicit |
Create validity period from block
.
Definition at line 56 of file validity-period.cpp.
References wireDecode().
ndn::security::ValidityPeriod::ValidityPeriod | ( | const time::system_clock::TimePoint & | notBefore, |
const time::system_clock::TimePoint & | notAfter | ||
) |
Create validity period [notBefore
, notAfter
].
notBefore | exclusive beginning of the validity period range |
notAfter | exclusive end of the validity period range |
notBefore
is rounded up the next whole secondnotAfter
is truncated to the previous whole second Definition at line 48 of file validity-period.cpp.
bool ndn::security::ValidityPeriod::isValid | ( | const time::system_clock::TimePoint & | now = time::system_clock::now() | ) | const |
Check if now
falls within the validity period.
now | Time point to check if it falls within the period |
now
and now
<= periodEnd Definition at line 147 of file validity-period.cpp.
Referenced by ndn::security::ValidityPeriod::Error::Error(), and ndn::security::v2::Certificate::isValid().
ValidityPeriod & ndn::security::ValidityPeriod::setPeriod | ( | const time::system_clock::TimePoint & | notBefore, |
const time::system_clock::TimePoint & | notAfter | ||
) |
Set validity period [notBefore
, notAfter
].
notBefore | exclusive beginning of the validity period range |
notAfter | exclusive end of the validity period range |
notBefore
is rounded up the next whole secondnotAfter
is truncated to the previous whole second Definition at line 130 of file validity-period.cpp.
References ndn::Block::reset().
Referenced by ndn::security::ValidityPeriod::Error::Error().
std::pair< time::system_clock::TimePoint, time::system_clock::TimePoint > ndn::security::ValidityPeriod::getPeriod | ( | ) | const |
Get the stored validity period.
Definition at line 141 of file validity-period.cpp.
Referenced by ndn::security::ValidityPeriod::Error::Error(), ndn::security::v2::CertificateCache::insert(), ndn::security::v2::operator<<(), and ndn::security::operator<<().
size_t ndn::security::ValidityPeriod::wireEncode | ( | EncodingImpl< TAG > & | encoder | ) | const |
Fast encoding or block size estimation.
Definition at line 63 of file validity-period.cpp.
References ndn::security::NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(), ndn::tlv::NotAfter, ndn::tlv::NotBefore, ndn::encoding::prependStringBlock(), ndn::time::toIsoString(), and ndn::tlv::ValidityPeriod.
Referenced by ndn::SignatureInfo::setValidityPeriod().
const Block & ndn::security::ValidityPeriod::wireEncode | ( | ) | const |
Encode ValidityPeriod into TLV block.
Definition at line 78 of file validity-period.cpp.
References ndn::Block::hasWire(), and ndn::Block::parse().
Referenced by ndn::security::ValidityPeriod::Error::Error().
void ndn::security::ValidityPeriod::wireDecode | ( | const Block & | wire | ) |
Decode ValidityPeriod from TLV block.
Error | when an invalid TLV block supplied |
Definition at line 96 of file validity-period.cpp.
References ndn::Block::elements(), ndn::Block::elements_size(), ndn::time::fromIsoString(), ndn::Block::hasWire(), ndn::security::ISO_DATETIME_SIZE, ndn::security::NOT_AFTER_OFFSET, ndn::security::NOT_BEFORE_OFFSET, ndn::tlv::NotAfter, ndn::tlv::NotBefore, ndn::Block::parse(), ndn::encoding::readString(), ndn::Block::type(), and ndn::tlv::ValidityPeriod.
Referenced by ndn::security::ValidityPeriod::Error::Error(), and ValidityPeriod().
bool ndn::security::ValidityPeriod::operator== | ( | const ValidityPeriod & | other | ) | const |
Definition at line 153 of file validity-period.cpp.
Referenced by ndn::security::ValidityPeriod::Error::Error().
bool ndn::security::ValidityPeriod::operator!= | ( | const ValidityPeriod & | other | ) | const |
Definition at line 160 of file validity-period.cpp.
Referenced by ndn::security::ValidityPeriod::Error::Error().