DataObjectOperator.h
#ifndef GPGFRONTEND_DATAOBJECTOPERATOR_H
#define GPGFRONTEND_DATAOBJECTOPERATOR_H
#include "core/GpgFrontendCore.h"
#include "core/GpgFunctionObject.h"
#include "core/function/GlobalSettingStation.h"
namespace GpgFrontend {
class GPGFRONTEND_CORE_EXPORT DataObjectOperator
: public SingletonFunctionObject<DataObjectOperator> {
public:
explicit DataObjectOperator(
int channel = SingletonFunctionObject::GetDefaultChannel());
std::string SaveDataObj(const std::string &_key, const nlohmann::json &value);
std::optional<nlohmann::json> GetDataObject(const std::string &_key);
std::optional<nlohmann::json> GetDataObjectByRef(const std::string &_ref);
private:
void init_app_secure_key();
GlobalSettingStation &global_setting_station_ =
GlobalSettingStation::GetInstance();
std::filesystem::path app_secure_path_ =
global_setting_station_.GetAppConfigPath() /
"secure";
std::filesystem::path app_secure_key_path_ =
app_secure_path_ / "app.key";
std::filesystem::path app_data_objs_path_ =
global_setting_station_.GetAppDataPath() / "data_objs";
std::random_device rd_;
std::mt19937 mt_ = std::mt19937(rd_());
QByteArray hash_key_;
};
} // namespace GpgFrontend
#endif // GPGFRONTEND_DATAOBJECTOPERATOR_H
GpgFrontend::SingletonFunctionObject
Definition: GpgFunctionObject.h:148
GpgFrontend::FileOperator::WriteFileStd
static bool WriteFileStd(const std::filesystem::path &file_name, const std::string &data)
write file content using std struct
Definition: FileOperator.cpp:69
GpgFrontend::DataObjectOperator::rd_
std::random_device rd_
Random device.
Definition: DataObjectOperator.h:74
GpgFrontend
Definition: CoreCommonUtil.cpp:29
GpgFrontend::SingletonFunctionObject< PassphraseGenerator >::GetInstance
static PassphraseGenerator & GetInstance(int channel=GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL)
Get the Instance object.
Definition: GpgFunctionObject.h:170
GpgFrontend::DataObjectOperator::app_secure_path_
std::filesystem::path app_secure_path_
Where sensitive information is stored.
Definition: DataObjectOperator.h:64
GpgFrontend::DataObjectOperator::app_secure_key_path_
std::filesystem::path app_secure_key_path_
Where the key of data object is stored.
Definition: DataObjectOperator.h:67
GpgFrontend::DataObjectOperator::DataObjectOperator
DataObjectOperator(int channel=SingletonFunctionObject::GetDefaultChannel())
DataObjectOperator constructor.
Definition: DataObjectOperator.cpp:47
GpgFrontend::DataObjectOperator::hash_key_
QByteArray hash_key_
Hash key.
Definition: DataObjectOperator.h:76
GpgFrontend::GlobalSettingStation
Definition: GlobalSettingStation.h:42
GpgFrontend::DataObjectOperator::app_data_objs_path_
std::filesystem::path app_data_objs_path_
Definition: DataObjectOperator.h:69
GpgFrontend::SingletonFunctionObject::GetDefaultChannel
static int GetDefaultChannel()
Get the Default Channel object.
Definition: GpgFunctionObject.h:232
GpgFrontend::FileOperator::ReadFileStd
static bool ReadFileStd(const std::filesystem::path &file_name, std::string &data)
read file content using std struct
Definition: FileOperator.cpp:55
GpgFrontend::DataObjectOperator
Definition: DataObjectOperator.h:38
GpgFrontend::DataObjectOperator::init_app_secure_key
void init_app_secure_key()
init the secure key of application data object
Definition: DataObjectOperator.cpp:38