Skip to content
Snippets Groups Projects
Commit fcb7b8f8 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #9847: don't use assertions for input coming from DBus

parent d7300288
No related branches found
No related tags found
No related merge requests found
......@@ -56,12 +56,12 @@ std::map<std::string, std::string> ConfigurationManager::getIp2IpDetails()
SIPAccount *sipaccount = Manager::instance().getIP2IPAccount();
if (!sipaccount) {
ERROR("ConfigurationManager: could not find account");
ERROR("ConfigurationManager: could not find IP2IP account");
return ip2ipAccountDetails;
} else
return sipaccount->getIp2IpDetails();
std::map<std::string, std::string> tlsSettings = getTlsSettings();
std::map<std::string, std::string> tlsSettings(getTlsSettings());
std::copy(tlsSettings.begin(), tlsSettings.end(),
std::inserter(ip2ipAccountDetails, ip2ipAccountDetails.end()));
......@@ -442,23 +442,19 @@ void ConfigurationManager::setShortcuts(
std::vector<std::map<std::string, std::string> > ConfigurationManager::getCredentials(
const std::string& accountID)
{
Account *account = Manager::instance().getAccount(accountID);
SIPAccount *account = dynamic_cast<SIPAccount*>(Manager::instance().getAccount(accountID));
std::vector<std::map<std::string, std::string> > credentialInformation;
if (!account or account->getType() != "SIP")
if (!account)
return credentialInformation;
SIPAccount *sipaccount = static_cast<SIPAccount *>(account);
return sipaccount->getCredentials();
else
return account->getCredentials();
}
void ConfigurationManager::setCredentials(const std::string& accountID,
const std::vector<std::map<std::string, std::string> >& details)
{
Account *account = Manager::instance().getAccount(accountID);
if (account and account->getType() == "SIP") {
SIPAccount *sipaccount = static_cast<SIPAccount*>(account);
sipaccount->setCredentials(details);
}
SIPAccount *account = dynamic_cast<SIPAccount*>(Manager::instance().getAccount(accountID));
if (account)
account->setCredentials(details);
}
......@@ -42,9 +42,8 @@
#include "manager.h"
#include <pwd.h>
#include <sstream>
#include <cassert>
const char * const SIPAccount::IP2IP_PROFILE = "IP2IP";
const char * const SIPAccount::IP2IP_PROFILE = "IP2IP";
const char * const SIPAccount::OVERRTP_STR = "overrtp";
const char * const SIPAccount::SIPINFO_STR = "sipinfo";
......@@ -872,6 +871,7 @@ std::string computeMd5HashFromCredential(const std::string& username,
MD5_APPEND(&pms, realm.data(), realm.length());
MD5_APPEND(&pms, ":", 1);
MD5_APPEND(&pms, password.data(), password.length());
#undef MD5_APPEND
unsigned char digest[16];
pj_md5_final(&pms, digest);
......@@ -887,14 +887,18 @@ std::string computeMd5HashFromCredential(const std::string& username,
void SIPAccount::setCredentials(const std::vector<std::map<std::string, std::string> >& creds)
{
// we can not authenticate without credentials
if (creds.empty()) {
ERROR("SIPAccount: Cannot authenticate with empty credentials list");
return;
}
using std::vector;
using std::string;
using std::map;
bool md5HashingEnabled = Manager::instance().preferences.getMd5Hash();
assert(not creds.empty()); // we can not authenticate without credentials
credentials_ = creds;
/* md5 hashing */
......@@ -951,7 +955,8 @@ void SIPAccount::setCredentials(const std::vector<std::map<std::string, std::str
}
}
const std::vector<std::map<std::string, std::string> > &SIPAccount::getCredentials()
const std::vector<std::map<std::string, std::string> > &
SIPAccount::getCredentials() const
{
return credentials_;
}
......@@ -983,8 +988,7 @@ std::map<std::string, std::string> SIPAccount::getIp2IpDetails() const
portstr << localPort_;
ip2ipAccountDetails[CONFIG_LOCAL_PORT] = portstr.str();
std::map<std::string, std::string> tlsSettings;
tlsSettings = getTlsSettings();
std::map<std::string, std::string> tlsSettings(getTlsSettings());
std::copy(tlsSettings.begin(), tlsSettings.end(), std::inserter(
ip2ipAccountDetails, ip2ipAccountDetails.end()));
......@@ -993,8 +997,8 @@ std::map<std::string, std::string> SIPAccount::getIp2IpDetails() const
std::map<std::string, std::string> SIPAccount::getTlsSettings() const
{
std::map<std::string, std::string> tlsSettings;
assert(isIP2IP());
std::map<std::string, std::string> tlsSettings;
std::stringstream portstr;
portstr << tlsListenerPort_;
......
......@@ -205,7 +205,9 @@ class SIPAccount : public Account {
}
void setCredentials(const std::vector<std::map<std::string, std::string> >& details);
const std::vector<std::map<std::string, std::string> > &getCredentials();
const std::vector<std::map<std::string, std::string> > &
getCredentials() const;
/**
* A client sendings a REGISTER request MAY suggest an expiration
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment