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

[#3649] Fix credentials in managerimpl and in configurationmanager

parent a661f4e7
No related branches found
No related tags found
No related merge requests found
......@@ -265,18 +265,17 @@ void ConfigurationManager::setTlsSettings(const std::string& section,
std::map<std::string, std::string> ConfigurationManager::getCredential(
const std::string& accountID, const int32_t& index) {
std::string credentialIndex;
std::stringstream streamOut;
streamOut << index;
credentialIndex = streamOut.str();
Account *account = Manager::instance().getAccount(accountID);
SIPAccount *sipaccount = (SIPAccount *)Manager::instance().getAccount(accountID);
std::map<std::string, std::string> credentialInformation;
if(account->getType() != "SIP")
return credentialInformation;
std::string section = std::string("Credential") + std::string(":")
+ accountID + std::string(":") + credentialIndex;
SIPAccount *sipaccount = (SIPAccount *)account;
std::map<std::string, std::string> credentialInformation;
if(index == 0) {
std::string username = sipaccount->getUsername();
std::string password = sipaccount->getPassword();
std::string realm = sipaccount->getRealm();
......@@ -284,6 +283,18 @@ std::map<std::string, std::string> ConfigurationManager::getCredential(
credentialInformation.insert(std::pair<std::string, std::string>(USERNAME, username));
credentialInformation.insert(std::pair<std::string, std::string>(PASSWORD, password));
credentialInformation.insert(std::pair<std::string, std::string>(REALM, realm));
}
else {
// TODO: implement for extra credentials
std::string username = sipaccount->getUsername();
std::string password = sipaccount->getPassword();
std::string realm = sipaccount->getRealm();
credentialInformation.insert(std::pair<std::string, std::string>(USERNAME, username));
credentialInformation.insert(std::pair<std::string, std::string>(PASSWORD, password));
credentialInformation.insert(std::pair<std::string, std::string>(REALM, realm));
}
return credentialInformation;
}
......
......@@ -3330,6 +3330,9 @@ std::string ManagerImpl::computeMd5HashFromCredential (
void ManagerImpl::setCredential (const std::string& accountID,
const int32_t& index, const std::map<std::string, std::string>& details) {
_debug("Manager: set credential");
/*
std::map<std::string, std::string>::iterator it;
std::map<std::string, std::string> credentialInformation = details;
......@@ -3390,6 +3393,7 @@ void ManagerImpl::setCredential (const std::string& accountID,
}
Manager::instance().setConfig(section, PASSWORD, password);
*/
}
// method to reduce the if/else mess.
......@@ -3398,7 +3402,7 @@ void ManagerImpl::setCredential (const std::string& accountID,
void ManagerImpl::setAccountDetails (const std::string& accountID,
const std::map<std::string, std::string>& details) {
_debug("----------------------- Manager: Set account details %s", accountID.c_str());
_debug("Manager: Set account details %s", accountID.c_str());
Account* account;
if(!(account = getAccount(accountID))) {
......@@ -3477,6 +3481,8 @@ std::string ManagerImpl::addAccount (
void ManagerImpl::deleteAllCredential (const AccountID& accountID) {
_debug("Manager: delete all credential");
Account *account = getAccount(accountID);
if(account->getType() != "SIP")
......
......@@ -643,7 +643,7 @@ int SIPVoIPLink::sendRegister (AccountID id)
pjsip_cred_info *cred = account->getCredInfo();
int credential_count = account->getCredentialCount();
_debug ("setting %d credentials in sendRegister", credential_count);
_debug ("UserAgent: setting %d credentials in sendRegister", credential_count);
pjsip_regc_set_credentials (regc, credential_count, cred);
// Add User-Agent Header
......@@ -657,7 +657,7 @@ int SIPVoIPLink::sendRegister (AccountID id)
// pj_list_push_back (&hdr_list, (pjsip_hdr*) routing);
if (regc)
_debug("No regc ......");
_debug("UserAgent: Error: No regc ......");
pjsip_regc_add_headers (regc, &hdr_list);
......@@ -681,7 +681,7 @@ int SIPVoIPLink::sendRegister (AccountID id)
// managed when acquiring transport
pjsip_transport_dec_ref(account->getAccountTransport ());
_debug("After setting the transport in account registration using transport: %s %s (refcnt=%d)",
_debug("UserAgent: After setting the transport in account registration using transport: %s %s (refcnt=%d)",
account->getAccountTransport()->obj_name,
account->getAccountTransport()->info,
(int)pj_atomic_get(account->getAccountTransport()->ref_cnt));
......
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