RetroShare/libretroshare/src/pqi/p3authmgr.cc
drbob d4b52a59e5 Major bugfixes to get PGP authentication finished.
* p3disc now exchanges "Issuer" (pgp) certificates as well.
 * additional types for rsdiscitems.h
 * Bug Fix for NULL packet in p3service.cc
 * allow unauthed SSL certificates to be added in AuthSSL - otherwise cant add new friends!
 * only save authed SSL certificates.
 * fixed ref/unref of PGP keys in AuthGPG
 * added Mutex protection to AuthGPG
 * added PGP reloading when key is imported, or signed.
 * Fixed PGP key signing.
 * added Additional field validLvl to RsPeerDetails.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1270 b45a01b8-16f6-495d-af2f-9b41ad6348cc
2009-05-25 11:38:47 +00:00

302 lines
6.2 KiB
C++

/*
* libretroshare/src/pqi: p3authmgr.cc
*
* 3P/PQI network interface for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include <iostream>
#include "pqi/p3authmgr.h"
pqiAuthDetails::pqiAuthDetails()
:trustLvl(0), validLvl(0), ownsign(false), trusted(false)
{
return;
}
p3DummyAuthMgr::p3DummyAuthMgr()
{
/* for the truely dummy option */
mOwnId = "OWNID";
pqiAuthDetails ownDetails;
ownDetails.id = mOwnId;
ownDetails.name = "Youself";
ownDetails.email = "me@me.com";
ownDetails.location = "here";
ownDetails.org = "me.com";
ownDetails.trustLvl = 6;
ownDetails.ownsign = true;
ownDetails.trusted = true;
/* ignoring fpr and signers */
mPeerList[mOwnId] = ownDetails;
}
bool p3DummyAuthMgr::isTrustingMe(std::string id)
{
std::cerr << "isTrustingMe is not implemented in p3DummyAuthMgr. Look into authxpgp.cc." << std::endl ;
return false ;
}
void p3DummyAuthMgr::addTrustingPeer(std::string id)
{
std::cerr << "addTrustingPeer is not implemented in p3DummyAuthMgr. Look into authxpgp.cc." << std::endl ;
}
p3DummyAuthMgr::p3DummyAuthMgr(std::string ownId, std::list<pqiAuthDetails> peers)
{
mOwnId = ownId;
bool addedOwn = false;
std::list<pqiAuthDetails>::iterator it;
for(it = peers.begin(); it != peers.end(); it++)
{
mPeerList[it->id] = (*it);
if (it->id == ownId)
{
addedOwn = true;
}
}
if (!addedOwn)
{
pqiAuthDetails ownDetails;
ownDetails.id = mOwnId;
ownDetails.name = "Youself";
ownDetails.email = "me@me.com";
ownDetails.location = "here";
ownDetails.org = "me.com";
ownDetails.trustLvl = 6;
ownDetails.ownsign = true;
ownDetails.trusted = true;
/* ignoring fpr and signers */
mPeerList[mOwnId] = ownDetails;
}
}
bool p3DummyAuthMgr:: active()
{
return true;
}
int p3DummyAuthMgr::InitAuth(const char *srvr_cert, const char *priv_key,
const char *passwd)
{
return 1;
}
bool p3DummyAuthMgr::CloseAuth()
{
return true;
}
int p3DummyAuthMgr::setConfigDirectories(std::string confFile, std::string neighDir)
{
return 1;
}
std::string p3DummyAuthMgr::OwnId()
{
return mOwnId;
}
bool p3DummyAuthMgr::getAllList(std::list<std::string> &ids)
{
std::map<std::string, pqiAuthDetails>::iterator it;
for(it = mPeerList.begin(); it != mPeerList.end(); it++)
{
ids.push_back(it->first);
}
return true;
}
bool p3DummyAuthMgr::getAuthenticatedList(std::list<std::string> &ids)
{
std::map<std::string, pqiAuthDetails>::iterator it;
for(it = mPeerList.begin(); it != mPeerList.end(); it++)
{
if (it->second.trustLvl > 3)
{
ids.push_back(it->first);
}
}
return true;
}
bool p3DummyAuthMgr::getUnknownList(std::list<std::string> &ids)
{
std::map<std::string, pqiAuthDetails>::iterator it;
for(it = mPeerList.begin(); it != mPeerList.end(); it++)
{
if (it->second.trustLvl <= 3)
{
ids.push_back(it->first);
}
}
return true;
}
bool p3DummyAuthMgr::isValid(std::string id)
{
std::map<std::string, pqiAuthDetails>::iterator it;
return (mPeerList.end() != mPeerList.find(id));
}
bool p3DummyAuthMgr::isAuthenticated(std::string id)
{
std::map<std::string, pqiAuthDetails>::iterator it;
if (mPeerList.end() != (it = mPeerList.find(id)))
{
return (it->second.trustLvl > 3);
}
return false;
}
std::string p3DummyAuthMgr::getName(std::string id)
{
std::map<std::string, pqiAuthDetails>::iterator it;
if (mPeerList.end() != (it = mPeerList.find(id)))
{
return it->second.name;
}
std::string empty("");
return empty;
}
bool p3DummyAuthMgr::getDetails(std::string id, pqiAuthDetails &details)
{
std::map<std::string, pqiAuthDetails>::iterator it;
if (mPeerList.end() != (it = mPeerList.find(id)))
{
details = it->second;
return true;
}
return false;
}
bool p3DummyAuthMgr::FinalSaveCertificates()
{
return false;
}
bool p3DummyAuthMgr::CheckSaveCertificates()
{
return false;
}
bool p3DummyAuthMgr::saveCertificates()
{
return false;
}
bool p3DummyAuthMgr::loadCertificates()
{
return false;
}
bool p3DummyAuthMgr::LoadCertificateFromString(std::string pem, std::string &id)
{
return false;
}
std::string p3DummyAuthMgr::SaveCertificateToString(std::string id)
{
std::string dummy("CERT STRING");
return dummy;
}
bool p3DummyAuthMgr::LoadCertificateFromFile(std::string filename, std::string &id)
{
return false;
}
bool p3DummyAuthMgr::SaveCertificateToFile(std::string id, std::string filename)
{
return false;
}
bool p3DummyAuthMgr::LoadCertificateFromBinary(const uint8_t *ptr, uint32_t len, std::string &id)
{
return false;
}
bool p3DummyAuthMgr::SaveCertificateToBinary(std::string id, uint8_t **ptr, uint32_t *len)
{
return false;
}
/* Signatures */
bool p3DummyAuthMgr::AuthCertificate(std::string id)
{
return false;
}
bool p3DummyAuthMgr::SignCertificate(std::string id)
{
return false;
}
bool p3DummyAuthMgr::RevokeCertificate(std::string id)
{
return false;
}
bool p3DummyAuthMgr::TrustCertificate(std::string id, bool trust)
{
return false;
}
bool p3DummyAuthMgr::SignData(std::string input, std::string &sign)
{
return false;
}
bool p3DummyAuthMgr::SignData(const void *data, const uint32_t len, std::string &sign)
{
return false;
}
bool p3DummyAuthMgr::SignDataBin(std::string input,
unsigned char *sign, unsigned int *signlen)
{
return false;
}
bool p3DummyAuthMgr::SignDataBin(const void *data, const uint32_t len,
unsigned char *sign, unsigned int *signlen)
{
return false;
}
bool p3DummyAuthMgr::VerifySignBin(std::string pid,
const void *data, const uint32_t len,
unsigned char *sign, unsigned int signlen)
{
return false;
}