Leosac  0.8.0
Open Source Access Control
Leosac::Auth::ValidityInfo Class Reference

A simple class that stores (and can be queried for) the validity of some objects. More...

#include <ValidityInfo.hpp>

Public Types

using TimePoint = std::chrono::system_clock::time_point
 

Public Member Functions

 ValidityInfo ()
 Default status is: enabled and no time-based limitation. More...
 
 ValidityInfo (const ValidityInfo &)=default
 
bool is_valid () const
 Check that the current date is between validity start and end and make sure its enabled too. More...
 
bool is_enabled () const
 Is the credential enabled ? More...
 
bool is_in_range () const
 Are we currently is the validity range of the credential ? More...
 
void set_start_date (const std::string &s)
 Set the start validity date. More...
 
void set_end_date (const std::string &s)
 Set the end validity date. More...
 
void set_enabled (bool v)
 
const TimePointstart () const
 
void start (const TimePoint &tp)
 
const TimePointend () const
 
void end (const TimePoint &tp)
 

Private Attributes

TimePoint start_
 
TimePoint end_
 
bool enabled_
 

Friends

class odb::access
 

Detailed Description

A simple class that stores (and can be queried for) the validity of some objects.

Validity means 3 simple thing:

  • Is is enabled ?
  • The validity start date.
  • The validity end date.

You can set validity_start to time::min(), and validity_end to time::max if there is no validity date.

Definition at line 42 of file ValidityInfo.hpp.

Member Typedef Documentation

◆ TimePoint

using Leosac::Auth::ValidityInfo::TimePoint = std::chrono::system_clock::time_point

Definition at line 45 of file ValidityInfo.hpp.

Constructor & Destructor Documentation

◆ ValidityInfo() [1/2]

ValidityInfo::ValidityInfo ( )

Default status is: enabled and no time-based limitation.

Definition at line 27 of file ValidityInfo.cpp.

◆ ValidityInfo() [2/2]

Leosac::Auth::ValidityInfo::ValidityInfo ( const ValidityInfo )
default

Member Function Documentation

◆ end() [1/2]

const ValidityInfo::TimePoint & ValidityInfo::end ( ) const

Definition at line 103 of file ValidityInfo.cpp.

◆ end() [2/2]

void ValidityInfo::end ( const TimePoint tp)

Definition at line 113 of file ValidityInfo.cpp.

◆ is_enabled()

bool ValidityInfo::is_enabled ( ) const

Is the credential enabled ?

Definition at line 39 of file ValidityInfo.cpp.

◆ is_in_range()

bool ValidityInfo::is_in_range ( ) const

Are we currently is the validity range of the credential ?

Definition at line 44 of file ValidityInfo.cpp.

◆ is_valid()

bool ValidityInfo::is_valid ( ) const

Check that the current date is between validity start and end and make sure its enabled too.

Definition at line 34 of file ValidityInfo.cpp.

◆ set_enabled()

void ValidityInfo::set_enabled ( bool  v)

Definition at line 93 of file ValidityInfo.cpp.

◆ set_end_date()

void ValidityInfo::set_end_date ( const std::string &  s)

Set the end validity date.

We receive the date as a string. The expected format is this: d/m/Y H:M

This method accept an empty string, if that case it will set the end_date to time_point::max().

Definition at line 72 of file ValidityInfo.cpp.

◆ set_start_date()

void ValidityInfo::set_start_date ( const std::string &  s)

Set the start validity date.

We receive the date as a string. The expected format is this: d/m/Y H:M

This method accept an empty string, if that case it will set the end_date to time_point::min().

Definition at line 51 of file ValidityInfo.cpp.

◆ start() [1/2]

const ValidityInfo::TimePoint & ValidityInfo::start ( ) const

Definition at line 98 of file ValidityInfo.cpp.

◆ start() [2/2]

void ValidityInfo::start ( const TimePoint tp)

Definition at line 108 of file ValidityInfo.cpp.

Friends And Related Function Documentation

◆ odb::access

friend class odb::access
friend

Definition at line 98 of file ValidityInfo.hpp.

Member Data Documentation

◆ enabled_

bool Leosac::Auth::ValidityInfo::enabled_
private

Definition at line 104 of file ValidityInfo.hpp.

◆ end_

TimePoint Leosac::Auth::ValidityInfo::end_
private

Definition at line 102 of file ValidityInfo.hpp.

◆ start_

TimePoint Leosac::Auth::ValidityInfo::start_
private

Definition at line 100 of file ValidityInfo.hpp.


The documentation for this class was generated from the following files: