BeeeOn Gateway
v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
|
#include <FileCredentialsStorage.h>
Public Member Functions | |
void | setFile (const std::string &path) |
void | setConfigRoot (const std::string &root) |
void | setSaveDelay (const Poco::Timespan &delay) |
void | load () |
void | save () |
void | insertOrUpdate (const DeviceID &device, const Poco::SharedPtr< Credentials > credentials) override |
void | remove (const DeviceID &device) override |
void | clear () override |
Public Member Functions inherited from BeeeOn::CredentialsStorage | |
CredentialsStorage (const std::map< std::string, CredentialsFactory > &factory) | |
Poco::SharedPtr< Credentials > | find (const DeviceID &ID) |
void | save (Poco::AutoPtr< Poco::Util::AbstractConfiguration > conf, const std::string &root="credentials") const |
void | load (Poco::AutoPtr< Poco::Util::AbstractConfiguration > rootConf, const std::string &root="credentials") |
Protected Member Functions | |
void | saveLater () |
void | onSaveLater (Poco::Timer &) |
void | saveUnlocked () const |
Protected Member Functions inherited from BeeeOn::CredentialsStorage | |
Poco::RWLock & | lock () const |
void | insertOrUpdateUnlocked (const DeviceID &device, const Poco::SharedPtr< Credentials > credentials) |
void | removeUnlocked (const DeviceID &device) |
void | clearUnlocked () |
Protected Member Functions inherited from BeeeOn::Loggable | |
void | setupLogger (Poco::Logger *logger=0) const |
Poco::Logger & | logger () const |
Loggable (const ClassInfo &info) | |
Loggable (const std::type_info &info) | |
Additional Inherited Members | |
Public Types inherited from BeeeOn::CredentialsStorage | |
typedef Poco::SharedPtr < CredentialsStorage > | Ptr |
typedef std::function < Poco::SharedPtr< Credentials > Poco::AutoPtr < Poco::Util::AbstractConfiguration >)> | CredentialsFactory |
Static Protected Member Functions inherited from BeeeOn::Loggable | |
static Poco::Logger & | forMethod (const char *name) |
static Poco::Logger & | forClass (const ClassInfo &info) |
static Poco::Logger & | forClass (const std::type_info &info) |
template<typename T > | |
static Poco::Logger & | forInstance (const T *i) |
static void | configureSimple (Poco::Logger &logger, const std::string &level) |
static void | logException (Poco::Logger &logger, const Poco::Message::Priority priority, const Poco::Exception &e, const char *file, size_t line) |
FileCredentialsStorage is subclass of CredentialsStorage which includes methods for saving credentials to file and loading them from it. To load from file, it is necessary to setFile and optionally to setConfigRoot, then call load.
|
protected |
This method must be always called while holding the write-lock.
void FileCredentialsStorage::setConfigRoot | ( | const std::string & | root | ) |
Credentials are saved in configuration in this form: <configRoot>.<DeviceID>.<attribute> =
. Default configRoot is "credentials".
void FileCredentialsStorage::setSaveDelay | ( | const Poco::Timespan & | delay | ) |
If a change occurs in Credentials (inserting, updating, or removing), FileCredentialsStorage will be automaticly saved after SaveDelayTime (from the first change). Default SaveDelayTime is 30min. Passing negative number to this funcion causes disabling of autosave (if autosave timer is already running, storage is saved).