mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
generalized the test for valid strings to all methods in AuthGPG
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7050 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1f4580304f
commit
11bc15b9cf
@ -383,7 +383,7 @@ std::string AuthGPG::getGPGName(const std::string &id,bool *success)
|
||||
}
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
|
||||
const PGPCertificateInfo *info = PGPHandler::getCertificateInfo(PGPIdType(id)) ;
|
||||
const PGPCertificateInfo *info = getCertInfoFromStdString(id) ;
|
||||
|
||||
if(info != NULL)
|
||||
{
|
||||
@ -401,7 +401,7 @@ std::string AuthGPG::getGPGName(const std::string &id,bool *success)
|
||||
std::string AuthGPG::getGPGEmail(const std::string &id,bool *success)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
const PGPCertificateInfo *info = PGPHandler::getCertificateInfo(PGPIdType(id)) ;
|
||||
const PGPCertificateInfo *info = getCertInfoFromStdString(id) ;
|
||||
|
||||
if(info != NULL)
|
||||
{
|
||||
@ -440,13 +440,25 @@ bool AuthGPG::getGPGAllList(std::list<std::string> &ids)
|
||||
|
||||
return true;
|
||||
}
|
||||
const PGPCertificateInfo *AuthGPG::getCertInfoFromStdString(const std::string& pgp_id) const
|
||||
{
|
||||
try
|
||||
{
|
||||
return PGPHandler::getCertificateInfo(PGPIdType(pgp_id)) ;
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
std::cerr << "(EE) exception raised while constructing a PGP certificate from id \"" << pgp_id << "\": " << e.what() << std::endl;
|
||||
return NULL ;
|
||||
}
|
||||
}
|
||||
bool AuthGPG::haveSecretKey(const std::string& id) const
|
||||
{
|
||||
return PGPHandler::haveSecretKey(PGPIdType(id)) ;
|
||||
}
|
||||
bool AuthGPG::isKeySupported(const std::string& id) const
|
||||
{
|
||||
const PGPCertificateInfo *pc = PGPHandler::getCertificateInfo(PGPIdType(id)) ;
|
||||
const PGPCertificateInfo *pc = getCertInfoFromStdString(id) ;
|
||||
|
||||
if(pc == NULL)
|
||||
return false ;
|
||||
@ -470,9 +482,7 @@ bool AuthGPG::getGPGDetails(const std::string& id, RsPeerDetails &d)
|
||||
return false ;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
const PGPCertificateInfo *pc = PGPHandler::getCertificateInfo(PGPIdType(id)) ;
|
||||
const PGPCertificateInfo *pc = getCertInfoFromStdString(id) ;
|
||||
|
||||
if(pc == NULL)
|
||||
return false ;
|
||||
@ -495,12 +505,6 @@ bool AuthGPG::getGPGDetails(const std::string& id, RsPeerDetails &d)
|
||||
d.fpr = cert._fpr.toStdString();
|
||||
d.accept_connection = cert._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_ACCEPT_CONNEXION;
|
||||
d.hasSignedMe = cert._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_SIGNED_ME;
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
std::cerr << "(EE) exception raised while constructing a PGP certificate: " << e.what() << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -249,6 +249,10 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
||||
/*****************************************************************/
|
||||
|
||||
private:
|
||||
// Gets the certificate pointer and returns NULL if the string is invalid, or the
|
||||
// cert was not found.
|
||||
//
|
||||
const PGPCertificateInfo *getCertInfoFromStdString(const std::string& ) const;
|
||||
|
||||
/* SKTAN */
|
||||
//void showData(gpgme_data_t dh);
|
||||
|
Loading…
Reference in New Issue
Block a user