get rid of p3authmgr

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2001 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2010-01-13 20:56:55 +00:00
parent 2917896834
commit c23407cae3
46 changed files with 254 additions and 874 deletions

View file

@ -29,6 +29,7 @@
#include <iostream>
#include <sstream>
#include "pqi/authssl.h"
#include "util/rsdebug.h"
const int p3facemsgzone = 11453;
@ -102,8 +103,8 @@ int RsServer::UpdateAllConfig()
RsConfig &config = iface.mConfig;
config.ownId = mAuthMgr->OwnId();
config.ownName = mAuthMgr->getName(config.ownId);
config.ownId = getAuthSSL()->OwnId();
config.ownName = getAuthSSL()->getName(config.ownId);
peerConnectState pstate;
mConnMgr->getOwnNetStatus(pstate);
@ -156,7 +157,7 @@ void RsServer::ConfigFinalSave()
/* force saving of transfers TODO */
//ftserver->saveFileTransferStatus();
mAuthMgr->FinalSaveCertificates();
getAuthSSL()->FinalSaveCertificates();
mConfigMgr->completeConfiguration();
}

View file

@ -30,6 +30,7 @@
#include "tcponudp/tou.h"
#include <sstream>
#include "pqi/authssl.h"
#include <sys/time.h>
#include <time.h>
@ -244,7 +245,7 @@ void RsServer::run()
//ftserver->saveFileTransferStatus();
/* see if we need to resave certs */
mAuthMgr->CheckSaveCertificates();
getAuthSSL()->CheckSaveCertificates();
/* hour loop */
if (++min >= 60)

View file

@ -42,6 +42,8 @@ const int p3facemsgzone = 11453;
#include "services/p3msgservice.h"
#include "services/p3chatservice.h"
#include "pqi/authssl.h"
/* external reference point */
RsMsgs *rsMsgs = NULL;
@ -154,7 +156,7 @@ bool p3Msgs::getNewChat(std::list<ChatInfo> &chats)
void p3Msgs::initRsChatInfo(RsChatMsgItem *c, ChatInfo &i)
{
i.rsid = c -> PeerId();
i.name = mAuthMgr->getName(i.rsid);
i.name = getAuthSSL()->getName(i.rsid);
i.chatflags = 0 ;
i.msg = c -> message;

View file

@ -26,7 +26,7 @@
#include "rsserver/p3peers.h"
#include "rsserver/p3face.h"
#include "pqi/p3connmgr.h"
#include "pqi/p3authmgr.h"
#include "pqi/authssl.h"
#include <rsiface/rsinit.h>
#include <iostream>
@ -165,8 +165,8 @@ std::string RsPeerLastConnectString(uint32_t lastConnect)
}
p3Peers::p3Peers(p3ConnectMgr *cm, p3AuthMgr *am)
:mConnMgr(cm), mAuthMgr(am)
p3Peers::p3Peers(p3ConnectMgr *cm)
:mConnMgr(cm)
{
return;
}
@ -202,7 +202,7 @@ std::string p3Peers::getOwnId()
std::cerr << std::endl;
#endif
return mAuthMgr->OwnId();
return getAuthSSL()->OwnId();
}
bool p3Peers::getOnlineList(std::list<std::string> &ids)
@ -237,7 +237,7 @@ bool p3Peers::getOthersList(std::list<std::string> &ids)
#endif
/* get from mAuthMgr */
mAuthMgr->getAllList(ids);
getAuthSSL()->getAllList(ids);
return true;
}
@ -260,7 +260,7 @@ bool p3Peers::isOnline(std::string id)
bool p3Peers::isTrustingMe(std::string id) const
{
return mAuthMgr->isTrustingMe(id) ;
return getAuthSSL()->isTrustingMe(id) ;
}
bool p3Peers::isFriend(std::string id)
@ -301,8 +301,8 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
#endif
/* get from mAuthMgr (first) */
pqiAuthDetails authDetail;
if (!mAuthMgr->getDetails(id, authDetail))
sslcert authDetail;
if (!getAuthSSL()->getCertDetails(id, authDetail))
{
return false;
}
@ -317,16 +317,8 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
d.issuer = authDetail.issuer;
d.ownsign = authDetail.ownsign;
d.trusted = authDetail.trusted;
d.trusted = getAuthGPG()->isPGPAuthenticated(getAuthSSL()->getGPGId(id));
#ifdef RS_USE_PGPSSL
d.trustLvl = authDetail.trustLvl;
d.validLvl = authDetail.validLvl;
#else
d.trustLvl = RsPeerTranslateTrust(authDetail.trustLvl);
d.validLvl = RsPeerTranslateTrust(authDetail.trustLvl);
#endif
/* generate */
d.authcode = "AUTHCODE";
@ -334,7 +326,7 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
/* get from mConnectMgr */
peerConnectState pcs;
if (id == mAuthMgr->OwnId())
if (id == getAuthSSL()->OwnId())
{
mConnMgr->getOwnNetStatus(pcs);
}
@ -478,7 +470,7 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
std::string p3Peers::getPeerPGPName(std::string id)
{
/* get from mAuthMgr as it should have more peers? */
return mAuthMgr->getIssuerName(id);
return getAuthSSL()->getIssuerName(id);
}
std::string p3Peers::getPeerName(std::string id)
@ -489,7 +481,7 @@ std::string p3Peers::getPeerName(std::string id)
#endif
/* get from mAuthMgr as it should have more peers? */
return mAuthMgr->getName(id);
return getAuthSSL()->getName(id);
}
@ -508,8 +500,8 @@ bool p3Peers::getPGPFriendList(std::list<std::string> &ids)
/* get from mAuthMgr (first) */
for(it = certids.begin(); it != certids.end(); it++)
{
pqiAuthDetails detail;
if (!mAuthMgr->getDetails(*it, detail))
sslcert detail;
if (!getAuthSSL()->getCertDetails(*it, detail))
{
continue;
}
@ -552,7 +544,7 @@ bool p3Peers::getPGPAllList(std::list<std::string> &ids)
#endif
/* get from mAuthMgr */
mAuthMgr->getPGPAllList(ids);
getAuthGPG()->getPGPAllList(ids);
return true;
}
@ -564,7 +556,7 @@ std::string p3Peers::getPGPOwnId()
#endif
/* get from mAuthMgr */
return mAuthMgr->PGPOwnId();
return getAuthGPG()->PGPOwnId();
}
@ -742,12 +734,12 @@ p3Peers::GetRetroshareInvite()
std::cerr << "p3Peers::GetRetroshareInvite()";
std::cerr << std::endl;
std::string ownId = mAuthMgr->OwnId();
std::string certstr = mAuthMgr->SaveCertificateToString(ownId);
std::string name = mAuthMgr->getName(ownId);
std::string ownId = getAuthSSL()->OwnId();
std::string certstr = getAuthSSL()->SaveCertificateToString(ownId);
std::string name = getAuthSSL()->getName(ownId);
std::string pgpownId = mAuthMgr->PGPOwnId();
std::string pgpcertstr = mAuthMgr->SaveCertificateToString(pgpownId);
std::string pgpownId = getAuthGPG()->PGPOwnId();
std::string pgpcertstr = getAuthGPG()->SaveCertificateToString(pgpownId);
std::cerr << "p3Peers::GetRetroshareInvite() SSL Cert:";
std::cerr << std::endl;
@ -776,7 +768,7 @@ bool p3Peers::LoadCertificateFromFile(std::string fname, std::string &id)
std::cerr << std::endl;
#endif
return mAuthMgr->LoadCertificateFromFile(fname, id);
return getAuthSSL()->LoadCertificateFromFile(fname, id);
}
@ -841,14 +833,14 @@ bool p3Peers::LoadCertificateFromString(std::string cert, std::string &id)
std::cerr << "pgpcert .... " << std::endl;
std::cerr << pgpcert << std::endl;
ret = mAuthMgr->LoadCertificateFromString(pgpcert, id);
ret = getAuthGPG()->LoadCertificateFromString(pgpcert);
}
if (sslcert != "")
{
std::cerr << "sslcert .... " << std::endl;
std::cerr << sslcert << std::endl;
ret = mAuthMgr->LoadCertificateFromString(sslcert, id);
ret = getAuthSSL()->LoadCertificateFromString(sslcert, id);
}
}
@ -868,7 +860,7 @@ bool p3Peers::SaveCertificateToFile(std::string id, std::string fname)
ensureExtension(fname, "pqi");
return mAuthMgr->SaveCertificateToFile(id, fname);
return getAuthSSL()->SaveCertificateToFile(id, fname);
}
std::string p3Peers::SaveCertificateToString(std::string id)
@ -878,7 +870,7 @@ std::string p3Peers::SaveCertificateToString(std::string id)
std::cerr << std::endl;
#endif
return mAuthMgr->SaveCertificateToString(id);
return getAuthSSL()->SaveCertificateToString(id);
}
bool p3Peers::AuthCertificate(std::string id, std::string code)
@ -888,7 +880,7 @@ bool p3Peers::AuthCertificate(std::string id, std::string code)
std::cerr << std::endl;
#endif
if (mAuthMgr->AuthCertificate(id))
if (getAuthSSL()->AuthCertificate(id))
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::AuthCertificate() OK ... Adding as Friend";
@ -908,7 +900,7 @@ bool p3Peers::SignCertificate(std::string id)
std::cerr << std::endl;
#endif
return mAuthMgr->SignCertificate(id);
return getAuthSSL()->SignCertificate(id);
}
bool p3Peers::TrustCertificate(std::string id, bool trust)
@ -918,7 +910,7 @@ bool p3Peers::TrustCertificate(std::string id, bool trust)
std::cerr << std::endl;
#endif
return mAuthMgr->TrustCertificate(id, trust);
return getAuthSSL()->TrustCertificate(id, trust);
}

View file

@ -28,13 +28,12 @@
#include "rsiface/rspeers.h"
#include "pqi/p3connmgr.h"
#include "pqi/p3authmgr.h"
class p3Peers: public RsPeers
{
public:
p3Peers(p3ConnectMgr *cm, p3AuthMgr *am);
p3Peers(p3ConnectMgr *cm);
virtual ~p3Peers() { return; }
/* Updates ... */
@ -95,7 +94,6 @@ virtual bool TrustCertificate(std::string id, bool trust);
private:
p3ConnectMgr *mConnMgr;
p3AuthMgr *mAuthMgr;
};
#endif

View file

@ -46,8 +46,8 @@
// for blocking signals
#include <signal.h>
#include "pqi/authgpg.h"
#include "pqi/authssl.h"
#include "pqi/authgpg.h"
class accountId
{
@ -469,7 +469,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored)
* 2) Get List of Available Accounts.
* 4) Get List of GPG Accounts.
*/
getAuthMgr() -> InitAuth(NULL, NULL, NULL);
getAuthSSL() -> InitAuth(NULL, NULL, NULL);
// first check config directories, and set bootstrap values.
setupBaseDir();
@ -766,50 +766,27 @@ static bool checkAccount(std::string accountdir, accountId &id)
/* Generating GPGme Account */
int RsInit::GetPGPLogins(std::list<std::string> &pgpIds)
{
#ifdef PQI_USE_SSLONLY
return 0;
#else // PGP+SSL
GPGAuthMgr *mgr = (GPGAuthMgr *) getAuthMgr();
mgr->availablePGPCertificates(pgpIds);
int RsInit::GetPGPLogins(std::list<std::string> &pgpIds) {
getAuthGPG()->availablePGPCertificates(pgpIds);
return 1;
#endif
}
bool RsInit::getPGPEngineFileName(std::string &fileName)
{
#ifdef PQI_USE_SSLONLY
return false;
#else // PGP+SSL
GPGAuthMgr *mgr = (GPGAuthMgr *) getAuthMgr();
return mgr->getPGPEngineFileName(fileName);
#endif
bool RsInit::getPGPEngineFileName(std::string &fileName) {
return getAuthGPG()->getPGPEngineFileName(fileName);
}
int RsInit::GetPGPLoginDetails(std::string id, std::string &name, std::string &email)
{
std::cerr << "RsInit::GetPGPLoginDetails for \"" << id << "\"";
std::cerr << std::endl;
std::cerr << "RsInit::GetPGPLoginDetails for \"" << id << "\"";
std::cerr << std::endl;
#ifdef PQI_USE_SSLONLY
return 0;
#else // PGP+SSL
GPGAuthMgr *mgr = (GPGAuthMgr *) getAuthMgr();
pqiAuthDetails details;
if (!mgr->getDetails(id, details))
{
return 0;
}
name = details.name;
email = details.email;
return 1;
#endif
name = getAuthGPG()->getPGPName(getAuthSSL()->getGPGId(id));
email = getAuthGPG()->getPGPEmail(getAuthSSL()->getGPGId(id));
if (name != "") {
return 1;
} else {
return 0;
}
}
/* Before any SSL stuff can be loaded, the correct PGP must be selected / generated:
@ -821,7 +798,7 @@ bool RsInit::SelectGPGAccount(std::string id)
std::string gpgId = id;
std::string name = id;
GPGAuthMgr *gpgAuthMgr = (GPGAuthMgr *) getAuthMgr();
GPGAuthMgr *gpgAuthMgr = getAuthGPG();
if (0 < gpgAuthMgr -> GPGInit(gpgId))
{
ok = true;
@ -841,7 +818,7 @@ bool RsInit::SelectGPGAccount(std::string id)
bool RsInit::LoadGPGPassword(std::string inPGPpasswd)
{
GPGAuthMgr *gpgAuthMgr = (GPGAuthMgr *) getAuthMgr();
GPGAuthMgr *gpgAuthMgr =getAuthGPG();
bool ok = false;
if (0 < gpgAuthMgr -> LoadGPGPassword(inPGPpasswd))
@ -1221,25 +1198,8 @@ int RsInit::LoadCertificates(bool autoLoginNT)
return 0;
}
//std::string ca_loc = RsInitConfig::basedir + RsInitConfig::dirSeperator;
//ca_loc += configCaFile;
p3AuthMgr *authMgr = getAuthMgr();
bool ok = false;
#if defined(PQI_USE_SSLONLY)
std::cerr << "Calling initAuth debug 2." << std::endl;
if (0 < authMgr -> InitAuth(RsInitConfig::load_cert.c_str(), RsInitConfig::load_key.c_str(),RsInitConfig::passwd.c_str()))
{
ok = true;
}
else
{
std::cerr << "AuthSSL::InitAuth Failed" << std::endl;
}
#else /* X509 Certificates */
/* The SSL / SSL + PGP version requires, SSL init + PGP init. */
const char* sslPassword;
sslPassword = RsInitConfig::passwd.c_str();
@ -1256,7 +1216,7 @@ int RsInit::LoadCertificates(bool autoLoginNT)
gpgme_data_t plain;
gpgme_data_new_from_mem(&plain, sslPassword, strlen(sslPassword), 1);
gpgme_data_new_from_stream (&cipher, sslPassphraseFile);
if (0 < authMgr->encryptText(plain, cipher)) {
if (0 < getAuthGPG()->encryptText(plain, cipher)) {
std::cerr << "Encrypting went ok !" << std::endl;
}
gpgme_data_release (cipher);
@ -1277,7 +1237,7 @@ int RsInit::LoadCertificates(bool autoLoginNT)
gpgme_data_t plain;
gpgme_data_new (&plain);
gpgme_error_t error_reading_file = gpgme_data_new_from_stream (&cipher, sslPassphraseFile);
if (0 < authMgr->decryptText(cipher, plain)) {
if (0 < getAuthGPG()->decryptText(cipher, plain)) {
std::cerr << "Decrypting went ok !" << std::endl;
gpgme_data_write (plain, "", 1);
sslPassword = gpgme_data_release_and_get_mem(plain, NULL);
@ -1293,7 +1253,7 @@ int RsInit::LoadCertificates(bool autoLoginNT)
std::cerr << "RsInitConfig::load_key.c_str() : " << RsInitConfig::load_key.c_str() << std::endl;
std::cerr << "sslPassword : " << sslPassword << std::endl;;
if (0 < authMgr -> InitAuth(RsInitConfig::load_cert.c_str(), RsInitConfig::load_key.c_str(), sslPassword))
if (0 < getAuthSSL() -> InitAuth(RsInitConfig::load_cert.c_str(), RsInitConfig::load_key.c_str(), sslPassword))
{
ok = true;
}
@ -1302,7 +1262,6 @@ int RsInit::LoadCertificates(bool autoLoginNT)
std::cerr << "SSL Auth Failed!";
std::cerr << std::endl;
}
#endif /* X509 Certificates */
if (ok)
{
@ -1869,9 +1828,7 @@ int RsServer::StartupRetroShare()
/* (1) Load up own certificate (DONE ALREADY) - just CHECK */
/**************************************************************************/
mAuthMgr = getAuthMgr();
if (1 != mAuthMgr -> InitAuth(NULL, NULL, NULL))
if (1 != getAuthSSL() -> InitAuth(NULL, NULL, NULL))
{
std::cerr << "main() - Fatal Error....." << std::endl;
std::cerr << "Invalid Certificate configuration!" << std::endl;
@ -1879,7 +1836,7 @@ int RsServer::StartupRetroShare()
exit(1);
}
std::string ownId = mAuthMgr->OwnId();
std::string ownId = getAuthSSL()->OwnId();
/**************************************************************************/
/* Any Initial Configuration (Commandline Options) */
@ -1924,9 +1881,9 @@ int RsServer::StartupRetroShare()
bool oldFormat = false;
std::map<std::string, std::string> oldConfigMap;
mAuthMgr -> setConfigDirectories(certConfigFile, certNeighDir);
getAuthSSL() -> setConfigDirectories(certConfigFile, certNeighDir);
mAuthMgr -> loadCertificates();
getAuthSSL() -> loadCertificates();
/**************************************************************************/
/* setup classes / structures */
@ -1936,7 +1893,7 @@ int RsServer::StartupRetroShare()
/* Setup Notify Early - So we can use it. */
rsNotify = new p3Notify();
mConnMgr = new p3ConnectMgr(mAuthMgr);
mConnMgr = new p3ConnectMgr();
pqiNetAssistFirewall *mUpnpMgr = new upnphandler();
//p3DhtMgr *mDhtMgr = new OpenDHTMgr(ownId, mConnMgr, RsInitConfig::configDir);
@ -1945,7 +1902,7 @@ int RsServer::StartupRetroShare()
//pqih = new pqipersongrpDummy(none, flags);
/****** New Ft Server **** !!! */
ftserver = new ftServer(mAuthMgr, mConnMgr);
ftserver = new ftServer(mConnMgr);
ftserver->setP3Interface(pqih);
ftserver->setConfigDirectory(RsInitConfig::configDir);
@ -1962,15 +1919,15 @@ int RsServer::StartupRetroShare()
rsFiles = ftserver;
mConfigMgr = new p3ConfigMgr(mAuthMgr, RsInitConfig::configDir, "rs-v0.5.cfg", "rs-v0.5.sgn");
mConfigMgr = new p3ConfigMgr(RsInitConfig::configDir, "rs-v0.5.cfg", "rs-v0.5.sgn");
mGeneralConfig = new p3GeneralConfig();
/* create Services */
ad = new p3disc(mAuthMgr, mConnMgr, pqih);
ad = new p3disc(mConnMgr, pqih);
msgSrv = new p3MsgService(mConnMgr);
chatSrv = new p3ChatService(mConnMgr);
p3tunnel *tn = new p3tunnel(mAuthMgr,mConnMgr, pqih);
p3tunnel *tn = new p3tunnel(mConnMgr, pqih);
pqih -> addService(tn);
mConnMgr->setP3tunnel(tn);
@ -2000,7 +1957,7 @@ int RsServer::StartupRetroShare()
p3Forums *mForums = new p3Forums(RS_SERVICE_TYPE_FORUM,
mCacheStrapper, mCacheTransfer,
localcachedir, remotecachedir, mAuthMgr);
localcachedir, remotecachedir);
CachePair cp4(mForums, mForums, CacheId(RS_SERVICE_TYPE_FORUM, 0));
mCacheStrapper -> addCachePair(cp4);
@ -2008,7 +1965,7 @@ int RsServer::StartupRetroShare()
p3Channels *mChannels = new p3Channels(RS_SERVICE_TYPE_CHANNEL,
mCacheStrapper, mCacheTransfer, rsFiles,
localcachedir, remotecachedir, channelsdir, mAuthMgr);
localcachedir, remotecachedir, channelsdir);
CachePair cp5(mChannels, mChannels, CacheId(RS_SERVICE_TYPE_CHANNEL, 0));
mCacheStrapper -> addCachePair(cp5);
@ -2177,7 +2134,7 @@ int RsServer::StartupRetroShare()
/* Setup GUI Interfaces. */
rsPeers = new p3Peers(mConnMgr, mAuthMgr);
rsPeers = new p3Peers(mConnMgr);
rsMsgs = new p3Msgs(mAuthMgr, msgSrv, chatSrv);
rsDisc = new p3Discovery(ad);