mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-19 11:54:22 -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
2 changed files with 40 additions and 32 deletions
|
@ -383,7 +383,7 @@ std::string AuthGPG::getGPGName(const std::string &id,bool *success)
|
||||||
}
|
}
|
||||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||||
|
|
||||||
const PGPCertificateInfo *info = PGPHandler::getCertificateInfo(PGPIdType(id)) ;
|
const PGPCertificateInfo *info = getCertInfoFromStdString(id) ;
|
||||||
|
|
||||||
if(info != NULL)
|
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)
|
std::string AuthGPG::getGPGEmail(const std::string &id,bool *success)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||||
const PGPCertificateInfo *info = PGPHandler::getCertificateInfo(PGPIdType(id)) ;
|
const PGPCertificateInfo *info = getCertInfoFromStdString(id) ;
|
||||||
|
|
||||||
if(info != NULL)
|
if(info != NULL)
|
||||||
{
|
{
|
||||||
|
@ -440,13 +440,25 @@ bool AuthGPG::getGPGAllList(std::list<std::string> &ids)
|
||||||
|
|
||||||
return true;
|
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
|
bool AuthGPG::haveSecretKey(const std::string& id) const
|
||||||
{
|
{
|
||||||
return PGPHandler::haveSecretKey(PGPIdType(id)) ;
|
return PGPHandler::haveSecretKey(PGPIdType(id)) ;
|
||||||
}
|
}
|
||||||
bool AuthGPG::isKeySupported(const std::string& id) const
|
bool AuthGPG::isKeySupported(const std::string& id) const
|
||||||
{
|
{
|
||||||
const PGPCertificateInfo *pc = PGPHandler::getCertificateInfo(PGPIdType(id)) ;
|
const PGPCertificateInfo *pc = getCertInfoFromStdString(id) ;
|
||||||
|
|
||||||
if(pc == NULL)
|
if(pc == NULL)
|
||||||
return false ;
|
return false ;
|
||||||
|
@ -470,37 +482,29 @@ bool AuthGPG::getGPGDetails(const std::string& id, RsPeerDetails &d)
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
const PGPCertificateInfo *pc = getCertInfoFromStdString(id) ;
|
||||||
{
|
|
||||||
const PGPCertificateInfo *pc = PGPHandler::getCertificateInfo(PGPIdType(id)) ;
|
|
||||||
|
|
||||||
if(pc == NULL)
|
if(pc == NULL)
|
||||||
return false ;
|
|
||||||
|
|
||||||
const PGPCertificateInfo& cert(*pc) ;
|
|
||||||
|
|
||||||
d.id = id ;
|
|
||||||
d.gpg_id = id ;
|
|
||||||
d.name = cert._name;
|
|
||||||
d.lastUsed = cert._time_stamp;
|
|
||||||
d.email = cert._email;
|
|
||||||
d.trustLvl = cert._trustLvl;
|
|
||||||
d.validLvl = cert._trustLvl;
|
|
||||||
d.ownsign = cert._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_OWN_SIGNATURE;
|
|
||||||
d.gpgSigners.clear() ;
|
|
||||||
|
|
||||||
for(std::set<std::string>::const_iterator it(cert.signers.begin());it!=cert.signers.end();++it)
|
|
||||||
d.gpgSigners.push_back( *it ) ;
|
|
||||||
|
|
||||||
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 false ;
|
||||||
}
|
|
||||||
|
const PGPCertificateInfo& cert(*pc) ;
|
||||||
|
|
||||||
|
d.id = id ;
|
||||||
|
d.gpg_id = id ;
|
||||||
|
d.name = cert._name;
|
||||||
|
d.lastUsed = cert._time_stamp;
|
||||||
|
d.email = cert._email;
|
||||||
|
d.trustLvl = cert._trustLvl;
|
||||||
|
d.validLvl = cert._trustLvl;
|
||||||
|
d.ownsign = cert._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_OWN_SIGNATURE;
|
||||||
|
d.gpgSigners.clear() ;
|
||||||
|
|
||||||
|
for(std::set<std::string>::const_iterator it(cert.signers.begin());it!=cert.signers.end();++it)
|
||||||
|
d.gpgSigners.push_back( *it ) ;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,6 +249,10 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
|
|
||||||
private:
|
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 */
|
/* SKTAN */
|
||||||
//void showData(gpgme_data_t dh);
|
//void showData(gpgme_data_t dh);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue