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
Branches
Tags
No related merge requests found
...@@ -56,12 +56,12 @@ std::map<std::string, std::string> ConfigurationManager::getIp2IpDetails() ...@@ -56,12 +56,12 @@ std::map<std::string, std::string> ConfigurationManager::getIp2IpDetails()
SIPAccount *sipaccount = Manager::instance().getIP2IPAccount(); SIPAccount *sipaccount = Manager::instance().getIP2IPAccount();
if (!sipaccount) { if (!sipaccount) {
ERROR("ConfigurationManager: could not find account"); ERROR("ConfigurationManager: could not find IP2IP account");
return ip2ipAccountDetails; return ip2ipAccountDetails;
} else } else
return sipaccount->getIp2IpDetails(); 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::copy(tlsSettings.begin(), tlsSettings.end(),
std::inserter(ip2ipAccountDetails, ip2ipAccountDetails.end())); std::inserter(ip2ipAccountDetails, ip2ipAccountDetails.end()));
...@@ -442,23 +442,19 @@ void ConfigurationManager::setShortcuts( ...@@ -442,23 +442,19 @@ void ConfigurationManager::setShortcuts(
std::vector<std::map<std::string, std::string> > ConfigurationManager::getCredentials( std::vector<std::map<std::string, std::string> > ConfigurationManager::getCredentials(
const std::string& accountID) 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; std::vector<std::map<std::string, std::string> > credentialInformation;
if (!account or account->getType() != "SIP") if (!account)
return credentialInformation; return credentialInformation;
else
SIPAccount *sipaccount = static_cast<SIPAccount *>(account); return account->getCredentials();
return sipaccount->getCredentials();
} }
void ConfigurationManager::setCredentials(const std::string& accountID, void ConfigurationManager::setCredentials(const std::string& accountID,
const std::vector<std::map<std::string, std::string> >& details) const std::vector<std::map<std::string, std::string> >& details)
{ {
Account *account = Manager::instance().getAccount(accountID); SIPAccount *account = dynamic_cast<SIPAccount*>(Manager::instance().getAccount(accountID));
if (account)
if (account and account->getType() == "SIP") { account->setCredentials(details);
SIPAccount *sipaccount = static_cast<SIPAccount*>(account);
sipaccount->setCredentials(details);
}
} }
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include "manager.h" #include "manager.h"
#include <pwd.h> #include <pwd.h>
#include <sstream> #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::OVERRTP_STR = "overrtp";
...@@ -872,6 +871,7 @@ std::string computeMd5HashFromCredential(const std::string& username, ...@@ -872,6 +871,7 @@ std::string computeMd5HashFromCredential(const std::string& username,
MD5_APPEND(&pms, realm.data(), realm.length()); MD5_APPEND(&pms, realm.data(), realm.length());
MD5_APPEND(&pms, ":", 1); MD5_APPEND(&pms, ":", 1);
MD5_APPEND(&pms, password.data(), password.length()); MD5_APPEND(&pms, password.data(), password.length());
#undef MD5_APPEND
unsigned char digest[16]; unsigned char digest[16];
pj_md5_final(&pms, digest); pj_md5_final(&pms, digest);
...@@ -887,14 +887,18 @@ std::string computeMd5HashFromCredential(const std::string& username, ...@@ -887,14 +887,18 @@ std::string computeMd5HashFromCredential(const std::string& username,
void SIPAccount::setCredentials(const std::vector<std::map<std::string, std::string> >& creds) 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::vector;
using std::string; using std::string;
using std::map; using std::map;
bool md5HashingEnabled = Manager::instance().preferences.getMd5Hash(); bool md5HashingEnabled = Manager::instance().preferences.getMd5Hash();
assert(not creds.empty()); // we can not authenticate without credentials
credentials_ = creds; credentials_ = creds;
/* md5 hashing */ /* md5 hashing */
...@@ -951,7 +955,8 @@ void SIPAccount::setCredentials(const std::vector<std::map<std::string, std::str ...@@ -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_; return credentials_;
} }
...@@ -983,8 +988,7 @@ std::map<std::string, std::string> SIPAccount::getIp2IpDetails() const ...@@ -983,8 +988,7 @@ std::map<std::string, std::string> SIPAccount::getIp2IpDetails() const
portstr << localPort_; portstr << localPort_;
ip2ipAccountDetails[CONFIG_LOCAL_PORT] = portstr.str(); ip2ipAccountDetails[CONFIG_LOCAL_PORT] = portstr.str();
std::map<std::string, std::string> tlsSettings; std::map<std::string, std::string> tlsSettings(getTlsSettings());
tlsSettings = getTlsSettings();
std::copy(tlsSettings.begin(), tlsSettings.end(), std::inserter( std::copy(tlsSettings.begin(), tlsSettings.end(), std::inserter(
ip2ipAccountDetails, ip2ipAccountDetails.end())); ip2ipAccountDetails, ip2ipAccountDetails.end()));
...@@ -993,8 +997,8 @@ std::map<std::string, std::string> SIPAccount::getIp2IpDetails() const ...@@ -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> SIPAccount::getTlsSettings() const
{ {
std::map<std::string, std::string> tlsSettings;
assert(isIP2IP()); assert(isIP2IP());
std::map<std::string, std::string> tlsSettings;
std::stringstream portstr; std::stringstream portstr;
portstr << tlsListenerPort_; portstr << tlsListenerPort_;
......
...@@ -205,7 +205,9 @@ class SIPAccount : public Account { ...@@ -205,7 +205,9 @@ class SIPAccount : public Account {
} }
void setCredentials(const std::vector<std::map<std::string, std::string> >& details); 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 * 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.
Please register or to comment