mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 06:02:41 -04:00
JSON API import/export PGP key to file
This commit is contained in:
parent
7a1375ff6f
commit
6543d713e4
3 changed files with 27 additions and 7 deletions
|
@ -449,7 +449,7 @@ void RsControlModule::handleImportPgp(Request &req, Response &resp)
|
||||||
|
|
||||||
RsPgpId pgp_id;
|
RsPgpId pgp_id;
|
||||||
std::string error_string;
|
std::string error_string;
|
||||||
if(RsAccounts::ImportIdentityFromString(key_string, pgp_id, error_string))
|
if(RsAccounts::importIdentityFromString(key_string, pgp_id, error_string))
|
||||||
{
|
{
|
||||||
resp.mDataStream << makeKeyValueReference("pgp_id", pgp_id);
|
resp.mDataStream << makeKeyValueReference("pgp_id", pgp_id);
|
||||||
resp.setOk();
|
resp.setOk();
|
||||||
|
|
|
@ -176,9 +176,26 @@ public:
|
||||||
static int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
|
static int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
|
||||||
static bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
|
static bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
|
||||||
|
|
||||||
// PGP Support Functions.
|
/**
|
||||||
static bool ExportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
|
* @brief Export full encrypted PGP identity to file
|
||||||
static bool ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
* @jsonapi{development}
|
||||||
|
* @param[in] filePath path of certificate file
|
||||||
|
* @param[in] pgpId PGP id to export
|
||||||
|
* @return true on success, false otherwise
|
||||||
|
*/
|
||||||
|
static bool ExportIdentity( const std::string& filePath,
|
||||||
|
const RsPgpId& pgpId );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Import full encrypted PGP identity from file
|
||||||
|
* @jsonapi{development,unauthenticated}
|
||||||
|
* @param[in] filePath path of certificate file
|
||||||
|
* @param[out] pgpId storage for the PGP fingerprint of the imported key
|
||||||
|
* @param[out] errorMsg storage for eventual human readable error message
|
||||||
|
* @return true on success, false otherwise
|
||||||
|
*/
|
||||||
|
static bool ImportIdentity(
|
||||||
|
const std::string& filePath, RsPgpId& pgpId, std::string& errorMsg );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Import full encrypted PGP identity from string
|
* @brief Import full encrypted PGP identity from string
|
||||||
|
@ -188,7 +205,7 @@ public:
|
||||||
* @param[out] errorMsg storage for eventual human readable error message
|
* @param[out] errorMsg storage for eventual human readable error message
|
||||||
* @return true on success, false otherwise
|
* @return true on success, false otherwise
|
||||||
*/
|
*/
|
||||||
static bool ImportIdentityFromString(
|
static bool importIdentityFromString(
|
||||||
const std::string& data, RsPgpId& pgpId,
|
const std::string& data, RsPgpId& pgpId,
|
||||||
std::string& errorMsg );
|
std::string& errorMsg );
|
||||||
|
|
||||||
|
|
|
@ -1347,9 +1347,12 @@ bool RsAccounts::ImportIdentity(const std::string& fname,RsPgpId& imported_pg
|
||||||
return rsAccountsDetails->importIdentity(fname,imported_pgp_id,import_error);
|
return rsAccountsDetails->importIdentity(fname,imported_pgp_id,import_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsAccounts::ImportIdentityFromString(const std::string& data,RsPgpId& imported_pgp_id,std::string& import_error)
|
bool RsAccounts::importIdentityFromString(
|
||||||
|
const std::string& data, RsPgpId& imported_pgp_id,
|
||||||
|
std::string& import_error )
|
||||||
{
|
{
|
||||||
return rsAccountsDetails->importIdentityFromString(data,imported_pgp_id,import_error);
|
return rsAccountsDetails->
|
||||||
|
importIdentityFromString(data, imported_pgp_id, import_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ bool RsAccounts::exportIdentityToString(
|
/*static*/ bool RsAccounts::exportIdentityToString(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue