Skip to content
Snippets Groups Projects
Commit 37ba1dca authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#3648] Implement credential serialization

parent fd8e77db
Branches
Tags
No related merge requests found
......@@ -113,6 +113,7 @@ class ManagerImpl {
ManagerImpl (void);
~ManagerImpl (void);
Preferences preferences;
short buildConfiguration();
......@@ -1347,8 +1348,6 @@ private:
Conf::YamlParser *parser;
Preferences preferences;
#ifdef TEST
bool testCallAccountMap();
bool testAccountMap();
......
......@@ -36,6 +36,28 @@
#include <pwd.h>
Credentials::Credentials() : credentialCount(0) {}
Credentials::~Credentials() {}
void Credentials::serialize(Engine *engine)
{
}
void Credentials::unserialize(Conf::MappingNode *map)
{
Conf::ScalarNode *val = NULL;
_debug("SipAccount: Unserialize");
val = (Conf::ScalarNode *)(map->getValue(credentialCountKey));
if(val) { credentialCount = atoi(val->getValue().data()); val = NULL; }
}
SIPAccount::SIPAccount (const AccountID& accountID)
: Account (accountID, "sip")
, _routeSet("")
......@@ -122,6 +144,7 @@ void SIPAccount::unserialize(Conf::MappingNode *map)
Conf::MappingNode *srtpMap;
Conf::MappingNode *tlsMap;
Conf::MappingNode *zrtpMap;
Conf::MappingNode *credMap;
_debug("SipAccount: Unserialize");
......@@ -167,6 +190,8 @@ void SIPAccount::unserialize(Conf::MappingNode *map)
// _dtmfType = atoi(val->getValue();
// stun enabled
credMap = (Conf::MappingNode *)(map->getValue(credKey));
credentials.unserialize(credMap);
// get srtp submap
srtpMap = (Conf::MappingNode *)(map->getValue(srtpKey));
......@@ -242,12 +267,12 @@ void SIPAccount::setVoIPLink() {
int SIPAccount::initCredential (void)
{
int credentialCount = 0;
credentialCount = Manager::instance().getConfigInt (_accountID, CONFIG_CREDENTIAL_NUMBER);
credentialCount = credentials.getCredentialCount();// Manager::instance().getConfigInt (_accountID, CONFIG_CREDENTIAL_NUMBER);
credentialCount += 1;
bool md5HashingEnabled = false;
int dataType = 0;
md5HashingEnabled = Manager::instance().getConfigBool (PREFERENCES, CONFIG_MD5HASH);
md5HashingEnabled = Manager::instance().preferences.getMd5Hash(); // Manager::instance().getConfigBool (PREFERENCES, CONFIG_MD5HASH);
std::string digest;
// Create the credential array
......
......@@ -43,6 +43,7 @@
#include "pjsip/sip_types.h"
#include "config/serializable.h"
#include <exception>
#include <map>
enum DtmfType { OVERRTP, SIPINFO};
......@@ -89,6 +90,9 @@ const Conf::Key serverKey("server");
const Conf::Key verifyClientKey("verifyClient");
const Conf::Key verifyServerKey("verifyServer");
const Conf::Key credKey("credential");
const Conf::Key credentialCountKey("count");
class SIPVoIPLink;
/**
......@@ -115,6 +119,32 @@ class SipAccountException : public std::exception
};
class Credentials : public Serializable
{
public:
typedef std::map<std::string, std::string> CredentialMap;
Credentials();
~Credentials();
virtual void serialize(Engine *engine);
virtual void unserialize(Conf::MappingNode *map);
int getCredentialCount(void) { return credentialCount; }
void setCredentialCount(int count) { credentialCount = count; }
private:
int credentialCount;
CredentialMap credentialMap;
};
class SIPAccount : public Account
{
public:
......@@ -546,6 +576,7 @@ class SIPAccount : public Account
pjsip_cred_info *_cred;
std::string _realm;
std::string _authenticationUsername;
Credentials credentials;
// The TLS settings, if tls is chosen as
// a sip transport.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment