ID cleaning

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7099 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-02-07 22:48:26 +00:00
parent 18f5128319
commit c56e1627f4
33 changed files with 329 additions and 412 deletions

View file

@ -192,23 +192,23 @@ RsNxsNetMgrImpl::RsNxsNetMgrImpl(p3LinkMgr *lMgr)
} }
std::string RsNxsNetMgrImpl::getOwnId() const RsPeerId& RsNxsNetMgrImpl::getOwnId()
{ {
RsStackMutex stack(mNxsNetMgrMtx); RsStackMutex stack(mNxsNetMgrMtx);
return mLinkMgr->getOwnId(); return mLinkMgr->getOwnId();
} }
void RsNxsNetMgrImpl::getOnlineList(std::set<std::string> &ssl_peers) void RsNxsNetMgrImpl::getOnlineList(std::set<RsPeerId> &ssl_peers)
{ {
ssl_peers.clear(); ssl_peers.clear();
std::list<std::string> pList; std::list<RsPeerId> pList;
{ {
RsStackMutex stack(mNxsNetMgrMtx); RsStackMutex stack(mNxsNetMgrMtx);
mLinkMgr->getOnlineList(pList); mLinkMgr->getOnlineList(pList);
} }
std::list<std::string>::const_iterator lit = pList.begin(); std::list<RsPeerId>::const_iterator lit = pList.begin();
for(; lit != pList.end(); lit++) for(; lit != pList.end(); lit++)
ssl_peers.insert(*lit); ssl_peers.insert(*lit);

View file

@ -81,8 +81,8 @@ class RsNxsNetMgr
public: public:
virtual ~RsNxsNetMgr(){}; virtual ~RsNxsNetMgr(){};
virtual std::string getOwnId() = 0; virtual const RsPeerId& getOwnId() = 0;
virtual void getOnlineList(std::set<std::string>& ssl_peers) = 0; virtual void getOnlineList(std::set<RsPeerId>& ssl_peers) = 0;
}; };
@ -94,8 +94,8 @@ public:
RsNxsNetMgrImpl(p3LinkMgr* lMgr); RsNxsNetMgrImpl(p3LinkMgr* lMgr);
virtual ~RsNxsNetMgrImpl(){}; virtual ~RsNxsNetMgrImpl(){};
std::string getOwnId(); const RsPeerId& getOwnId();
void getOnlineList(std::set<std::string>& ssl_peers); void getOnlineList(std::set<RsPeerId>& ssl_peers);
private: private:
@ -141,7 +141,7 @@ protected:
* @param authorId reputation to get * @param authorId reputation to get
* @return true if successfully retrieve repution * @return true if successfully retrieve repution
*/ */
bool getAuthorRep(GixsReputation& rep, const std::string& authorId, const std::string& peerId); bool getAuthorRep(GixsReputation& rep, const std::string& authorId, const RsPeerId& peerId);
private: private:
@ -182,11 +182,11 @@ class MsgRespPending : public AuthorPending
{ {
public: public:
MsgRespPending(RsGixsReputation* rep, const std::string& peerId, const MsgAuthorV& msgAuthV, int cutOff = 0); MsgRespPending(RsGixsReputation* rep, const RsPeerId& peerId, const MsgAuthorV& msgAuthV, int cutOff = 0);
int getType() const; int getType() const;
bool accepted(); bool accepted();
std::string mPeerId; RsPeerId mPeerId;
MsgAuthorV mMsgAuthV; MsgAuthorV mMsgAuthV;
int mCutOff; int mCutOff;
}; };
@ -195,10 +195,10 @@ class GrpRespPending : public AuthorPending
{ {
public: public:
GrpRespPending(RsGixsReputation* rep, const std::string& peerId, const GrpAuthorV& grpAuthV, int cutOff = 0); GrpRespPending(RsGixsReputation* rep, const RsPeerId& peerId, const GrpAuthorV& grpAuthV, int cutOff = 0);
int getType() const; int getType() const;
bool accepted(); bool accepted();
std::string mPeerId; RsPeerId mPeerId;
GrpAuthorV mGrpAuthV; GrpAuthorV mGrpAuthV;
int mCutOff; int mCutOff;
}; };
@ -261,23 +261,23 @@ private:
class GrpCircleIdRequestVetting : public GrpCircleVetting class GrpCircleIdRequestVetting : public GrpCircleVetting
{ {
public: public:
GrpCircleIdRequestVetting(RsGcxs* const circles, std::vector<GrpIdCircleVet> mGrpCircleV, const std::string& peerId); GrpCircleIdRequestVetting(RsGcxs* const circles, std::vector<GrpIdCircleVet> mGrpCircleV, const RsPeerId& peerId);
bool cleared(); bool cleared();
int getType() const; int getType() const;
std::vector<GrpIdCircleVet> mGrpCircleV; std::vector<GrpIdCircleVet> mGrpCircleV;
std::string mPeerId; RsPeerId mPeerId;
}; };
class MsgCircleIdsRequestVetting : public GrpCircleVetting class MsgCircleIdsRequestVetting : public GrpCircleVetting
{ {
public: public:
MsgCircleIdsRequestVetting(RsGcxs* const circles, std::vector<MsgIdCircleVet> msgs, const RsGxsGroupId& grpId, MsgCircleIdsRequestVetting(RsGcxs* const circles, std::vector<MsgIdCircleVet> msgs, const RsGxsGroupId& grpId,
const std::string& peerId, const RsGxsCircleId& circleId); const RsPeerId& peerId, const RsGxsCircleId& circleId);
bool cleared(); bool cleared();
int getType() const; int getType() const;
std::vector<MsgIdCircleVet> mMsgs; std::vector<MsgIdCircleVet> mMsgs;
RsGxsGroupId mGrpId; RsGxsGroupId mGrpId;
std::string mPeerId; RsPeerId mPeerId;
RsGxsCircleId mCircleId; RsGxsCircleId mCircleId;
}; };

View file

@ -109,7 +109,7 @@ public:
* @param enabled set to false to disable pause, and true otherwise * @param enabled set to false to disable pause, and true otherwise
* @return request token to be redeemed * @return request token to be redeemed
*/ */
virtual int requestGrp(const std::list<RsGxsGroupId>& grpId, const std::string& peerId) = 0; virtual int requestGrp(const std::list<RsGxsGroupId>& grpId, const RsPeerId& peerId) = 0;
}; };

View file

@ -410,19 +410,6 @@ std::string RsCertificate::hidden_node_string() const
return empty; return empty;
} }
std::string RsCertificate::sslid_string() const
{
if (only_pgp)
{
std::string empty;
return empty;
}
else
{
return location_id.toStdString(false);
}
}
std::string RsCertificate::ext_ip_string() const std::string RsCertificate::ext_ip_string() const
{ {
std::ostringstream os ; std::ostringstream os ;

View file

@ -30,7 +30,7 @@ class RsCertificate
std::string loc_ip_string() const ; std::string loc_ip_string() const ;
std::string location_name_string() const { return location_name; } std::string location_name_string() const { return location_name; }
std::string dns_string() const { return dns_name ; } std::string dns_string() const { return dns_name ; }
std::string sslid_string() const; RsPeerId sslid() const { return location_id ; }
std::string hidden_node_string() const; std::string hidden_node_string() const;
std::string armouredPGPKey() const ; std::string armouredPGPKey() const ;

View file

@ -427,7 +427,7 @@ static int initLib = 0;
return -1; return -1;
} }
std::string mownidstr ; RsPeerId mownidstr ;
if (!getX509id(x509, mownidstr)) if (!getX509id(x509, mownidstr))
{ {
@ -438,7 +438,7 @@ static int initLib = 0;
CloseAuth(); CloseAuth();
return -1; return -1;
} }
mOwnId = SSLIdType(mownidstr) ; mOwnId = mownidstr ;
assert(!mOwnId.isNull()) ; assert(!mOwnId.isNull()) ;
@ -1029,7 +1029,7 @@ bool AuthSSLimpl::ValidateCertificate(X509 *x509, SSLIdType &peerId)
#endif #endif
return false; return false;
} }
std::string peerIdstr ; RsPeerId peerIdstr ;
if(!getX509id(x509, peerIdstr)) if(!getX509id(x509, peerIdstr))
{ {
@ -1039,7 +1039,7 @@ bool AuthSSLimpl::ValidateCertificate(X509 *x509, SSLIdType &peerId)
#endif #endif
return false; return false;
} }
peerId = SSLIdType(peerIdstr) ; peerId = peerIdstr ;
#ifdef AUTHSSL_DEBUG #ifdef AUTHSSL_DEBUG
std::cerr << "AuthSSLimpl::ValidateCertificate() good certificate."; std::cerr << "AuthSSLimpl::ValidateCertificate() good certificate.";
@ -1076,11 +1076,9 @@ static int verify_x509_callback(int preverify_ok, X509_STORE_CTX *ctx)
} }
std::string sslcn = getX509CNString(x509->cert_info->subject); std::string sslcn = getX509CNString(x509->cert_info->subject);
std::string sslidstr ; RsPeerId sslid ;
getX509id(x509,sslidstr); getX509id(x509,sslid);
SSLIdType sslid(sslidstr) ;
if(sslid.isNull()) if(sslid.isNull())
{ {
@ -1182,7 +1180,7 @@ int AuthSSLimpl::VerifyX509Callback(int preverify_ok, X509_STORE_CTX *ctx)
if (preverify_ok) { if (preverify_ok) {
//sslcert *cert = NULL; //sslcert *cert = NULL;
std::string certId; RsPeerId certId;
getX509id(X509_STORE_CTX_get_current_cert(ctx), certId); getX509id(X509_STORE_CTX_get_current_cert(ctx), certId);
} }
@ -1551,19 +1549,18 @@ bool AuthSSLimpl::RemoveX509(SSLIdType id)
bool AuthSSLimpl::LocalStoreCert(X509* x509) bool AuthSSLimpl::LocalStoreCert(X509* x509)
{ {
//store the certificate in the local cert list //store the certificate in the local cert list
std::string peerIdstr ; RsPeerId peerId ;
if(!getX509id(x509, peerIdstr)) if(!getX509id(x509, peerId))
{ {
std::cerr << "AuthSSLimpl::LocalStoreCert() Cannot retrieve peer id from certificate." << std::endl; std::cerr << "AuthSSLimpl::LocalStoreCert() Cannot retrieve peer id from certificate." << std::endl;
#ifdef AUTHSSL_DEBUG #ifdef AUTHSSL_DEBUG
#endif #endif
return false; return false;
} }
SSLIdType peerId(peerIdstr);
if(peerId.isNull()) if(peerId.isNull())
{ {
std::cerr << "AuthSSLimpl::LocalStoreCert(): invalid peer id \"" << peerIdstr << "\"" << std::endl; std::cerr << "AuthSSLimpl::LocalStoreCert(): invalid peer id \"" << peerId << "\"" << std::endl;
return false ; return false ;
} }

View file

@ -810,10 +810,8 @@ bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId)
} }
/* remove id from all groups */ /* remove id from all groups */
std::list<RsPeerId> peerIds;
peerIds.push_back(id);
assignPeersToGroup("", peerIds, false); assignPeersToGroup("", pgpid_toRemove, false);
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
@ -1955,7 +1953,7 @@ bool p3PeerMgrIMPL::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
} }
// groupId == "" && assign == false -> remove from all groups // groupId == "" && assign == false -> remove from all groups
bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::list<RsPeerId> &peerIds, bool assign) bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::list<PGPIdType> &peerIds, bool assign)
{ {
if (groupId.empty() && assign == true) { if (groupId.empty() && assign == true) {
return false; return false;
@ -1975,9 +1973,9 @@ bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::li
if (groupId.empty() || (*groupIt)->id == groupId) { if (groupId.empty() || (*groupIt)->id == groupId) {
RsPeerGroupItem *groupItem = *groupIt; RsPeerGroupItem *groupItem = *groupIt;
std::list<RsPeerId>::const_iterator peerIt; std::list<PGPIdType>::const_iterator peerIt;
for (peerIt = peerIds.begin(); peerIt != peerIds.end(); peerIt++) { for (peerIt = peerIds.begin(); peerIt != peerIds.end(); peerIt++) {
std::list<RsPeerId>::iterator peerIt1 = std::find(groupItem->peerIds.begin(), groupItem->peerIds.end(), *peerIt); std::list<PGPIdType>::iterator peerIt1 = std::find(groupItem->peerIds.begin(), groupItem->peerIds.end(), *peerIt);
if (assign) { if (assign) {
if (peerIt1 == groupItem->peerIds.end()) { if (peerIt1 == groupItem->peerIds.end()) {
groupItem->peerIds.push_back(*peerIt); groupItem->peerIds.push_back(*peerIt);

View file

@ -133,7 +133,7 @@ virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) =
virtual bool removeGroup(const std::string &groupId) = 0; virtual bool removeGroup(const std::string &groupId) = 0;
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0; virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0; virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPeerId> &peerIds, bool assign) = 0; virtual bool assignPeersToGroup(const std::string &groupId, const std::list<PGPIdType> &peerIds, bool assign) = 0;
virtual ServicePermissionFlags servicePermissionFlags(const PGPIdType& gpg_id) =0; virtual ServicePermissionFlags servicePermissionFlags(const PGPIdType& gpg_id) =0;
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) =0; virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) =0;
@ -233,7 +233,7 @@ virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
virtual bool removeGroup(const std::string &groupId); virtual bool removeGroup(const std::string &groupId);
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo); virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList); virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPeerId> &peerIds, bool assign); virtual bool assignPeersToGroup(const std::string &groupId, const std::list<PGPIdType> &peerIds, bool assign);
virtual ServicePermissionFlags servicePermissionFlags(const PGPIdType& gpg_id) ; virtual ServicePermissionFlags servicePermissionFlags(const PGPIdType& gpg_id) ;
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) ; virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) ;

View file

@ -1219,14 +1219,14 @@ int pqissl::Extract_Failed_SSL_Certificate()
// which could be // which could be
// (pqissl's case) sslcert->serveraddr or sslcert->localaddr. // (pqissl's case) sslcert->serveraddr or sslcert->localaddr.
std::string sslid ; RsPeerId sslid ;
getX509id(peercert, sslid) ; getX509id(peercert, sslid) ;
PGPIdType gpgid(getX509CNString(peercert->cert_info->issuer)); PGPIdType gpgid(getX509CNString(peercert->cert_info->issuer));
std::string sslcn = getX509CNString(peercert->cert_info->subject); std::string sslcn = getX509CNString(peercert->cert_info->subject);
AuthSSL::getAuthSSL()->FailedCertificate(peercert, gpgid,RsPeerId(sslid),sslcn,remote_addr, false); AuthSSL::getAuthSSL()->FailedCertificate(peercert, gpgid,sslid,sslcn,remote_addr, false);
mLinkMgr->notifyDeniedConnection(gpgid, RsPeerId(sslid), sslcn, remote_addr, false); mLinkMgr->notifyDeniedConnection(gpgid, sslid, sslcn, remote_addr, false);
return 1; return 1;
} }
@ -1277,7 +1277,7 @@ int pqissl::Authorise_SSL_Connection()
return -1; return -1;
} }
std::string certPeerId; RsPeerId certPeerId;
getX509id(peercert, certPeerId); getX509id(peercert, certPeerId);
if (RsPeerId(certPeerId) != PeerId()) { if (RsPeerId(certPeerId) != PeerId()) {
rslog(RSL_WARNING, pqisslzone, rslog(RSL_WARNING, pqisslzone,

View file

@ -621,13 +621,14 @@ bool saveX509ToDER(X509 *x509, uint8_t **ptr, uint32_t *len)
} }
bool getX509id(X509 *x509, std::string &xid) { bool getX509id(X509 *x509, RsPeerId& xid)
{
#ifdef AUTHSSL_DEBUG #ifdef AUTHSSL_DEBUG
std::cerr << "AuthSSL::getX509id()"; std::cerr << "AuthSSL::getX509id()";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
xid = ""; xid.clear() ;
if (x509 == NULL) if (x509 == NULL)
{ {
#ifdef AUTHSSL_DEBUG #ifdef AUTHSSL_DEBUG
@ -652,14 +653,16 @@ bool getX509id(X509 *x509, std::string &xid) {
// else copy in the first CERTSIGNLEN. // else copy in the first CERTSIGNLEN.
unsigned char *signdata = ASN1_STRING_data(signature); unsigned char *signdata = ASN1_STRING_data(signature);
xid.clear();
/* switched to the other end of the signature. for /* switched to the other end of the signature. for
* more randomness * more randomness
*/ */
for(int i = signlen - CERTSIGNLEN; i < signlen; i++)
{ xid = RsPeerId(&signdata[signlen - CERTSIGNLEN]) ;
rs_sprintf_append(xid, "%02x", (uint16_t) (((uint8_t *) (signdata))[i]));
} //for(int i = signlen - CERTSIGNLEN; i < signlen; i++)
//{
// rs_sprintf_append(xid, "%02x", (uint16_t) (((uint8_t *) (signdata))[i]));
//}
return true; return true;
} }
@ -690,7 +693,7 @@ bool CheckX509Certificate(X509 */*x509*/)
// Not dependent on sslroot. load, and detroys the X509 memory. // Not dependent on sslroot. load, and detroys the X509 memory.
int LoadCheckX509(const char *cert_file, std::string &issuerName, std::string &location, std::string &userId) int LoadCheckX509(const char *cert_file, PGPIdType& issuerName, std::string &location, RsPeerId &userId)
{ {
/* This function loads the X509 certificate from the file, /* This function loads the X509 certificate from the file,
* and checks the certificate * and checks the certificate
@ -725,7 +728,7 @@ int LoadCheckX509(const char *cert_file, std::string &issuerName, std::string &l
if (valid) if (valid)
{ {
// extract the name. // extract the name.
issuerName = getX509CNString(x509->cert_info->issuer); issuerName = PGPIdType(std::string(getX509CNString(x509->cert_info->issuer)));
location = getX509LocString(x509->cert_info->subject); location = getX509LocString(x509->cert_info->subject);
} }

View file

@ -37,6 +37,7 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include <inttypes.h> #include <inttypes.h>
#include <retroshare/rstypes.h>
#include <string> #include <string>
/**** /****
@ -98,7 +99,7 @@ std::string saveX509ToPEM(X509* x509);
X509 *loadX509FromDER(const uint8_t *ptr, uint32_t len); X509 *loadX509FromDER(const uint8_t *ptr, uint32_t len);
bool saveX509ToDER(X509 *x509, uint8_t **ptr, uint32_t *len); bool saveX509ToDER(X509 *x509, uint8_t **ptr, uint32_t *len);
bool getX509id(X509 *x509, std::string &xid); bool getX509id(X509 *x509, RsPeerId &xid);
/********************************************************************************/ /********************************************************************************/
/********************************************************************************/ /********************************************************************************/
@ -110,7 +111,7 @@ int pem_passwd_cb(char *buf, int size, int rwflag, void *password);
bool CheckX509Certificate(X509 *x509); bool CheckX509Certificate(X509 *x509);
// Not dependent on sslroot. load, and detroys the X509 memory. // Not dependent on sslroot. load, and detroys the X509 memory.
int LoadCheckX509(const char *cert_file, std::string &issuerName, std::string &location, std::string &userId); int LoadCheckX509(const char *cert_file, PGPIdType& issuer, std::string &location, RsPeerId& userId);
std::string getX509NameString(X509_NAME *name); std::string getX509NameString(X509_NAME *name);

View file

@ -27,6 +27,7 @@
*/ */
#include <inttypes.h> #include <inttypes.h>
#include <retroshare/rstypes.h>
#include <string> #include <string>
#include <list> #include <list>
#include <map> #include <map>
@ -35,10 +36,6 @@
class RsServerConfig; class RsServerConfig;
extern RsServerConfig *rsConfig; extern RsServerConfig *rsConfig;
#define RSNET_NETWORK_UNKNOWN 1 #define RSNET_NETWORK_UNKNOWN 1
#define RSNET_NETWORK_RESTARTING 2 #define RSNET_NETWORK_RESTARTING 2
#define RSNET_NETWORK_OFFLINE 3 #define RSNET_NETWORK_OFFLINE 3
@ -188,7 +185,7 @@ class RsConfigNetStatus
} }
std::string ownId; RsPeerId ownId;
std::string ownName; std::string ownName;
std::string localAddr; std::string localAddr;

View file

@ -167,8 +167,8 @@ virtual ~RsDht() { return; }
virtual uint32_t getNetState(uint32_t type) = 0; virtual uint32_t getNetState(uint32_t type) = 0;
virtual int getDhtPeers(int lvl, std::list<RsDhtPeer> &peers) = 0; virtual int getDhtPeers(int lvl, std::list<RsDhtPeer> &peers) = 0;
virtual int getNetPeerList(std::list<std::string> &peerIds) = 0; virtual int getNetPeerList(std::list<RsPeerId> &peerIds) = 0;
virtual int getNetPeerStatus(std::string peerId, RsDhtNetPeer &status) = 0; virtual int getNetPeerStatus(const RsPeerId& peerId, RsDhtNetPeer &status) = 0;
virtual int getRelayEnds(std::list<RsDhtRelayEnd> &relayEnds) = 0; virtual int getRelayEnds(std::list<RsDhtRelayEnd> &relayEnds) = 0;
virtual int getRelayProxies(std::list<RsDhtRelayProxy> &relayProxies) = 0; virtual int getRelayProxies(std::list<RsDhtRelayProxy> &relayProxies) = 0;

View file

@ -31,6 +31,7 @@
#include <list> #include <list>
#include <set> #include <set>
#include "retroshare/rstypes.h"
#include "retroshare/rstokenservice.h" #include "retroshare/rstokenservice.h"
#include "retroshare/rsgxsifacehelper.h" #include "retroshare/rsgxsifacehelper.h"

View file

@ -77,7 +77,7 @@ class RsControl /* The Main Interface Class - for controlling the server */
/****************************************/ /****************************************/
virtual bool getPeerCryptoDetails(const std::string& ssl_id,RsPeerCryptoParams& params) = 0; virtual bool getPeerCryptoDetails(const RsPeerId& ssl_id,RsPeerCryptoParams& params) = 0;
protected: protected:
RsControl() {} // should not be used, hence it's private. RsControl() {} // should not be used, hence it's private.

View file

@ -45,6 +45,7 @@
#include <list> #include <list>
#include <map> #include <map>
#include <vector> #include <vector>
#include <retroshare/rstypes.h>
/*! /*!
* Initialisation Class (not publicly disclosed to RsIFace) * Initialisation Class (not publicly disclosed to RsIFace)
@ -136,26 +137,26 @@ namespace RsAccounts
std::string AccountDirectory(); std::string AccountDirectory();
// PGP Accounts. // PGP Accounts.
int GetPGPLogins(std::list<std::string> &pgpIds); int GetPGPLogins(std::list<PGPIdType> &pgpIds);
int GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email); int GetPGPLoginDetails(const PGPIdType& id, std::string &name, std::string &email);
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString); bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, PGPIdType &pgpId, std::string &errString);
// PGP Support Functions. // PGP Support Functions.
bool ExportIdentity(const std::string& fname,const std::string& pgp_id) ; bool ExportIdentity(const std::string& fname,const PGPIdType& pgp_id) ;
bool ImportIdentity(const std::string& fname,std::string& imported_pgp_id,std::string& import_error) ; bool ImportIdentity(const std::string& fname,PGPIdType& imported_pgp_id,std::string& import_error) ;
void GetUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys); void GetUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
bool CopyGnuPGKeyrings() ; bool CopyGnuPGKeyrings() ;
// Rs Accounts // Rs Accounts
bool SelectAccount(const std::string &id); bool SelectAccount(const RsPeerId& id);
bool GetPreferredAccountId(std::string &id); bool GetPreferredAccountId(RsPeerId &id);
bool GetAccountIds(std::list<std::string> &ids); bool GetAccountIds(std::list<RsPeerId> &ids);
bool GetAccountDetails(const std::string &id, bool GetAccountDetails(const RsPeerId &id,
std::string &gpgId, std::string &gpgName, PGPIdType &gpgId, std::string &gpgName,
std::string &gpgEmail, std::string &location); std::string &gpgEmail, std::string &location);
bool GenerateSSLCertificate(const std::string& name, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, std::string &sslId, std::string &errString); bool GenerateSSLCertificate(const PGPIdType& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString);
}; };

View file

@ -198,7 +198,7 @@ class RsPeerDetails
PGPIdType issuer; PGPIdType issuer;
PGPFingerprintType fpr; /* pgp fingerprint */ PGPFingerprintType fpr; /* pgp fingerprint */
//std::string authcode; // (cyril) what is this used for ????? std::string authcode; // (cyril) what is this used for ?????
std::list<PGPIdType> gpgSigners; std::list<PGPIdType> gpgSigners;
uint32_t trustLvl; uint32_t trustLvl;
@ -274,7 +274,7 @@ public:
std::string name; std::string name;
uint32_t flag; uint32_t flag;
std::list<SSLIdType> peerIds; std::list<PGPIdType> peerIds;
}; };
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail); std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
@ -308,7 +308,7 @@ class RsPeers
virtual bool getGPGDetails(const PGPIdType& gpg_id, RsPeerDetails &d) = 0; virtual bool getGPGDetails(const PGPIdType& gpg_id, RsPeerDetails &d) = 0;
/* Using PGP Ids */ /* Using PGP Ids */
virtual PGPIdType getGPGOwnId() = 0; virtual const PGPIdType& getGPGOwnId() = 0;
virtual PGPIdType getGPGId(const SSLIdType& sslid) = 0; //return the gpg id of the given ssl id virtual PGPIdType getGPGId(const SSLIdType& sslid) = 0; //return the gpg id of the given ssl id
virtual bool isKeySupported(const PGPIdType& gpg_ids) = 0; virtual bool isKeySupported(const PGPIdType& gpg_ids) = 0;
virtual bool getGPGAcceptedList(std::list<PGPIdType> &gpg_ids) = 0; virtual bool getGPGAcceptedList(std::list<PGPIdType> &gpg_ids) = 0;
@ -375,8 +375,8 @@ class RsPeers
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0; virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0; virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
// groupId == "" && assign == false -> remove from all groups // groupId == "" && assign == false -> remove from all groups
virtual bool assignPeerToGroup(const std::string &groupId, const SSLIdType& peerId, bool assign) = 0; virtual bool assignPeerToGroup(const std::string &groupId, const PGPIdType& peerId, bool assign) = 0;
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<SSLIdType> &peerIds, bool assign) = 0; virtual bool assignPeersToGroup(const std::string &groupId, const std::list<PGPIdType> &peerIds, bool assign) = 0;
/* Group sharing permission */ /* Group sharing permission */
@ -389,7 +389,7 @@ class RsPeers
// ... computes the sharing file permission hint flags set for this peer, that is a combination of // ... computes the sharing file permission hint flags set for this peer, that is a combination of
// RS_FILE_HINTS_NETWORK_WIDE and RS_FILE_HINTS_BROWSABLE. // RS_FILE_HINTS_NETWORK_WIDE and RS_FILE_HINTS_BROWSABLE.
// //
virtual FileSearchFlags computePeerPermissionFlags(const SSLIdType& peer_id,FileStorageFlags file_sharing_flags,const std::list<std::string>& file_parent_groups) = 0; virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags file_sharing_flags,const std::list<std::string>& file_parent_groups) = 0;
/* Service permission flags */ /* Service permission flags */

View file

@ -56,7 +56,7 @@ class RsRtt
RsRtt() { return; } RsRtt() { return; }
virtual ~RsRtt() { return; } virtual ~RsRtt() { return; }
virtual uint32_t getPongResults(std::string id, int n, std::list<RsRttPongResult> &results) = 0; virtual uint32_t getPongResults(const RsPeerId& id, int n, std::list<RsRttPongResult> &results) = 0;
}; };

View file

@ -169,7 +169,7 @@ const RsPeerId& p3Peers::getOwnId()
return AuthSSL::getAuthSSL()->OwnId(); return AuthSSL::getAuthSSL()->OwnId();
} }
bool p3Peers::getOnlineList(std::list<std::string> &ids) bool p3Peers::getOnlineList(std::list<RsPeerId> &ids)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getOnlineList()" << std::endl; std::cerr << "p3Peers::getOnlineList()" << std::endl;
@ -180,7 +180,7 @@ bool p3Peers::getOnlineList(std::list<std::string> &ids)
return true; return true;
} }
bool p3Peers::getFriendList(std::list<std::string> &ids) bool p3Peers::getFriendList(std::list<RsPeerId> &ids)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getFriendList()" << std::endl; std::cerr << "p3Peers::getFriendList()" << std::endl;
@ -215,7 +215,7 @@ bool p3Peers::getPeerCount (unsigned int *friendCount, unsigned int *onlineCount
return true; return true;
} }
bool p3Peers::isOnline(const std::string &id) bool p3Peers::isOnline(const RsPeerId &id)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::isOnline() " << id << std::endl; std::cerr << "p3Peers::isOnline() " << id << std::endl;
@ -231,7 +231,7 @@ bool p3Peers::isOnline(const std::string &id)
return false; return false;
} }
bool p3Peers::isFriend(const std::string &ssl_id) bool p3Peers::isFriend(const RsPeerId &ssl_id)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::isFriend() " << ssl_id << std::endl; std::cerr << "p3Peers::isFriend() " << ssl_id << std::endl;
@ -241,7 +241,7 @@ bool p3Peers::isFriend(const std::string &ssl_id)
return mPeerMgr->isFriend(ssl_id); return mPeerMgr->isFriend(ssl_id);
} }
bool p3Peers::haveSecretKey(const std::string& id) bool p3Peers::haveSecretKey(const PGPIdType& id)
{ {
return AuthGPG::getAuthGPG()->haveSecretKey(id) ; return AuthGPG::getAuthGPG()->haveSecretKey(id) ;
} }
@ -250,7 +250,7 @@ bool p3Peers::haveSecretKey(const std::string& id)
* to shift it immeidately * to shift it immeidately
*/ */
bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d) bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPeerDetails() called for id : " << id << std::endl; std::cerr << "p3Peers::getPeerDetails() called for id : " << id << std::endl;
@ -258,7 +258,7 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
// NOW Only for SSL Details. // NOW Only for SSL Details.
std::string sOwnId = AuthSSL::getAuthSSL()->OwnId(); RsPeerId sOwnId = AuthSSL::getAuthSSL()->OwnId();
peerState ps; peerState ps;
if (id == sOwnId) if (id == sOwnId)
@ -266,30 +266,29 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
mPeerMgr->getOwnNetStatus(ps); mPeerMgr->getOwnNetStatus(ps);
ps.gpg_id = AuthGPG::getAuthGPG()->getGPGOwnId(); ps.gpg_id = AuthGPG::getAuthGPG()->getGPGOwnId();
} }
else else if (!mPeerMgr->getFriendNetStatus(id, ps))
{
if (!mPeerMgr->getFriendNetStatus(id, ps))
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPeerDetails() ERROR not an SSL Id: " << id << std::endl; std::cerr << "p3Peers::getPeerDetails() ERROR not an SSL Id: " << id << std::endl;
#endif #endif
bool res = getGPGDetails(id, d); return false ;
d.isOnlyGPGdetail = true;
if(id.length() == 16)
d.service_perm_flags = mPeerMgr->servicePermissionFlags(id) ;
else if(id.length() == 32)
d.service_perm_flags = mPeerMgr->servicePermissionFlags_sslid(id) ;
else
{
std::cerr << "p3Peers::getPeerDetails() ERROR not an correct Id: " << id << std::endl;
d.service_perm_flags = RS_SERVICE_PERM_NONE ;
} }
return res ; // bool res = getGPGDetails(id, d);
} //
} // d.isOnlyGPGdetail = true;
//
// if(id.length() == 16)
// d.service_perm_flags = mPeerMgr->servicePermissionFlags(id) ;
// else if(id.length() == 32)
// d.service_perm_flags = mPeerMgr->servicePermissionFlags(id) ;
// else
// {
// std::cerr << "p3Peers::getPeerDetails() ERROR not an correct Id: " << id << std::endl;
// d.service_perm_flags = RS_SERVICE_PERM_NONE ;
// }
//
// return res ;
/* get from gpg (first), to fill in the sign and trust details */ /* get from gpg (first), to fill in the sign and trust details */
/* don't retrun now, we've got fill in the ssl and connection info */ /* don't retrun now, we've got fill in the ssl and connection info */
@ -454,47 +453,44 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
return true; return true;
} }
bool p3Peers::isKeySupported(const std::string& id) bool p3Peers::isKeySupported(const PGPIdType& id)
{ {
return AuthGPG::getAuthGPG()->isKeySupported(id); return AuthGPG::getAuthGPG()->isKeySupported(id);
} }
std::string p3Peers::getGPGName(const std::string &gpg_id) std::string p3Peers::getGPGName(const PGPIdType &gpg_id)
{ {
/* get from mAuthMgr as it should have more peers? */ /* get from mAuthMgr as it should have more peers? */
return AuthGPG::getAuthGPG()->getGPGName(gpg_id); return AuthGPG::getAuthGPG()->getGPGName(gpg_id);
} }
bool p3Peers::isGPGAccepted(const std::string &gpg_id_is_friend) bool p3Peers::isGPGAccepted(const PGPIdType &gpg_id_is_friend)
{ {
/* get from mAuthMgr as it should have more peers? */ /* get from mAuthMgr as it should have more peers? */
return AuthGPG::getAuthGPG()->isGPGAccepted(gpg_id_is_friend); return AuthGPG::getAuthGPG()->isGPGAccepted(gpg_id_is_friend);
} }
std::string p3Peers::getPeerName(const std::string &ssl_or_gpg_id) std::string p3Peers::getPeerName(const RsPeerId& ssl)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPeerName() " << ssl_or_gpg_id << std::endl; std::cerr << "p3Peers::getPeerName() " << ssl_or_gpg_id << std::endl;
#endif #endif
std::string name; std::string name;
if (ssl_or_gpg_id == AuthSSL::getAuthSSL()->OwnId()) if (ssl == AuthSSL::getAuthSSL()->OwnId())
{
return AuthGPG::getAuthGPG()->getGPGOwnName(); return AuthGPG::getAuthGPG()->getGPGOwnName();
}
if (mPeerMgr->getPeerName(ssl_or_gpg_id, name)) if (mPeerMgr->getPeerName(ssl, name))
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPeerName() got a ssl id. Name is : " << name << std::endl; std::cerr << "p3Peers::getPeerName() got a ssl id. Name is : " << name << std::endl;
#endif #endif
return name; return name;
} }
return std::string() ;
return AuthGPG::getAuthGPG()->getGPGName(ssl_or_gpg_id);
} }
bool p3Peers::getGPGAllList(std::list<std::string> &ids) bool p3Peers::getGPGAllList(std::list<PGPIdType> &ids)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getGPGAllList()" << std::endl; std::cerr << "p3Peers::getGPGAllList()" << std::endl;
@ -505,7 +501,7 @@ bool p3Peers::getGPGAllList(std::list<std::string> &ids)
return true; return true;
} }
bool p3Peers::getGPGValidList(std::list<std::string> &ids) bool p3Peers::getGPGValidList(std::list<PGPIdType> &ids)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPGPOthersList()" << std::endl; std::cerr << "p3Peers::getPGPOthersList()" << std::endl;
@ -516,7 +512,7 @@ bool p3Peers::getGPGValidList(std::list<std::string> &ids)
return true; return true;
} }
bool p3Peers::getGPGSignedList(std::list<std::string> &ids) bool p3Peers::getGPGSignedList(std::list<PGPIdType> &ids)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPGPOthersList()" << std::endl; std::cerr << "p3Peers::getPGPOthersList()" << std::endl;
@ -527,7 +523,7 @@ bool p3Peers::getGPGSignedList(std::list<std::string> &ids)
return true; return true;
} }
bool p3Peers::getGPGAcceptedList(std::list<std::string> &ids) bool p3Peers::getGPGAcceptedList(std::list<PGPIdType> &ids)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getGPGAcceptedList()" << std::endl; std::cerr << "p3Peers::getGPGAcceptedList()" << std::endl;
@ -537,7 +533,7 @@ bool p3Peers::getGPGAcceptedList(std::list<std::string> &ids)
} }
bool p3Peers::getAssociatedSSLIds(const std::string &gpg_id, std::list<std::string> &ids) bool p3Peers::getAssociatedSSLIds(const PGPIdType &gpg_id, std::list<RsPeerId> &ids)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getAssociatedSSLIds() for id : " << gpg_id << std::endl; std::cerr << "p3Peers::getAssociatedSSLIds() for id : " << gpg_id << std::endl;
@ -551,7 +547,7 @@ bool p3Peers::gpgSignData(const void *data, const uint32_t len, unsigned char
return AuthGPG::getAuthGPG()->SignDataBin(data,len,sign,signlen); return AuthGPG::getAuthGPG()->SignDataBin(data,len,sign,signlen);
} }
bool p3Peers::getGPGDetails(const std::string &id, RsPeerDetails &d) bool p3Peers::getGPGDetails(const PGPIdType &id, RsPeerDetails &d)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPgpDetails() called for id : " << id << std::endl; std::cerr << "p3Peers::getPgpDetails() called for id : " << id << std::endl;
@ -561,7 +557,7 @@ bool p3Peers::getGPGDetails(const std::string &id, RsPeerDetails &d)
return AuthGPG::getAuthGPG()->getGPGDetails(id, d); return AuthGPG::getAuthGPG()->getGPGDetails(id, d);
} }
std::string p3Peers::getGPGOwnId() const PGPIdType& p3Peers::getGPGOwnId()
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPGPOwnId()" << std::endl; std::cerr << "p3Peers::getPGPOwnId()" << std::endl;
@ -571,28 +567,23 @@ std::string p3Peers::getGPGOwnId()
return AuthGPG::getAuthGPG()->getGPGOwnId(); return AuthGPG::getAuthGPG()->getGPGOwnId();
} }
std::string p3Peers::getGPGId(const std::string &sslid_or_gpgid) PGPIdType p3Peers::getGPGId(const RsPeerId& sslid)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPGPId()" << std::endl; std::cerr << "p3Peers::getPGPId()" << std::endl;
#endif #endif
/* get from mAuthMgr */ /* get from mAuthMgr */
if (sslid_or_gpgid == AuthSSL::getAuthSSL()->OwnId()) { if (sslid == AuthSSL::getAuthSSL()->OwnId())
{
return AuthGPG::getAuthGPG()->getGPGOwnId(); return AuthGPG::getAuthGPG()->getGPGOwnId();
} }
peerState pcs; peerState pcs;
if (mPeerMgr->getFriendNetStatus(sslid_or_gpgid, pcs) || mPeerMgr->getOthersNetStatus(sslid_or_gpgid, pcs)) { if (mPeerMgr->getFriendNetStatus(sslid, pcs) || mPeerMgr->getOthersNetStatus(sslid, pcs)) {
return pcs.gpg_id; return pcs.gpg_id;
} else {
if ( AuthGPG::getAuthGPG()->isGPGId(sslid_or_gpgid)) {
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPGPId() given id is already an gpg id : " << sslid_or_gpgid << std::endl;
#endif
return sslid_or_gpgid;
} }
}
return ""; return PGPIdType();
} }
@ -601,13 +592,13 @@ std::string p3Peers::getGPGId(const std::string &sslid_or_gpgid)
*/ */
/* Add/Remove Friends */ /* Add/Remove Friends */
bool p3Peers::addFriend(const std::string &ssl_id, const std::string &gpg_id,ServicePermissionFlags perm_flags) bool p3Peers::addFriend(const RsPeerId &ssl_id, const PGPIdType &gpg_id,ServicePermissionFlags perm_flags)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::addFriend() with : id : " << id << "; gpg_id : " << gpg_id << std::endl; std::cerr << "p3Peers::addFriend() with : id : " << id << "; gpg_id : " << gpg_id << std::endl;
#endif #endif
if (AuthGPG::getAuthGPG()->isGPGId(gpg_id)) if(AuthGPG::getAuthGPG()->isGPGId(gpg_id))
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::addFriend() Authorising GPG Id: " << gpg_id << std::endl; std::cerr << "p3Peers::addFriend() Authorising GPG Id: " << gpg_id << std::endl;
@ -634,7 +625,7 @@ bool p3Peers::addFriend(const std::string &ssl_id, const std::string &gpg_id,Se
return false; return false;
} }
if (ssl_id == gpg_id || ssl_id == "") if(ssl_id.isNull())
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::addFriend() WARNING id is NULL or gpgId" << std::endl; std::cerr << "p3Peers::addFriend() WARNING id is NULL or gpgId" << std::endl;
@ -650,12 +641,12 @@ bool p3Peers::addFriend(const std::string &ssl_id, const std::string &gpg_id,Se
return mPeerMgr->addFriend(ssl_id, gpg_id, RS_NET_MODE_UDP, RS_VS_DISC_FULL, RS_VS_DHT_FULL, now, perm_flags); return mPeerMgr->addFriend(ssl_id, gpg_id, RS_NET_MODE_UDP, RS_VS_DISC_FULL, RS_VS_DHT_FULL, now, perm_flags);
} }
bool p3Peers::removeKeysFromPGPKeyring(const std::list<std::string>& pgp_ids,std::string& backup_file,uint32_t& error_code) bool p3Peers::removeKeysFromPGPKeyring(const std::list<PGPIdType>& pgp_ids,std::string& backup_file,uint32_t& error_code)
{ {
return AuthGPG::getAuthGPG()->removeKeysFromPGPKeyring(pgp_ids,backup_file,error_code) ; return AuthGPG::getAuthGPG()->removeKeysFromPGPKeyring(pgp_ids,backup_file,error_code) ;
} }
bool p3Peers::removeFriendLocation(const std::string &sslId) bool p3Peers::removeFriendLocation(const RsPeerId &sslId)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeFriendLocation() " << sslId << std::endl; std::cerr << "p3Peers::removeFriendLocation() " << sslId << std::endl;
@ -666,7 +657,7 @@ bool p3Peers::removeFriendLocation(const std::string &sslId)
} }
bool p3Peers::removeFriend(const std::string &gpgId) bool p3Peers::removeFriend(const PGPIdType& gpgId)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeFriend() " << gpgId << std::endl; std::cerr << "p3Peers::removeFriend() " << gpgId << std::endl;
@ -676,8 +667,6 @@ bool p3Peers::removeFriend(const std::string &gpgId)
return false; return false;
} }
if (AuthGPG::getAuthGPG()->isGPGId(gpgId))
{
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeFriend() Removing GPG Id: " << gpgId << std::endl; std::cerr << "p3Peers::removeFriend() Removing GPG Id: " << gpgId << std::endl;
#endif #endif
@ -697,22 +686,12 @@ bool p3Peers::removeFriend(const std::string &gpgId)
mPeerMgr->removeAllFriendLocations(gpgId); mPeerMgr->removeAllFriendLocations(gpgId);
return false; return false;
} }
}
else
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeFriend() Not GPG Id: " << gpg_id << std::endl;
#endif
return removeFriendLocation(gpgId);
}
return false;
} }
/* Network Stuff */ /* Network Stuff */
bool p3Peers::connectAttempt(const std::string &id) bool p3Peers::connectAttempt(const RsPeerId &id)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::connectAttempt() " << id << std::endl; std::cerr << "p3Peers::connectAttempt() " << id << std::endl;
@ -735,7 +714,7 @@ bool p3Peers::getAllowServerIPDetermination()
return mNetMgr->getIPServersEnabled() ; return mNetMgr->getIPServersEnabled() ;
} }
bool p3Peers::setLocation(const std::string &ssl_id, const std::string &location) bool p3Peers::setLocation(const RsPeerId &ssl_id, const std::string &location)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setLocation() " << ssl_id << std::endl; std::cerr << "p3Peers::setLocation() " << ssl_id << std::endl;
@ -783,7 +762,7 @@ bool splitAddressString(const std::string &addr, std::string &domain, uint16_t
} }
bool p3Peers::setHiddenNode(const std::string &id, const std::string &hidden_node_address) bool p3Peers::setHiddenNode(const RsPeerId &id, const std::string &hidden_node_address)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setHiddenNode() " << id << std::endl; std::cerr << "p3Peers::setHiddenNode() " << id << std::endl;
@ -801,7 +780,7 @@ bool p3Peers::setHiddenNode(const std::string &id, const std::string &hidden_no
} }
bool p3Peers::setHiddenNode(const std::string &id, const std::string &address, uint16_t port) bool p3Peers::setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setHiddenNode() " << id << std::endl; std::cerr << "p3Peers::setHiddenNode() " << id << std::endl;
@ -814,7 +793,7 @@ bool p3Peers::setHiddenNode(const std::string &id, const std::string &address,
return true; return true;
} }
bool p3Peers::setLocalAddress(const std::string &id, const std::string &addr_str, uint16_t port) bool p3Peers::setLocalAddress(const RsPeerId &id, const std::string &addr_str, uint16_t port)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setLocalAddress() " << id << std::endl; std::cerr << "p3Peers::setLocalAddress() " << id << std::endl;
@ -840,7 +819,7 @@ bool p3Peers::setLocalAddress(const std::string &id, const std::string &addr_st
return false; return false;
} }
bool p3Peers::setExtAddress(const std::string &id, const std::string &addr_str, uint16_t port) bool p3Peers::setExtAddress(const RsPeerId &id, const std::string &addr_str, uint16_t port)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setExtAddress() " << id << std::endl; std::cerr << "p3Peers::setExtAddress() " << id << std::endl;
@ -867,7 +846,7 @@ bool p3Peers::setExtAddress(const std::string &id, const std::string &addr_str,
return false; return false;
} }
bool p3Peers::setDynDNS(const std::string &id, const std::string &dyndns) bool p3Peers::setDynDNS(const RsPeerId &id, const std::string &dyndns)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setDynDNS() called with id: " << id << " dyndns: " << dyndns <<std::endl; std::cerr << "p3Peers::setDynDNS() called with id: " << id << " dyndns: " << dyndns <<std::endl;
@ -875,7 +854,7 @@ bool p3Peers::setDynDNS(const std::string &id, const std::string &dyndns)
return mPeerMgr->setDynDNS(id, dyndns); return mPeerMgr->setDynDNS(id, dyndns);
} }
bool p3Peers::setNetworkMode(const std::string &id, uint32_t extNetMode) bool p3Peers::setNetworkMode(const RsPeerId &id, uint32_t extNetMode)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setNetworkMode() " << id << std::endl; std::cerr << "p3Peers::setNetworkMode() " << id << std::endl;
@ -908,7 +887,7 @@ bool p3Peers::setNetworkMode(const std::string &id, uint32_t extNetMode)
} }
bool p3Peers::setVisState(const std::string &id, uint16_t vs_disc, uint16_t vs_dht) bool p3Peers::setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setVisState() " << id << std::endl; std::cerr << "p3Peers::setVisState() " << id << std::endl;
@ -973,7 +952,7 @@ p3Peers::GetRetroshareInvite(bool include_signatures)
return GetRetroshareInvite(getOwnId(),include_signatures); return GetRetroshareInvite(getOwnId(),include_signatures);
} }
bool p3Peers::GetPGPBase64StringAndCheckSum( const std::string& gpg_id, bool p3Peers::GetPGPBase64StringAndCheckSum( const PGPIdType& gpg_id,
std::string& gpg_base64_string, std::string& gpg_base64_string,
std::string& gpg_base64_checksum) std::string& gpg_base64_checksum)
{ {
@ -998,7 +977,7 @@ bool p3Peers::GetPGPBase64StringAndCheckSum( const std::string& gpg_id,
return true ; return true ;
} }
std::string p3Peers::GetRetroshareInvite(const std::string& ssl_id,bool include_signatures) std::string p3Peers::GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::GetRetroshareInvite()" << std::endl; std::cerr << "p3Peers::GetRetroshareInvite()" << std::endl;
@ -1033,15 +1012,15 @@ std::string p3Peers::GetRetroshareInvite(const std::string& ssl_id,bool include_
//=========================================================================== //===========================================================================
bool p3Peers::loadCertificateFromString(const std::string& cert, std::string& ssl_id, std::string& gpg_id, std::string& error_string) bool p3Peers::loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id, PGPIdType& gpg_id, std::string& error_string)
{ {
RsCertificate crt(cert) ; RsCertificate crt(cert) ;
PGPIdType gpgid ; PGPIdType gpgid ;
bool res = AuthGPG::getAuthGPG()->LoadCertificateFromString(crt.armouredPGPKey(),gpgid,error_string) ; bool res = AuthGPG::getAuthGPG()->LoadCertificateFromString(crt.armouredPGPKey(),gpgid,error_string) ;
gpg_id = gpgid.toStdString() ; gpg_id = gpgid;
ssl_id = crt.sslid_string() ; ssl_id = crt.sslid() ;
return res ; return res ;
} }
@ -1064,10 +1043,10 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
std::cerr << "Parsing cert for sslid, location, ext and local address details. : " << certstr << std::endl; std::cerr << "Parsing cert for sslid, location, ext and local address details. : " << certstr << std::endl;
#endif #endif
pd.id = cert.sslid_string() ; pd.id = cert.sslid() ;
pd.location = cert.location_name_string(); pd.location = cert.location_name_string();
pd.isOnlyGPGdetail = pd.id.empty(); pd.isOnlyGPGdetail = pd.id.isNull();
pd.service_perm_flags = RS_SERVICE_PERM_ALL ; pd.service_perm_flags = RS_SERVICE_PERM_ALL ;
if (!cert.hidden_node_string().empty()) if (!cert.hidden_node_string().empty())
@ -1099,7 +1078,7 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
return false ; return false ;
} }
if (pd.gpg_id == "") if (pd.gpg_id.isNull())
return false; return false;
else else
return true; return true;
@ -1112,7 +1091,7 @@ bool p3Peers::cleanCertificate(const std::string &certstr, std::string &cleanCer
return RsCertificate::cleanCertificate(certstr,cleanCert,format,error_code) ; return RsCertificate::cleanCertificate(certstr,cleanCert,format,error_code) ;
} }
bool p3Peers::saveCertificateToFile(const std::string &id, const std::string &/*fname*/) bool p3Peers::saveCertificateToFile(const RsPeerId &id, const std::string &/*fname*/)
{ {
/* remove unused parameter warnings */ /* remove unused parameter warnings */
(void) id; (void) id;
@ -1128,7 +1107,7 @@ bool p3Peers::saveCertificateToFile(const std::string &id, const std::string &/
return false; return false;
} }
std::string p3Peers::saveCertificateToString(const std::string &id) std::string p3Peers::saveCertificateToString(const RsPeerId &id)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::SaveCertificateToString() " << id; std::cerr << "p3Peers::SaveCertificateToString() " << id;
@ -1141,7 +1120,7 @@ std::string p3Peers::saveCertificateToString(const std::string &id)
} }
} }
bool p3Peers::signGPGCertificate(const std::string &id) bool p3Peers::signGPGCertificate(const PGPIdType &id)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::SignCertificate() " << id; std::cerr << "p3Peers::SignCertificate() " << id;
@ -1154,54 +1133,15 @@ bool p3Peers::signGPGCertificate(const std::string &id)
} }
bool p3Peers::trustGPGCertificate(const std::string &id, uint32_t trustlvl) bool p3Peers::trustGPGCertificate(const PGPIdType &id, uint32_t trustlvl)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::TrustCertificate() " << id; std::cerr << "p3Peers::TrustCertificate() " << id;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
//check if we've got a ssl or gpg id
std::string gpgId = getGPGId(id);
if (gpgId.empty()) {
//if no result then it must be a gpg id
return AuthGPG::getAuthGPG()->TrustCertificate(id, trustlvl); return AuthGPG::getAuthGPG()->TrustCertificate(id, trustlvl);
} else {
return AuthGPG::getAuthGPG()->TrustCertificate(gpgId, trustlvl);
}
} }
//int ensureExtension(std::string &name, std::string def_ext)
//{
// /* if it has an extension, don't change */
// int len = name.length();
// int extpos = name.find_last_of('.');
// std::string out;
// rs_sprintf_append(out, "ensureExtension() name: %s\n\t\t extpos: %d len: \n", name.c_str(), extpos, len);
// /* check that the '.' has between 1 and 4 char after it (an extension) */
// if ((extpos > 0) && (extpos < len - 1) && (extpos + 6 > len))
// {
// /* extension there */
// std::string curext = name.substr(extpos, len);
// out += "ensureExtension() curext: " + curext;
// std::cerr << out << std::endl;
// return 0;
// }
// if (extpos != len - 1)
// {
// name += ".";
// }
// name += def_ext;
// out += "ensureExtension() added ext: " + name;
// std::cerr << out << std::endl;
// return 1;
//}
/* Group Stuff */ /* Group Stuff */
bool p3Peers::addGroup(RsGroupInfo &groupInfo) bool p3Peers::addGroup(RsGroupInfo &groupInfo)
{ {
@ -1255,15 +1195,15 @@ bool p3Peers::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
return mPeerMgr->getGroupInfoList(groupInfoList); return mPeerMgr->getGroupInfoList(groupInfoList);
} }
bool p3Peers::assignPeerToGroup(const std::string &groupId, const std::string &peerId, bool assign) bool p3Peers::assignPeerToGroup(const std::string &groupId, const PGPIdType& peerId, bool assign)
{ {
std::list<std::string> peerIds; std::list<PGPIdType> peerIds;
peerIds.push_back(peerId); peerIds.push_back(peerId);
return assignPeersToGroup(groupId, peerIds, assign); return assignPeersToGroup(groupId, peerIds, assign);
} }
bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign) bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<PGPIdType> &peerIds, bool assign)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::assignPeersToGroup()" << std::endl; std::cerr << "p3Peers::assignPeersToGroup()" << std::endl;
@ -1275,7 +1215,7 @@ bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<std
return res ; return res ;
} }
FileSearchFlags p3Peers::computePeerPermissionFlags(const std::string& peer_ssl_id, FileSearchFlags p3Peers::computePeerPermissionFlags(const RsPeerId& peer_ssl_id,
FileStorageFlags share_flags, FileStorageFlags share_flags,
const std::list<std::string>& directory_parent_groups) const std::list<std::string>& directory_parent_groups)
{ {
@ -1286,7 +1226,7 @@ FileSearchFlags p3Peers::computePeerPermissionFlags(const std::string& peer_ssl_
// //
bool found = false ; bool found = false ;
std::string pgp_id = getGPGId(peer_ssl_id) ; PGPIdType pgp_id = getGPGId(peer_ssl_id) ;
for(std::list<std::string>::const_iterator it(directory_parent_groups.begin());it!=directory_parent_groups.end() && !found;++it) for(std::list<std::string>::const_iterator it(directory_parent_groups.begin());it!=directory_parent_groups.end() && !found;++it)
{ {
@ -1297,7 +1237,7 @@ FileSearchFlags p3Peers::computePeerPermissionFlags(const std::string& peer_ssl_
continue ; continue ;
} }
for(std::list<std::string>::const_iterator it2(info.peerIds.begin());it2!=info.peerIds.end() && !found;++it2) for(std::list<PGPIdType>::const_iterator it2(info.peerIds.begin());it2!=info.peerIds.end() && !found;++it2)
if(*it2 == pgp_id) if(*it2 == pgp_id)
found = true ; found = true ;
} }
@ -1343,7 +1283,7 @@ std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail)
out << " signers:"; out << " signers:";
out << std::endl; out << std::endl;
std::list<std::string>::const_iterator it; std::list<PGPIdType>::const_iterator it;
for(it = detail.gpgSigners.begin(); for(it = detail.gpgSigners.begin();
it != detail.gpgSigners.end(); it++) it != detail.gpgSigners.end(); it++)
{ {
@ -1380,15 +1320,15 @@ RsGroupInfo::RsGroupInfo()
flag = 0; flag = 0;
} }
ServicePermissionFlags p3Peers::servicePermissionFlags_sslid(const std::string& ssl_id) ServicePermissionFlags p3Peers::servicePermissionFlags(const RsPeerId& ssl_id)
{ {
return mPeerMgr->servicePermissionFlags_sslid(ssl_id) ; return mPeerMgr->servicePermissionFlags(ssl_id) ;
} }
ServicePermissionFlags p3Peers::servicePermissionFlags(const std::string& gpg_id) ServicePermissionFlags p3Peers::servicePermissionFlags(const PGPIdType& gpg_id)
{ {
return mPeerMgr->servicePermissionFlags(gpg_id) ; return mPeerMgr->servicePermissionFlags(gpg_id) ;
} }
void p3Peers::setServicePermissionFlags(const std::string& gpg_id,const ServicePermissionFlags& flags) void p3Peers::setServicePermissionFlags(const PGPIdType& gpg_id,const ServicePermissionFlags& flags)
{ {
mPeerMgr->setServicePermissionFlags(gpg_id,flags) ; mPeerMgr->setServicePermissionFlags(gpg_id,flags) ;
} }

View file

@ -62,7 +62,7 @@ virtual std::string getPeerName(const RsPeerId& ssl_or_gpg_id);
virtual bool getPeerDetails(const RsPeerId& ssl_or_gpg_id, RsPeerDetails &d); virtual bool getPeerDetails(const RsPeerId& ssl_or_gpg_id, RsPeerDetails &d);
/* Using PGP Ids */ /* Using PGP Ids */
virtual PGPIdType getGPGOwnId(); virtual const PGPIdType& getGPGOwnId();
virtual PGPIdType getGPGId(const RsPeerId &ssl_id); virtual PGPIdType getGPGId(const RsPeerId &ssl_id);
virtual bool isKeySupported(const PGPIdType& ids); virtual bool isKeySupported(const PGPIdType& ids);
virtual bool getGPGAcceptedList(std::list<PGPIdType> &ids); virtual bool getGPGAcceptedList(std::list<PGPIdType> &ids);
@ -75,8 +75,9 @@ virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char
/* Add/Remove Friends */ /* Add/Remove Friends */
virtual bool addFriend(const RsPeerId &ssl_id, const PGPIdType &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL); virtual bool addFriend(const RsPeerId &ssl_id, const PGPIdType &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL);
virtual bool removeFriend(const RsPeerId &ssl_or_gpgid); virtual bool removeFriend(const PGPIdType& gpgid);
virtual bool removeFriendLocation(const RsPeerId &sslId); virtual bool removeFriend(const RsPeerId& sslid);
virtual bool removeFriendLocation(const RsPeerId& sslId);
/* keyring management */ /* keyring management */
virtual bool removeKeysFromPGPKeyring(const std::list<PGPIdType>& pgp_ids,std::string& backup_file,uint32_t& error_code); virtual bool removeKeysFromPGPKeyring(const std::list<PGPIdType>& pgp_ids,std::string& backup_file,uint32_t& error_code);
@ -125,16 +126,16 @@ virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
virtual bool removeGroup(const std::string &groupId); virtual bool removeGroup(const std::string &groupId);
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo); virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList); virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
virtual bool assignPeerToGroup(const PGPIdType &groupId, const PGPIdType &peerId, bool assign); virtual bool assignPeerToGroup(const std::string &groupId, const PGPIdType &peerId, bool assign);
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign); virtual bool assignPeersToGroup(const std::string &groupId, const std::list<PGPIdType>& peerIds, bool assign);
virtual FileSearchFlags computePeerPermissionFlags(const std::string& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups) ; virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups) ;
// service permission stuff // service permission stuff
virtual ServicePermissionFlags servicePermissionFlags(const std::string& gpg_id) ; virtual ServicePermissionFlags servicePermissionFlags(const PGPIdType& gpg_id) ;
virtual ServicePermissionFlags servicePermissionFlags_sslid(const std::string& ssl_id) ; virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id) ;
virtual void setServicePermissionFlags(const std::string& gpg_id,const ServicePermissionFlags& flags) ; virtual void setServicePermissionFlags(const PGPIdType& gpg_id,const ServicePermissionFlags& flags) ;
private: private:

View file

@ -101,14 +101,6 @@ bool RsAccountsDetail::lockPreferredAccount()
bool RsAccountsDetail::selectAccountByString(const std::string &prefUserString) bool RsAccountsDetail::selectAccountByString(const std::string &prefUserString)
{ {
std::string lower_case_user_string;
stringToLowerCase(prefUserString, lower_case_user_string) ;
std::string upper_case_user_string;
stringToUpperCase(prefUserString, upper_case_user_string) ;
std::cerr << "RsAccountsDetail::selectAccountByString(" << prefUserString << ")";
std::cerr << std::endl;
if (mAccountsLocked) if (mAccountsLocked)
{ {
std::cerr << "RsAccountsDetail::selectAccountByString() ERROR Accounts Locked"; std::cerr << "RsAccountsDetail::selectAccountByString() ERROR Accounts Locked";
@ -116,18 +108,22 @@ bool RsAccountsDetail::selectAccountByString(const std::string &prefUserString)
return false; return false;
} }
// try both.
//
RsPeerId ssl_id(prefUserString) ;
PGPIdType pgp_id(prefUserString) ;
std::cerr << "RsAccountsDetail::selectAccountByString(" << prefUserString << ")" << std::endl;
bool pgpNameFound = false; bool pgpNameFound = false;
std::map<std::string, AccountDetails>::const_iterator it; std::map<RsPeerId, AccountDetails>::const_iterator it;
for(it = mAccounts.begin() ; it!= mAccounts.end() ; it++) for(it = mAccounts.begin() ; it!= mAccounts.end() ; it++)
{ {
std::cerr << "\tChecking account (pgpid = " << it->second.mPgpId; std::cerr << "\tChecking account (pgpid = " << it->second.mPgpId;
std::cerr << ", name=" << it->second.mPgpName << ", sslId="; std::cerr << ", name=" << it->second.mPgpName << ", sslId=";
std::cerr << it->second.mSslId << ")" << std::endl; std::cerr << it->second.mSslId << ")" << std::endl;
if(prefUserString == it->second.mPgpName || if(prefUserString == it->second.mPgpName || pgp_id == it->second.mPgpId || ssl_id == it->second.mSslId)
upper_case_user_string == it->second.mPgpId ||
lower_case_user_string == it->second.mSslId)
{ {
mPreferredId = it->second.mSslId; mPreferredId = it->second.mSslId;
pgpNameFound = true; pgpNameFound = true;
@ -137,7 +133,7 @@ bool RsAccountsDetail::selectAccountByString(const std::string &prefUserString)
} }
bool RsAccountsDetail::selectId(const std::string preferredId) bool RsAccountsDetail::selectId(const RsPeerId& preferredId)
{ {
if (mAccountsLocked) if (mAccountsLocked)
@ -147,7 +143,7 @@ bool RsAccountsDetail::selectId(const std::string preferredId)
return false; return false;
} }
std::map<std::string, AccountDetails>::const_iterator it; std::map<RsPeerId, AccountDetails>::const_iterator it;
it = mAccounts.find(preferredId); it = mAccounts.find(preferredId);
if (it != mAccounts.end()) if (it != mAccounts.end())
@ -164,7 +160,7 @@ bool RsAccountsDetail::selectId(const std::string preferredId)
bool RsAccountsDetail::checkPreferredId() bool RsAccountsDetail::checkPreferredId()
{ {
std::map<std::string, AccountDetails>::const_iterator it; std::map<RsPeerId, AccountDetails>::const_iterator it;
it = mAccounts.find(mPreferredId); it = mAccounts.find(mPreferredId);
if (it != mAccounts.end()) if (it != mAccounts.end())
@ -173,7 +169,7 @@ bool RsAccountsDetail::checkPreferredId()
} }
else else
{ {
mPreferredId = ""; mPreferredId.clear();
return false; return false;
} }
} }
@ -208,7 +204,7 @@ std::string RsAccountsDetail::PathAccountDirectory()
{ {
std::string path; std::string path;
std::map<std::string, AccountDetails>::const_iterator it; std::map<RsPeerId, AccountDetails>::const_iterator it;
it = mAccounts.find(mPreferredId); it = mAccounts.find(mPreferredId);
if (it == mAccounts.end()) if (it == mAccounts.end())
{ {
@ -371,7 +367,10 @@ bool RsAccountsDetail::loadPreferredAccount()
path[i] = '\0'; path[i] = '\0';
// Store PreferredId. // Store PreferredId.
mPreferredId = path; mPreferredId = RsPeerId(std::string(path));
if(mPreferredId.isNull())
return false ;
} }
fclose(ifd); fclose(ifd);
return true; return true;
@ -390,7 +389,7 @@ bool RsAccountsDetail::storePreferredAccount()
if (ifd != NULL) if (ifd != NULL)
{ {
fprintf(ifd, "%s\n", mPreferredId.c_str()); fprintf(ifd, "%s\n", mPreferredId.toStdString().c_str());
fclose(ifd); fclose(ifd);
std::cerr << "Creating Init File: " << initfile << std::endl; std::cerr << "Creating Init File: " << initfile << std::endl;
@ -408,15 +407,15 @@ bool RsAccountsDetail::storePreferredAccount()
* *
*/ */
bool RsAccountsDetail::getPreferredAccountId(std::string &id) bool RsAccountsDetail::getPreferredAccountId(RsPeerId &id)
{ {
id = mPreferredId; id = mPreferredId;
return (mPreferredId != ""); return (!mPreferredId.isNull());
} }
bool RsAccountsDetail::getAccountIds(std::list<std::string> &ids) bool RsAccountsDetail::getAccountIds(std::list<RsPeerId> &ids)
{ {
std::map<std::string, AccountDetails>::iterator it; std::map<RsPeerId, AccountDetails>::iterator it;
std::cerr << "getAccountIds:" << std::endl; std::cerr << "getAccountIds:" << std::endl;
for(it = mAccounts.begin(); it != mAccounts.end(); it++) for(it = mAccounts.begin(); it != mAccounts.end(); it++)
@ -433,11 +432,11 @@ bool RsAccountsDetail::getAccountIds(std::list<std::string> &ids)
} }
bool RsAccountsDetail::getAccountDetails(const std::string &id, bool RsAccountsDetail::getAccountDetails(const RsPeerId &id,
std::string &gpgId, std::string &gpgName, PGPIdType &gpgId, std::string &gpgName,
std::string &gpgEmail, std::string &location) std::string &gpgEmail, std::string &location)
{ {
std::map<std::string, AccountDetails>::iterator it; std::map<RsPeerId, AccountDetails>::iterator it;
it = mAccounts.find(id); it = mAccounts.find(id);
if (it != mAccounts.end()) if (it != mAccounts.end())
{ {
@ -452,7 +451,7 @@ bool RsAccountsDetail::getAccountDetails(const std::string &id,
bool RsAccountsDetail::getAccountOptions(bool &ishidden, bool isFirstTimeRun) bool RsAccountsDetail::getAccountOptions(bool &ishidden, bool isFirstTimeRun)
{ {
std::map<std::string, AccountDetails>::iterator it; std::map<RsPeerId, AccountDetails>::iterator it;
it = mAccounts.find(mPreferredId); it = mAccounts.find(mPreferredId);
if (it != mAccounts.end()) if (it != mAccounts.end())
{ {
@ -465,7 +464,7 @@ bool RsAccountsDetail::getAccountOptions(bool &ishidden, bool isFirstTimeRun)
/* directories with valid certificates in the expected location */ /* directories with valid certificates in the expected location */
bool RsAccountsDetail::getAvailableAccounts(std::map<std::string, AccountDetails> &accounts,int& failing_accounts,std::map<std::string,std::vector<std::string> >& unsupported_keys) bool RsAccountsDetail::getAvailableAccounts(std::map<RsPeerId, AccountDetails> &accounts,int& failing_accounts,std::map<std::string,std::vector<std::string> >& unsupported_keys)
{ {
failing_accounts = 0 ; failing_accounts = 0 ;
/* get the directories */ /* get the directories */
@ -584,7 +583,7 @@ bool RsAccountsDetail::getAvailableAccounts(std::map<std::string, AccountDetails
std::cerr << "getAvailableAccounts() Accepted: " << *it << std::endl; std::cerr << "getAvailableAccounts() Accepted: " << *it << std::endl;
#endif #endif
std::map<std::string, AccountDetails>::iterator ait; std::map<RsPeerId, AccountDetails>::iterator ait;
ait = accounts.find(tmpId.mSslId); ait = accounts.find(tmpId.mSslId);
if (ait != accounts.end()) if (ait != accounts.end())
{ {
@ -623,7 +622,7 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma
basename += "user"; basename += "user";
std::string cert_name = basename + "_cert.pem"; std::string cert_name = basename + "_cert.pem";
std::string userName, userId; std::string userName;
#ifdef AUTHSSL_DEBUG #ifdef AUTHSSL_DEBUG
std::cerr << "checkAccount() dir: " << accountdir << std::endl; std::cerr << "checkAccount() dir: " << accountdir << std::endl;
@ -646,8 +645,8 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma
if(!AuthGPG::getAuthGPG()->isKeySupported(account.mPgpId)) if(!AuthGPG::getAuthGPG()->isKeySupported(account.mPgpId))
{ {
std::string keystring = account.mPgpId + " " + account.mPgpName + "&#60;" + account.mPgpEmail ; std::string keystring = account.mPgpId.toStdString() + " " + account.mPgpName + "&#60;" + account.mPgpEmail ;
unsupported_keys[keystring].push_back("Location: " + account.mLocation + "&nbsp;&nbsp;(" + account.mSslId + ")") ; unsupported_keys[keystring].push_back("Location: " + account.mLocation + "&nbsp;&nbsp;(" + account.mSslId.toStdString() + ")") ;
return false ; return false ;
} }
@ -788,12 +787,12 @@ std::string RsAccountsDetail::PathDataDirectory()
/* Generating GPGme Account */ /* Generating GPGme Account */
int RsAccountsDetail::GetPGPLogins(std::list<std::string> &pgpIds) { int RsAccountsDetail::GetPGPLogins(std::list<PGPIdType> &pgpIds) {
AuthGPG::getAuthGPG()->availableGPGCertificatesWithPrivateKeys(pgpIds); AuthGPG::getAuthGPG()->availableGPGCertificatesWithPrivateKeys(pgpIds);
return 1; return 1;
} }
int RsAccountsDetail::GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email) int RsAccountsDetail::GetPGPLoginDetails(const PGPIdType& id, std::string &name, std::string &email)
{ {
#ifdef GPG_DEBUG #ifdef GPG_DEBUG
std::cerr << "RsInit::GetPGPLoginDetails for \"" << id << "\"" << std::endl; std::cerr << "RsInit::GetPGPLoginDetails for \"" << id << "\"" << std::endl;
@ -819,7 +818,7 @@ int RsAccountsDetail::GetPGPLoginDetails(const std::string& id, std::string
/* Before any SSL stuff can be loaded, the correct PGP must be selected / generated: /* Before any SSL stuff can be loaded, the correct PGP must be selected / generated:
**/ **/
bool RsAccountsDetail::SelectPGPAccount(const std::string& pgpId) bool RsAccountsDetail::SelectPGPAccount(const PGPIdType& pgpId)
{ {
bool retVal = false; bool retVal = false;
@ -837,7 +836,7 @@ bool RsAccountsDetail::SelectPGPAccount(const std::string& pgpId)
} }
bool RsAccountsDetail::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString) bool RsAccountsDetail::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, PGPIdType &pgpId, std::string &errString)
{ {
return AuthGPG::getAuthGPG()->GeneratePGPCertificate(name, email, passwd, pgpId, errString); return AuthGPG::getAuthGPG()->GeneratePGPCertificate(name, email, passwd, pgpId, errString);
} }
@ -849,12 +848,12 @@ void RsAccountsDetail::getUnsupportedKeys(std::map<std::string,std::vector<std::
return; return;
} }
bool RsAccountsDetail::exportIdentity(const std::string& fname,const std::string& id) bool RsAccountsDetail::exportIdentity(const std::string& fname,const PGPIdType& id)
{ {
return AuthGPG::getAuthGPG()->exportProfile(fname,id); return AuthGPG::getAuthGPG()->exportProfile(fname,id);
} }
bool RsAccountsDetail::importIdentity(const std::string& fname,std::string& id,std::string& import_error) bool RsAccountsDetail::importIdentity(const std::string& fname,PGPIdType& id,std::string& import_error)
{ {
return AuthGPG::getAuthGPG()->importProfile(fname,id,import_error); return AuthGPG::getAuthGPG()->importProfile(fname,id,import_error);
} }
@ -917,7 +916,7 @@ bool RsAccountsDetail::copyGnuPGKeyrings()
/* Create SSL Certificates */ /* Create SSL Certificates */
bool RsAccountsDetail::GenerateSSLCertificate(const std::string& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, std::string &sslId, std::string &errString) bool RsAccountsDetail::GenerateSSLCertificate(const PGPIdType& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
{ {
/* select the PGP Identity first */ /* select the PGP Identity first */
if (!SelectPGPAccount(pgp_id)) if (!SelectPGPAccount(pgp_id))
@ -1045,7 +1044,8 @@ bool RsAccountsDetail::GenerateSSLCertificate(const std::string& pgp_id, con
/* try to load it, and get Id */ /* try to load it, and get Id */
std::string location; std::string location;
std::string pgpid_retrieved; PGPIdType pgpid_retrieved;
if (LoadCheckX509(cert_name.c_str(), pgpid_retrieved, location, sslId) == 0) { if (LoadCheckX509(cert_name.c_str(), pgpid_retrieved, location, sslId) == 0) {
std::cerr << "RsInit::GenerateSSLCertificate() Cannot check own signature, maybe the files are corrupted." << std::endl; std::cerr << "RsInit::GenerateSSLCertificate() Cannot check own signature, maybe the files are corrupted." << std::endl;
return false; return false;
@ -1054,13 +1054,9 @@ bool RsAccountsDetail::GenerateSSLCertificate(const std::string& pgp_id, con
/* Move directory to correct id */ /* Move directory to correct id */
std::string accountdir; std::string accountdir;
if (ishiddenloc) if (ishiddenloc)
{ accountdir = "HID06_" + sslId.toStdString();
accountdir = "HID06_" + sslId;
}
else else
{ accountdir = "LOC06_" + sslId.toStdString();
accountdir = "LOC06_" + sslId;
}
std::string fullAccountDir = mBaseDirectory + "/" + accountdir; std::string fullAccountDir = mBaseDirectory + "/" + accountdir;
std::string finalbase = fullAccountDir + "/"; std::string finalbase = fullAccountDir + "/";
@ -1245,28 +1241,28 @@ std::string RsAccounts::PGPDirectory() { return rsAccounts.PathPGPDirectory(); }
std::string RsAccounts::AccountDirectory() { return rsAccounts.PathAccountDirectory(); } std::string RsAccounts::AccountDirectory() { return rsAccounts.PathAccountDirectory(); }
// PGP Accounts. // PGP Accounts.
int RsAccounts::GetPGPLogins(std::list<std::string> &pgpIds) int RsAccounts::GetPGPLogins(std::list<PGPIdType> &pgpIds)
{ {
return rsAccounts.GetPGPLogins(pgpIds); return rsAccounts.GetPGPLogins(pgpIds);
} }
int RsAccounts::GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email) int RsAccounts::GetPGPLoginDetails(const PGPIdType& id, std::string &name, std::string &email)
{ {
return rsAccounts.GetPGPLoginDetails(id, name, email); return rsAccounts.GetPGPLoginDetails(id, name, email);
} }
bool RsAccounts::GeneratePGPCertificate(const std::string &name, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString) bool RsAccounts::GeneratePGPCertificate(const std::string &name, const std::string& email, const std::string& passwd, PGPIdType &pgpId, std::string &errString)
{ {
return rsAccounts.GeneratePGPCertificate(name, email, passwd, pgpId, errString); return rsAccounts.GeneratePGPCertificate(name, email, passwd, pgpId, errString);
} }
// PGP Support Functions. // PGP Support Functions.
bool RsAccounts::ExportIdentity(const std::string& fname,const std::string& pgp_id) bool RsAccounts::ExportIdentity(const std::string& fname,const PGPIdType& pgp_id)
{ {
return rsAccounts.exportIdentity(fname,pgp_id); return rsAccounts.exportIdentity(fname,pgp_id);
} }
bool RsAccounts::ImportIdentity(const std::string& fname,std::string& imported_pgp_id,std::string& import_error) bool RsAccounts::ImportIdentity(const std::string& fname,PGPIdType& imported_pgp_id,std::string& import_error)
{ {
return rsAccounts.importIdentity(fname,imported_pgp_id,import_error); return rsAccounts.importIdentity(fname,imported_pgp_id,import_error);
} }
@ -1282,29 +1278,29 @@ bool RsAccounts::CopyGnuPGKeyrings()
} }
// Rs Accounts // Rs Accounts
bool RsAccounts::SelectAccount(const std::string &id) bool RsAccounts::SelectAccount(const RsPeerId &id)
{ {
return rsAccounts.selectId(id); return rsAccounts.selectId(id);
} }
bool RsAccounts::GetPreferredAccountId(std::string &id) bool RsAccounts::GetPreferredAccountId(RsPeerId &id)
{ {
return rsAccounts.getPreferredAccountId(id); return rsAccounts.getPreferredAccountId(id);
} }
bool RsAccounts::GetAccountIds(std::list<std::string> &ids) bool RsAccounts::GetAccountIds(std::list<RsPeerId> &ids)
{ {
return rsAccounts.getAccountIds(ids); return rsAccounts.getAccountIds(ids);
} }
bool RsAccounts::GetAccountDetails(const std::string &id, bool RsAccounts::GetAccountDetails(const RsPeerId &id,
std::string &pgpId, std::string &pgpName, PGPIdType &pgpId, std::string &pgpName,
std::string &pgpEmail, std::string &location) std::string &pgpEmail, std::string &location)
{ {
return rsAccounts.getAccountDetails(id, pgpId, pgpName, pgpEmail, location); return rsAccounts.getAccountDetails(id, pgpId, pgpName, pgpEmail, location);
} }
bool RsAccounts::GenerateSSLCertificate(const std::string& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, std::string &sslId, std::string &errString) bool RsAccounts::GenerateSSLCertificate(const PGPIdType& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
{ {
return rsAccounts.GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, passwd, sslId, errString); return rsAccounts.GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, passwd, sslId, errString);
} }

View file

@ -36,16 +36,17 @@
#include <string> #include <string>
#include <list> #include <list>
#include <map> #include <map>
#include "retroshare/rstypes.h"
class AccountDetails class AccountDetails
{ {
public: public:
AccountDetails(); AccountDetails();
std::string mSslId; RsPeerId mSslId;
std::string mAccountDir; std::string mAccountDir;
std::string mPgpId; PGPIdType mPgpId;
std::string mPgpName; std::string mPgpName;
std::string mPgpEmail; std::string mPgpEmail;
@ -85,38 +86,36 @@ class RsAccountsDetail
// PGP Accounts. // PGP Accounts.
int GetPGPLogins(std::list<std::string> &pgpIds); int GetPGPLogins(std::list<PGPIdType> &pgpIds);
int GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email); int GetPGPLoginDetails(const PGPIdType& id, std::string &name, std::string &email);
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString); bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, PGPIdType &pgpId, std::string &errString);
bool SelectPGPAccount(const std::string& pgpId); bool SelectPGPAccount(const PGPIdType& pgpId);
// PGP Support Functions. // PGP Support Functions.
bool exportIdentity(const std::string& fname,const std::string& pgp_id) ; bool exportIdentity(const std::string& fname,const PGPIdType& pgp_id) ;
bool importIdentity(const std::string& fname,std::string& imported_pgp_id,std::string& import_error) ; bool importIdentity(const std::string& fname,PGPIdType& imported_pgp_id,std::string& import_error) ;
void getUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys); void getUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
bool copyGnuPGKeyrings() ; bool copyGnuPGKeyrings() ;
// Selecting Rs Account. // Selecting Rs Account.
bool selectAccountByString(const std::string &prefUserString); bool selectAccountByString(const std::string &prefUserString);
bool selectId(const std::string preferredId); bool selectId(const RsPeerId& preferredId);
// Details of Rs Account. // Details of Rs Account.
bool getPreferredAccountId(std::string &id); bool getPreferredAccountId(RsPeerId &id);
bool getAccountDetails(const std::string &id, bool getAccountDetails(const RsPeerId &id, PGPIdType& gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location);
std::string &gpgId, std::string &gpgName,
std::string &gpgEmail, std::string &location);
bool getAccountOptions(bool &ishidden, bool isFirstTimeRun); bool getAccountOptions(bool &ishidden, bool isFirstTimeRun);
bool getAccountIds(std::list<std::string> &ids); bool getAccountIds(std::list<RsPeerId> &ids);
bool GenerateSSLCertificate(const std::string& gpg_id, bool GenerateSSLCertificate(const PGPIdType& gpg_id,
const std::string& org, const std::string& loc, const std::string& org, const std::string& loc,
const std::string& country, const bool ishiddenloc, const std::string& country, const bool ishiddenloc,
const std::string& passwd, std::string &sslId, const std::string& passwd, RsPeerId &sslId,
std::string &errString); std::string &errString);
// From init file. // From init file.
@ -130,7 +129,7 @@ class RsAccountsDetail
std::string getHomePath() ; std::string getHomePath() ;
bool getAvailableAccounts(std::map<std::string, AccountDetails> &accounts, bool getAvailableAccounts(std::map<RsPeerId, AccountDetails> &accounts,
int& failing_accounts, int& failing_accounts,
std::map<std::string,std::vector<std::string> >& unsupported_keys); std::map<std::string,std::vector<std::string> >& unsupported_keys);
@ -140,8 +139,8 @@ class RsAccountsDetail
bool mAccountsLocked; bool mAccountsLocked;
std::map<std::string, AccountDetails> mAccounts; std::map<RsPeerId, AccountDetails> mAccounts;
std::string mPreferredId; RsPeerId mPreferredId;
std::string mBaseDirectory; std::string mBaseDirectory;
std::map<std::string,std::vector<std::string> > mUnsupportedKeys ; std::map<std::string,std::vector<std::string> > mUnsupportedKeys ;

View file

@ -566,7 +566,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
} }
/* check that we have selected someone */ /* check that we have selected someone */
std::string preferredId; RsPeerId preferredId;
bool existingUser = rsAccounts.getPreferredAccountId(preferredId); bool existingUser = rsAccounts.getPreferredAccountId(preferredId);
if (existingUser) if (existingUser)
@ -652,22 +652,20 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath
} }
// Logic that used to be external to RsInit... // Logic that used to be external to RsInit...
std::string accountId; RsPeerId accountId;
if (!rsAccounts.getPreferredAccountId(accountId)) if (!rsAccounts.getPreferredAccountId(accountId))
{ {
return 3; // invalid PreferredAccount; return 3; // invalid PreferredAccount;
} }
std::string pgpId, pgpName, pgpEmail, location; PGPIdType pgpId;
std::string pgpName, pgpEmail, location;
if (!rsAccounts.getAccountDetails(accountId, pgpId, pgpName, pgpEmail, location)) if (!rsAccounts.getAccountDetails(accountId, pgpId, pgpName, pgpEmail, location))
{
return 3; // invalid PreferredAccount; return 3; // invalid PreferredAccount;
}
if (!rsAccounts.SelectPGPAccount(pgpId)) if (!rsAccounts.SelectPGPAccount(pgpId))
{
return 3; // PGP Error. return 3; // PGP Error.
}
int retVal = LockConfigDirectory(rsAccounts.PathAccountDirectory(), lockFilePath); int retVal = LockConfigDirectory(rsAccounts.PathAccountDirectory(), lockFilePath);
if(retVal != 0) if(retVal != 0)
@ -694,7 +692,7 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath
*/ */
int RsInit::LoadCertificates(bool autoLoginNT) int RsInit::LoadCertificates(bool autoLoginNT)
{ {
std::string preferredId; RsPeerId preferredId;
if (!rsAccounts.getPreferredAccountId(preferredId)) if (!rsAccounts.getPreferredAccountId(preferredId))
{ {
std::cerr << "No Account Selected" << std::endl; std::cerr << "No Account Selected" << std::endl;
@ -758,7 +756,7 @@ int RsInit::LoadCertificates(bool autoLoginNT)
bool RsInit::RsClearAutoLogin() bool RsInit::RsClearAutoLogin()
{ {
std::string preferredId; RsPeerId preferredId;
if (!rsAccounts.getPreferredAccountId(preferredId)) if (!rsAccounts.getPreferredAccountId(preferredId))
{ {
std::cerr << "RsInit::RsClearAutoLogin() No Account Selected" << std::endl; std::cerr << "RsInit::RsClearAutoLogin() No Account Selected" << std::endl;
@ -982,7 +980,7 @@ int RsServer::StartupRetroShare()
return false ; return false ;
} }
std::string ownId = AuthSSL::getAuthSSL()->OwnId(); RsPeerId ownId = AuthSSL::getAuthSSL()->OwnId();
/**************************************************************************/ /**************************************************************************/
/* Any Initial Configuration (Commandline Options) */ /* Any Initial Configuration (Commandline Options) */
@ -1360,7 +1358,7 @@ int RsServer::StartupRetroShare()
// empty and matches an exist directory location // empty and matches an exist directory location
// the given ssl user id then this directory is cleaned // the given ssl user id then this directory is cleaned
// and deleted // and deleted
std::string priorGxsDir = "./" + mLinkMgr->getOwnId() + "/"; std::string priorGxsDir = "./" + mLinkMgr->getOwnId().toStdString() + "/";
std::string currGxsDir = rsAccounts.PathAccountDirectory() + "/GXS_phase2"; std::string currGxsDir = rsAccounts.PathAccountDirectory() + "/GXS_phase2";
#ifdef GXS_DEV_TESTNET // Different Directory for testing. #ifdef GXS_DEV_TESTNET // Different Directory for testing.

View file

@ -97,7 +97,7 @@ extern BOOL WINAPI CryptUnprotectData(
#endif #endif
bool RsLoginHandler::getSSLPassword(const std::string& ssl_id,bool enable_gpg_ask_passwd,std::string& ssl_passwd) bool RsLoginHandler::getSSLPassword(const RsPeerId& ssl_id,bool enable_gpg_ask_passwd,std::string& ssl_passwd)
{ {
// First, see if autologin is available // First, see if autologin is available
// //
@ -113,7 +113,7 @@ bool RsLoginHandler::getSSLPassword(const std::string& ssl_id,bool enable_gpg_as
return getSSLPasswdFromGPGFile(ssl_id,ssl_passwd) ; return getSSLPasswdFromGPGFile(ssl_id,ssl_passwd) ;
} }
bool RsLoginHandler::tryAutoLogin(const std::string& ssl_id,std::string& ssl_passwd) bool RsLoginHandler::tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd)
{ {
std::cerr << "RsTryAutoLogin()" << std::endl; std::cerr << "RsTryAutoLogin()" << std::endl;
@ -124,7 +124,7 @@ bool RsLoginHandler::tryAutoLogin(const std::string& ssl_id,std::string& ssl_pas
gchar *passwd = NULL; gchar *passwd = NULL;
std::cerr << "Using attribute: " << ssl_id << std::endl; std::cerr << "Using attribute: " << ssl_id << std::endl;
if( gnome_keyring_find_password_sync(&my_schema, &passwd,"RetroShare SSL Id",ssl_id.c_str(),NULL) == GNOME_KEYRING_RESULT_OK ) if( gnome_keyring_find_password_sync(&my_schema, &passwd,"RetroShare SSL Id",ssl_id.toStdString().c_str(),NULL) == GNOME_KEYRING_RESULT_OK )
{ {
std::cerr << "Got SSL passwd ********************" /*<< passwd*/ << " from gnome keyring" << std::endl; std::cerr << "Got SSL passwd ********************" /*<< passwd*/ << " from gnome keyring" << std::endl;
ssl_passwd = std::string(passwd); ssl_passwd = std::string(passwd);
@ -355,14 +355,14 @@ bool RsLoginHandler::tryAutoLogin(const std::string& ssl_id,std::string& ssl_pas
} }
bool RsLoginHandler::enableAutoLogin(const std::string& ssl_id,const std::string& ssl_passwd) bool RsLoginHandler::enableAutoLogin(const RsPeerId& ssl_id,const std::string& ssl_passwd)
{ {
std::cerr << "RsStoreAutoLogin()" << std::endl; std::cerr << "RsStoreAutoLogin()" << std::endl;
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ /******************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS /* UNIX */ #ifndef WINDOWS_SYS /* UNIX */
#if defined(UBUNTU) || defined(__FreeBSD__) || defined(__OpenBSD__) #if defined(UBUNTU) || defined(__FreeBSD__) || defined(__OpenBSD__)
if(GNOME_KEYRING_RESULT_OK == gnome_keyring_store_password_sync(&my_schema, NULL, (gchar*)("RetroShare password for SSL Id "+ssl_id).c_str(),(gchar*)ssl_passwd.c_str(),"RetroShare SSL Id",ssl_id.c_str(),NULL)) if(GNOME_KEYRING_RESULT_OK == gnome_keyring_store_password_sync(&my_schema, NULL, (gchar*)("RetroShare password for SSL Id "+ssl_id.toStdString()).c_str(),(gchar*)ssl_passwd.c_str(),"RetroShare SSL Id",ssl_id.toStdString().c_str(),NULL))
{ {
std::cerr << "Stored passwd " << "************************" << " into gnome keyring" << std::endl; std::cerr << "Stored passwd " << "************************" << " into gnome keyring" << std::endl;
return true ; return true ;
@ -519,10 +519,10 @@ bool RsLoginHandler::enableAutoLogin(const std::string& ssl_id,const std::string
return false; return false;
} }
bool RsLoginHandler::clearAutoLogin(const std::string& ssl_id) bool RsLoginHandler::clearAutoLogin(const RsPeerId& ssl_id)
{ {
#ifdef UBUNTU #ifdef UBUNTU
if(GNOME_KEYRING_RESULT_OK == gnome_keyring_delete_password_sync(&my_schema,"RetroShare SSL Id", ssl_id.c_str(),NULL)) if(GNOME_KEYRING_RESULT_OK == gnome_keyring_delete_password_sync(&my_schema,"RetroShare SSL Id", ssl_id.toStdString().c_str(),NULL))
{ {
std::cerr << "Successfully Cleared gnome keyring passwd for SSLID " << ssl_id << std::endl; std::cerr << "Successfully Cleared gnome keyring passwd for SSLID " << ssl_id << std::endl;
return true ; return true ;
@ -621,7 +621,7 @@ bool RsLoginHandler::clearAutoLogin(const std::string& ssl_id)
#endif #endif
} }
bool RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(const std::string& ssl_id,const std::string& ssl_passwd) bool RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(const RsPeerId& ssl_id,const std::string& ssl_passwd)
{ {
// We want to pursue login with gpg passwd. Let's do it: // We want to pursue login with gpg passwd. Let's do it:
// //
@ -652,7 +652,7 @@ bool RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(const std::string& ssl_id
return ok ; return ok ;
} }
bool RsLoginHandler::getSSLPasswdFromGPGFile(const std::string& ssl_id,std::string& sslPassword) bool RsLoginHandler::getSSLPasswdFromGPGFile(const RsPeerId& ssl_id,std::string& sslPassword)
{ {
// Let's read the password from an encrypted file // Let's read the password from an encrypted file
// Let's check if there's a ssl_passpharese_file that we can decrypt with PGP // Let's check if there's a ssl_passpharese_file that we can decrypt with PGP
@ -687,12 +687,12 @@ bool RsLoginHandler::getSSLPasswdFromGPGFile(const std::string& ssl_id,std::stri
} }
std::string RsLoginHandler::getSSLPasswdFileName(const std::string& /*ssl_id*/) std::string RsLoginHandler::getSSLPasswdFileName(const RsPeerId& /*ssl_id*/)
{ {
return rsAccounts.PathAccountKeysDirectory() + "/" + "ssl_passphrase.pgp"; return rsAccounts.PathAccountKeysDirectory() + "/" + "ssl_passphrase.pgp";
} }
std::string RsLoginHandler::getAutologinFileName(const std::string& /*ssl_id*/) std::string RsLoginHandler::getAutologinFileName(const RsPeerId& /*ssl_id*/)
{ {
return rsAccounts.PathAccountKeysDirectory() + "/" + "help.dta" ; return rsAccounts.PathAccountKeysDirectory() + "/" + "help.dta" ;
} }

View file

@ -22,26 +22,26 @@ class RsLoginHandler
public: public:
// Gets the SSL passwd by any means: try autologin, and look into gpg file if enable_gpg_key_callback==true // Gets the SSL passwd by any means: try autologin, and look into gpg file if enable_gpg_key_callback==true
// //
static bool getSSLPassword(const std::string& ssl_id,bool enable_gpg_key_callback,std::string& ssl_password) ; static bool getSSLPassword(const RsPeerId& ssl_id,bool enable_gpg_key_callback,std::string& ssl_password) ;
// Checks whether the ssl passwd is already in the gpg file. If the file's not here, the passwd is stored there, // Checks whether the ssl passwd is already in the gpg file. If the file's not here, the passwd is stored there,
// encrypted with the current GPG key. // encrypted with the current GPG key.
// //
static bool checkAndStoreSSLPasswdIntoGPGFile(const std::string& ssl_id,const std::string& ssl_passwd) ; static bool checkAndStoreSSLPasswdIntoGPGFile(const RsPeerId& ssl_id,const std::string& ssl_passwd) ;
// Stores the given ssl_id/passwd pair into the keyring, or by default into a file in /[ssl_id]/keys/help.dta // Stores the given ssl_id/passwd pair into the keyring, or by default into a file in /[ssl_id]/keys/help.dta
// //
static bool enableAutoLogin(const std::string& ssl_id,const std::string& passwd) ; static bool enableAutoLogin(const RsPeerId& ssl_id,const std::string& passwd) ;
// Clears autologin entry. // Clears autologin entry.
// //
static bool clearAutoLogin(const std::string& ssl_id) ; static bool clearAutoLogin(const RsPeerId& ssl_id) ;
private: private:
static bool tryAutoLogin(const std::string& ssl_id,std::string& ssl_passwd) ; static bool tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd) ;
static bool getSSLPasswdFromGPGFile(const std::string& ssl_id,std::string& sslPassword) ; static bool getSSLPasswdFromGPGFile(const RsPeerId& ssl_id,std::string& sslPassword) ;
static std::string getSSLPasswdFileName(const std::string& ssl_id) ; static std::string getSSLPasswdFileName(const RsPeerId& ssl_id) ;
static std::string getAutologinFileName(const std::string& ssl_id) ; static std::string getAutologinFileName(const RsPeerId& ssl_id) ;
}; };

View file

@ -131,7 +131,7 @@ public:
std::string name; std::string name;
uint32_t flag; uint32_t flag;
std::list<RsPeerId> peerIds; std::list<PGPIdType> peerIds;
}; };

View file

@ -52,7 +52,7 @@ class BanList
{ {
public: public:
std::string mPeerId; /* from */ RsPeerId mPeerId; /* from */
time_t mLastUpdate; time_t mLastUpdate;
std::map<struct sockaddr_storage, BanListPeer> mBanPeers; std::map<struct sockaddr_storage, BanListPeer> mBanPeers;
}; };
@ -74,7 +74,7 @@ class p3BanList: /* public RsBanList, */ public p3Service, public pqiNetAssistPe
/***** overloaded from pqiNetAssistPeerShare *****/ /***** overloaded from pqiNetAssistPeerShare *****/
virtual void updatePeer(std::string id, const struct sockaddr_storage &addr, int type, int reason, int age); virtual void updatePeer(const RsPeerId& id, const struct sockaddr_storage &addr, int type, int reason, int age);
/***** overloaded from p3Service *****/ /***** overloaded from p3Service *****/
@ -93,10 +93,10 @@ class p3BanList: /* public RsBanList, */ public p3Service, public pqiNetAssistPe
bool processIncoming(); bool processIncoming();
bool recvBanItem(RsBanListItem *item); bool recvBanItem(RsBanListItem *item);
bool addBanEntry(const std::string &peerId, const struct sockaddr_storage &addr, bool addBanEntry(const RsPeerId &peerId, const struct sockaddr_storage &addr,
int level, uint32_t reason, uint32_t age); int level, uint32_t reason, uint32_t age);
void sendBanLists(); void sendBanLists();
int sendBanSet(std::string peerid); int sendBanSet(const RsPeerId& peerid);
/*! /*!
@ -122,7 +122,7 @@ class p3BanList: /* public RsBanList, */ public p3Service, public pqiNetAssistPe
int printBanSet_locked(std::ostream &out); int printBanSet_locked(std::ostream &out);
time_t mSentListTime; time_t mSentListTime;
std::map<std::string, BanList> mBanSources; std::map<RsPeerId, BanList> mBanSources;
std::map<struct sockaddr_storage, BanListPeer> mBanSet; std::map<struct sockaddr_storage, BanListPeer> mBanSet;
p3LinkMgr *mLinkMgr; p3LinkMgr *mLinkMgr;

View file

@ -601,16 +601,14 @@ void p3GxsChannels::handleUnprocessedPost(const RsGxsChannelPost &msg)
std::string hash = fit->mHash; std::string hash = fit->mHash;
uint64_t size = fit->mSize; uint64_t size = fit->mSize;
std::list<std::string> srcIds; std::list<RsPeerId> srcIds;
std::string localpath = ""; std::string localpath = "";
TransferRequestFlags flags = RS_FILE_REQ_BACKGROUND | RS_FILE_REQ_ANONYMOUS_ROUTING; TransferRequestFlags flags = RS_FILE_REQ_BACKGROUND | RS_FILE_REQ_ANONYMOUS_ROUTING;
if (size < CHANNEL_MAX_AUTO_DL) if (size < CHANNEL_MAX_AUTO_DL)
{
rsFiles->FileRequest(fname, hash, size, localpath, flags, srcIds); rsFiles->FileRequest(fname, hash, size, localpath, flags, srcIds);
} }
} }
}
/* mark as processed */ /* mark as processed */
uint32_t token; uint32_t token;

View file

@ -1171,7 +1171,7 @@ bool p3GxsCircles::checkCircleCacheForAutoSubscribe(RsGxsCircleCache &cache)
} }
/* if we appear in the group - then autosubscribe, and mark as processed */ /* if we appear in the group - then autosubscribe, and mark as processed */
std::string ownId = AuthGPG::getAuthGPG()->getGPGOwnId(); const RsPgpId& ownId = AuthGPG::getAuthGPG()->getGPGOwnId();
std::map<RsPgpId, std::list<RsGxsId> >::iterator it = cache.mAllowedPeers.find(ownId); std::map<RsPgpId, std::list<RsGxsId> >::iterator it = cache.mAllowedPeers.find(ownId);
if (it != cache.mAllowedPeers.end()) if (it != cache.mAllowedPeers.end())
{ {

View file

@ -62,8 +62,8 @@ int p3heartbeat::tick()
{ {
mLastHeartbeat = time(NULL); mLastHeartbeat = time(NULL);
std::list<std::string> peers; std::list<RsPeerId> peers;
std::list<std::string>::const_iterator pit; std::list<RsPeerId>::const_iterator pit;
mLinkMgr->getOnlineList(peers); mLinkMgr->getOnlineList(peers);
for (pit = peers.begin(); pit != peers.end(); ++pit) for (pit = peers.begin(); pit != peers.end(); ++pit)
@ -97,7 +97,7 @@ int p3heartbeat::tick()
return nhandled ; return nhandled ;
} }
void p3heartbeat::sendHeartbeat(const std::string &toId) void p3heartbeat::sendHeartbeat(const RsPeerId &toId)
{ {
#ifdef HEART_DEBUG #ifdef HEART_DEBUG
@ -110,7 +110,7 @@ void p3heartbeat::sendHeartbeat(const std::string &toId)
} }
void p3heartbeat::recvHeartbeat(const std::string &fromId) void p3heartbeat::recvHeartbeat(const RsPeerId &fromId)
{ {
#ifdef HEART_DEBUG #ifdef HEART_DEBUG

View file

@ -44,8 +44,8 @@ virtual ~p3heartbeat();
private: private:
void sendHeartbeat(const std::string &toId); void sendHeartbeat(const RsPeerId &toId);
void recvHeartbeat(const std::string &fromId); void recvHeartbeat(const RsPeerId &fromId);
private: private:

View file

@ -168,7 +168,7 @@ void p3rtt::sendPingMeasurements()
/* we ping our peers */ /* we ping our peers */
/* who is online? */ /* who is online? */
std::list<std::string> idList; std::list<RsPeerId> idList;
mLinkMgr->getOnlineList(idList); mLinkMgr->getOnlineList(idList);
@ -180,7 +180,7 @@ void p3rtt::sendPingMeasurements()
#endif #endif
/* prepare packets */ /* prepare packets */
std::list<std::string>::iterator it; std::list<RsPeerId>::iterator it;
for(it = idList.begin(); it != idList.end(); it++) for(it = idList.begin(); it != idList.end(); it++)
{ {
#ifdef DEBUG_RTT #ifdef DEBUG_RTT
@ -309,7 +309,7 @@ int p3rtt::handlePong(RsItem *item)
int p3rtt::storePingAttempt(std::string id, double ts, uint32_t seqno) int p3rtt::storePingAttempt(const RsPeerId& id, double ts, uint32_t seqno)
{ {
RsStackMutex stack(mRttMtx); /****** LOCKED MUTEX *******/ RsStackMutex stack(mRttMtx); /****** LOCKED MUTEX *******/
@ -332,7 +332,7 @@ int p3rtt::storePingAttempt(std::string id, double ts, uint32_t seqno)
int p3rtt::storePongResult(std::string id, uint32_t counter, double ts, double rtt, double offset) int p3rtt::storePongResult(const RsPeerId& id, uint32_t counter, double ts, double rtt, double offset)
{ {
RsStackMutex stack(mRttMtx); /****** LOCKED MUTEX *******/ RsStackMutex stack(mRttMtx); /****** LOCKED MUTEX *******/
@ -363,7 +363,7 @@ int p3rtt::storePongResult(std::string id, uint32_t counter, double ts, double r
} }
uint32_t p3rtt::getPongResults(std::string id, int n, std::list<RsRttPongResult> &results) uint32_t p3rtt::getPongResults(const RsPeerId& id, int n, std::list<RsRttPongResult> &results)
{ {
RsStackMutex stack(mRttMtx); /****** LOCKED MUTEX *******/ RsStackMutex stack(mRttMtx); /****** LOCKED MUTEX *******/
@ -381,9 +381,9 @@ uint32_t p3rtt::getPongResults(std::string id, int n, std::list<RsRttPongResult>
RttPeerInfo *p3rtt::locked_GetPeerInfo(std::string id) RttPeerInfo *p3rtt::locked_GetPeerInfo(const RsPeerId& id)
{ {
std::map<std::string, RttPeerInfo>::iterator it; std::map<RsPeerId, RttPeerInfo>::iterator it;
it = mPeerInfo.find(id); it = mPeerInfo.find(id);
if (it == mPeerInfo.end()) if (it == mPeerInfo.end())
{ {
@ -404,7 +404,7 @@ RttPeerInfo *p3rtt::locked_GetPeerInfo(std::string id)
bool RttPeerInfo::initialisePeerInfo(std::string id) bool RttPeerInfo::initialisePeerInfo(const RsPeerId& id)
{ {
mId = id; mId = id;

View file

@ -40,9 +40,9 @@ class RttPeerInfo
{ {
public: public:
bool initialisePeerInfo(std::string id); bool initialisePeerInfo(const RsPeerId& id);
std::string mId; RsPeerId mId;
double mCurrentPingTS; double mCurrentPingTS;
double mCurrentPingCounter; double mCurrentPingCounter;
bool mCurrentPongRecvd; bool mCurrentPongRecvd;
@ -67,7 +67,7 @@ class p3rtt: public RsRtt, public p3FastService
/***** overloaded from rsRtt *****/ /***** overloaded from rsRtt *****/
virtual uint32_t getPongResults(std::string id, int n, std::list<RsRttPongResult> &results); virtual uint32_t getPongResults(const RsPeerId& id, int n, std::list<RsRttPongResult> &results);
/***** overloaded from p3Service *****/ /***** overloaded from p3Service *****/
@ -82,8 +82,8 @@ virtual bool recvItem(RsItem *item); // Overloaded from p3FastService.
int handlePing(RsItem *item); int handlePing(RsItem *item);
int handlePong(RsItem *item); int handlePong(RsItem *item);
int storePingAttempt(std::string id, double ts, uint32_t mCounter); int storePingAttempt(const RsPeerId& id, double ts, uint32_t mCounter);
int storePongResult(std::string id, uint32_t counter, double ts, double rtt, double offset); int storePongResult(const RsPeerId& id, uint32_t counter, double ts, double rtt, double offset);
/*! /*!
@ -104,9 +104,9 @@ virtual bool recvItem(RsItem *item); // Overloaded from p3FastService.
private: private:
RsMutex mRttMtx; RsMutex mRttMtx;
RttPeerInfo *locked_GetPeerInfo(std::string id); RttPeerInfo *locked_GetPeerInfo(const RsPeerId& id);
std::map<std::string, RttPeerInfo> mPeerInfo; std::map<RsPeerId, RttPeerInfo> mPeerInfo;
time_t mSentPingTime; time_t mSentPingTime;
uint32_t mCounter; uint32_t mCounter;