ndn::security::ValidityPeriod Class Reference

Represents a ValidityPeriod TLV element. More...

#include <ndn-cxx/security/validity-period.hpp>

+ Inheritance diagram for ndn::security::ValidityPeriod:
+ Collaboration diagram for ndn::security::ValidityPeriod:

Classes

class  Error
 

Public Member Functions

 ValidityPeriod ()
 Create a validity period that is invalid for any timepoint. More...
 
 ValidityPeriod (const Block &block)
 Decode validity period from block . More...
 
 ValidityPeriod (const time::system_clock::time_point &notBefore, const time::system_clock::time_point &notAfter)
 Create validity period [notBefore, notAfter]. More...
 
std::pair< time::system_clock::time_point, time::system_clock::time_pointgetPeriod () const
 Get the stored validity period. More...
 
bool isValid (const time::system_clock::time_point &now=time::system_clock::now()) const
 Check if now falls within the validity period. More...
 
ValidityPeriodsetPeriod (const time::system_clock::time_point &notBefore, const time::system_clock::time_point &notAfter)
 Set validity period [notBefore, notAfter]. More...
 
void wireDecode (const Block &wire)
 Decode ValidityPeriod from TLV block. More...
 
const BlockwireEncode () const
 Encode ValidityPeriod into TLV block. More...
 
template<encoding::Tag TAG>
size_t wireEncode (EncodingImpl< TAG > &encoder) const
 Fast encoding or block size estimation. More...
 

Static Public Member Functions

static ValidityPeriod makeRelative (time::seconds validFrom, time::seconds validUntil, const time::system_clock::time_point &now=time::system_clock::now())
 Construct ValidityPeriod relative to a timepoint. More...
 

Friends

bool operator== (const ValidityPeriod &lhs, const ValidityPeriod &rhs)
 

Detailed Description

Represents a ValidityPeriod TLV element.

See also
https://docs.named-data.net/NDN-packet-spec/0.3/certificate.html

Definition at line 35 of file validity-period.hpp.

Constructor & Destructor Documentation

◆ ValidityPeriod() [1/3]

ndn::security::ValidityPeriod::ValidityPeriod ( )

Create a validity period that is invalid for any timepoint.

Definition at line 40 of file validity-period.cpp.

◆ ValidityPeriod() [2/3]

ndn::security::ValidityPeriod::ValidityPeriod ( const Block block)
explicit

Decode validity period from block .

Definition at line 53 of file validity-period.cpp.

◆ ValidityPeriod() [3/3]

ndn::security::ValidityPeriod::ValidityPeriod ( const time::system_clock::time_point notBefore,
const time::system_clock::time_point notAfter 
)

Create validity period [notBefore, notAfter].

Parameters
notBeforeexclusive beginning of the validity period range, to be rounded up to the next whole second.
notAfterexclusive end of the validity period range, to be rounded down to the previous whole second.

Definition at line 46 of file validity-period.cpp.

Member Function Documentation

◆ getPeriod()

std::pair< time::system_clock::time_point, time::system_clock::time_point > ndn::security::ValidityPeriod::getPeriod ( ) const

Get the stored validity period.

Definition at line 170 of file validity-period.cpp.

◆ isValid()

bool ndn::security::ValidityPeriod::isValid ( const time::system_clock::time_point now = time::system_clock::now()) const

Check if now falls within the validity period.

Parameters
nowTime point to check if it falls within the period
Returns
notBefore <= now and now <= notAfter.

Definition at line 176 of file validity-period.cpp.

◆ makeRelative()

ValidityPeriod ndn::security::ValidityPeriod::makeRelative ( time::seconds  validFrom,
time::seconds  validUntil,
const time::system_clock::time_point now = time::system_clock::now() 
)
static

Construct ValidityPeriod relative to a timepoint.

Parameters
validFromNotBefore is computed as now+validFrom. This should be negative to construct a ValidityPeriod that includes now .
validUntilNotAfter is computed as now+validTo. This should be positive to construct a ValidityPeriod that includes now .
nowReference timepoint. Default is current system clock timestamp.

Definition at line 34 of file validity-period.cpp.

◆ setPeriod()

ValidityPeriod & ndn::security::ValidityPeriod::setPeriod ( const time::system_clock::time_point notBefore,
const time::system_clock::time_point notAfter 
)

Set validity period [notBefore, notAfter].

Parameters
notBeforeexclusive beginning of the validity period range, to be rounded up to the next whole second.
notAfterexclusive end of the validity period range, to be rounded down to the previous whole second.

Definition at line 160 of file validity-period.cpp.

◆ wireDecode()

void ndn::security::ValidityPeriod::wireDecode ( const Block wire)

Decode ValidityPeriod from TLV block.

Exceptions
Errorwhen an invalid TLV block supplied.
Note
If either timestamp in wire is earlier than 1677-09-21 or later than 2262-04-11, it will be adjusted to these dates so that they are representable as time::system_clock::time_point type returned by getPeriod() method.

Definition at line 93 of file validity-period.cpp.

◆ wireEncode() [1/2]

const Block & ndn::security::ValidityPeriod::wireEncode ( ) const

Encode ValidityPeriod into TLV block.

Definition at line 75 of file validity-period.cpp.

◆ wireEncode() [2/2]

template<encoding::Tag TAG>
size_t ndn::security::ValidityPeriod::wireEncode ( EncodingImpl< TAG > &  encoder) const

Fast encoding or block size estimation.

Definition at line 60 of file validity-period.cpp.

Friends And Related Function Documentation

◆ operator==

bool operator== ( const ValidityPeriod lhs,
const ValidityPeriod rhs 
)
friend

Definition at line 144 of file validity-period.hpp.