GpgKeyImportExporter.h
#ifndef _GPGKEYIMPORTEXPORTOR_H
#define _GPGKEYIMPORTEXPORTOR_H
#include <string>
#include "core/GpgConstants.h"
#include "core/GpgContext.h"
#include "core/GpgFunctionObject.h"
#include "core/GpgModel.h"
namespace GpgFrontend {
class GpgImportedKey {
public:
std::string fpr;
int import_status;
};
typedef std::list<GpgImportedKey> GpgImportedKeyList;
class GPGFRONTEND_CORE_EXPORT GpgImportInformation {
public:
GpgImportInformation();
explicit GpgImportInformation(gpgme_import_result_t result);
int considered = 0;
int no_user_id = 0;
int imported = 0;
int imported_rsa = 0;
int unchanged = 0;
int new_user_ids = 0;
int new_sub_keys = 0;
int new_signatures = 0;
int new_revocations = 0;
int secret_read = 0;
int secret_imported = 0;
int secret_unchanged = 0;
int not_imported = 0;
GpgImportedKeyList importedKeys;
};
class GPGFRONTEND_CORE_EXPORT GpgKeyImportExporter
: public SingletonFunctionObject<GpgKeyImportExporter> {
public:
explicit GpgKeyImportExporter(
int channel = SingletonFunctionObject::GetDefaultChannel());
GpgImportInformation ImportKey(StdBypeArrayPtr inBuffer);
bool ExportKeys(KeyIdArgsListPtr& uid_list, ByteArrayPtr& out_buffer,
bool secret = false) const;
bool ExportKeys(const KeyArgsList& keys, ByteArrayPtr& outBuffer,
bool secret = false) const;
bool ExportKey(const GpgKey& key, ByteArrayPtr& out_buffer) const;
bool ExportKeyOpenSSH(const GpgKey& key, ByteArrayPtr& out_buffer) const;
bool ExportSecretKey(const GpgKey& key, ByteArrayPtr& outBuffer) const;
bool ExportSecretKeyShortest(const GpgKey& key,
ByteArrayPtr& outBuffer) const;
private:
GpgContext& ctx_ =
GpgContext::GetInstance(SingletonFunctionObject::GetChannel());
};
} // namespace GpgFrontend
#endif // _GPGKEYIMPORTEXPORTOR_H
GpgFrontend::SingletonFunctionObject
Definition: GpgFunctionObject.h:148
GpgFrontend::GpgKeyImportExporter::ExportKeys
bool ExportKeys(KeyIdArgsListPtr &uid_list, ByteArrayPtr &out_buffer, bool secret=false) const
Definition: GpgKeyImportExporter.cpp:71
GpgFrontend::GpgKey::GetId
std::string GetId() const
Definition: GpgKey.cpp:52
GpgFrontend
Definition: CoreCommonUtil.cpp:29
GpgFrontend::SingletonFunctionObject< GpgKeyGetter >::GetInstance
static GpgKeyGetter & GetInstance(int channel=GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL)
Get the Instance object.
Definition: GpgFunctionObject.h:170
GpgFrontend::check_gpg_error
GPGFRONTEND_CORE_EXPORT GpgError check_gpg_error(GpgError err)
Definition: GpgConstants.cpp:54
GpgFrontend::GpgKeyImportExporter::GpgKeyImportExporter
GpgKeyImportExporter(int channel=SingletonFunctionObject::GetDefaultChannel())
Construct a new Gpg Key Import Exporter object.
Definition: GpgKeyImportExporter.cpp:34
GpgFrontend::SingletonFunctionObject::GetChannel
int GetChannel() const
Get the Channel object.
Definition: GpgFunctionObject.h:239
GpgFrontend::GpgData
Definition: GpgData.h:39
GpgFrontend::GpgContext
Definition: GpgContext.h:59
GpgFrontend::GpgImportedKey
Definition: GpgKeyImportExporter.h:45
GpgFrontend::SingletonFunctionObject::GetDefaultChannel
static int GetDefaultChannel()
Get the Default Channel object.
Definition: GpgFunctionObject.h:232
GpgFrontend::check_gpg_error_2_err_code
GPGFRONTEND_CORE_EXPORT gpg_err_code_t check_gpg_error_2_err_code(gpgme_error_t err, gpgme_error_t predict=GPG_ERR_NO_ERROR)
Definition: GpgConstants.cpp:63
GpgFrontend::GpgData::Read2Buffer
ByteArrayPtr Read2Buffer()
Definition: GpgData.cpp:55
GpgFrontend::GpgKeyImportExporter::ImportKey
GpgImportInformation ImportKey(StdBypeArrayPtr inBuffer)
Definition: GpgKeyImportExporter.cpp:42
GpgFrontend::GpgKeyImportExporter::ExportKeyOpenSSH
bool ExportKeyOpenSSH(const GpgKey &key, ByteArrayPtr &out_buffer) const
Definition: GpgKeyImportExporter.cpp:155
GpgFrontend::GpgKeyImportExporter::ExportSecretKey
bool ExportSecretKey(const GpgKey &key, ByteArrayPtr &outBuffer) const
Definition: GpgKeyImportExporter.cpp:124
GpgFrontend::GpgKeyImportExporter::ExportSecretKeyShortest
bool ExportSecretKeyShortest(const GpgKey &key, ByteArrayPtr &outBuffer) const
Definition: GpgKeyImportExporter.cpp:169
GpgFrontend::GpgKeyGetter::GetKeys
KeyListPtr GetKeys(const KeyIdArgsListPtr &ids)
Get the Keys object.
Definition: GpgKeyGetter.cpp:148
GpgFrontend::GpgImportInformation
Definition: GpgKeyImportExporter.h:57
GpgFrontend::GpgKeyImportExporter
Definition: GpgKeyImportExporter.h:89
GpgFrontend::GpgKey
Definition: GpgKey.h:41
GpgFrontend::GpgKeyImportExporter::ExportKey
bool ExportKey(const GpgKey &key, ByteArrayPtr &out_buffer) const
Definition: GpgKeyImportExporter.cpp:141