diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c index 6f82997a9a217f146cc0a9861d25540e7d3e1753..ac8ca1c261e1835c114ff174b71edf0cbc067d18 100644 --- a/sflphone-client-gnome/src/config/accountconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountconfigdialog.c @@ -51,7 +51,6 @@ GtkWidget * label; GtkWidget * entryID; GtkWidget * entryAlias; GtkWidget * entryProtocol; -GtkWidget * entryEnabled; GtkWidget * entryUsername; GtkWidget * entryHostname; GtkWidget * entryPassword; @@ -171,12 +170,6 @@ static GtkWidget * create_basic_tab(account_t **a) gtk_table_attach ( GTK_TABLE( table ), entryID, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); #endif - entryEnabled = gtk_check_button_new_with_mnemonic(_("_Enable this account")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(entryEnabled), - g_strcasecmp(curAccountEnabled,"true") == 0 ? TRUE: FALSE); - gtk_table_attach ( GTK_TABLE( table ), entryEnabled, 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive( GTK_WIDGET( entryEnabled ) , TRUE ); - label = gtk_label_new_with_mnemonic (_("_Alias")); gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); @@ -340,10 +333,6 @@ static void add_credential_cb (GtkWidget *button, gpointer data) { GtkTreeIter iter; GtkTreeModel *model = (GtkTreeModel *)data; - GtkRequisition requisitionTreeView; - GtkRequisition oldRequisitionTreeView; - - gtk_widget_size_request(GTK_WIDGET(treeViewCredential), &oldRequisitionTreeView); gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, @@ -351,9 +340,6 @@ static void add_credential_cb (GtkWidget *button, gpointer data) COLUMN_CREDENTIAL_USERNAME, _("Authentication"), COLUMN_CREDENTIAL_PASSWORD, _("Secret"), -1); - - gtk_widget_size_request(GTK_WIDGET(treeViewCredential), &requisitionTreeView); - gtk_widget_set_size_request(GTK_WIDGET(scrolledWindowCredential), oldRequisitionTreeView.width, requisitionTreeView.height + 20); } static void delete_credential_cb(GtkWidget *button, gpointer data) @@ -362,10 +348,6 @@ static void delete_credential_cb(GtkWidget *button, gpointer data) GtkTreeView *treeview = (GtkTreeView *)data; GtkTreeModel *model = gtk_tree_view_get_model (treeview); GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview); - GtkRequisition requisitionTreeView; - GtkRequisition oldRequisitionTreeView; - - gtk_widget_size_request(GTK_WIDGET(treeViewCredential), &oldRequisitionTreeView); if (gtk_tree_selection_get_selected (selection, NULL, &iter)) { @@ -376,9 +358,6 @@ static void delete_credential_cb(GtkWidget *button, gpointer data) gtk_tree_path_free (path); } - gtk_widget_size_request(GTK_WIDGET(treeViewCredential), &requisitionTreeView); - gtk_widget_set_size_request(GTK_WIDGET(scrolledWindowCredential), oldRequisitionTreeView.width, requisitionTreeView.height + 20); - } static void cell_edited_cb(GtkCellRendererText *renderer, gchar *path_desc, gchar *text, gpointer data) @@ -607,7 +586,7 @@ GtkWidget * create_security_tab(account_t **a) GtkRequisition requisitionTreeView; gtk_widget_size_request(GTK_WIDGET(treeViewCredential), &requisitionTreeView); gtk_widget_size_request(GTK_WIDGET(table), &requisitionTable); - gtk_widget_set_size_request(GTK_WIDGET(scrolledWindowCredential), requisitionTable.width, requisitionTreeView.height + 20); + gtk_widget_set_size_request(GTK_WIDGET(scrolledWindowCredential), requisitionTable.width, 120); gtk_widget_show_all(ret); @@ -939,9 +918,6 @@ show_account_window (account_t * a) { gchar* proto = (gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(entryProtocol)); - g_hash_table_replace(currentAccount->properties, - g_strdup(ACCOUNT_ENABLED), - g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(entryEnabled)) ? "true": "false")); g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_RESOLVE_ONCE), g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(entryResolveNameOnlyOnce)) ? "false": "true")); diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 0d39a1553fa8875513c6e15099ea01044dadfef5..6ace2fa9b2583ae2cf55aa3888677fac4bc63ce4 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -1416,7 +1416,7 @@ dbus_set_md5_credential_hashing(gboolean enabled) GError* error = NULL; org_sflphone_SFLphone_ConfigurationManager_set_md5_credential_hashing( configurationManagerProxy, - &enabled, + enabled, &error); if(error) { diff --git a/sflphone-common/src/dbus/configurationmanager.cpp b/sflphone-common/src/dbus/configurationmanager.cpp index f76921e2477b25b422c8762987891daa3a7b631b..3077e7e4d4740fa87ba106fd642d6757731454bd 100644 --- a/sflphone-common/src/dbus/configurationmanager.cpp +++ b/sflphone-common/src/dbus/configurationmanager.cpp @@ -482,13 +482,18 @@ ConfigurationManager::getRecordDeviceList() bool ConfigurationManager::isMd5CredentialHashing(void) { - return Manager::instance().getMd5CredentialHashing(); + bool isEnabled = Manager::instance().getConfigBool(PREFERENCES, CONFIG_MD5HASH); + return isEnabled; } void ConfigurationManager::setMd5CredentialHashing(const bool& enabled) { - Manager::instance().setMd5CredentialHashing(enabled); + if (enabled) { + Manager::instance().setConfig(PREFERENCES, CONFIG_MD5HASH, TRUE_STR); + } else { + Manager::instance().setConfig(PREFERENCES, CONFIG_MD5HASH, FALSE_STR); + } } int32_t diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index ff613b2300e9b9d32a0fa7118eb2cd8b070c10f5..177a7b304f80fb6cabb5a670a52b6cf141a5156a 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -1844,16 +1844,6 @@ ManagerImpl::getMd5CredentialHashing(void) return getConfigBool(PREFERENCES, CONFIG_MD5HASH); } -void -ManagerImpl::setMd5CredentialHashing(bool enabled) -{ - if (enabled) { - setConfig(PREFERENCES, CONFIG_MD5HASH, TRUE_STR); - } else { - setConfig(PREFERENCES, CONFIG_MD5HASH, FALSE_STR); - } -} - int ManagerImpl::getDialpad (void) { @@ -2695,7 +2685,8 @@ void ManagerImpl::setCredential (const std::string& accountID, const int32_t& in // because deleteCredential() is called before this // method. Therefore, we cannot check if the value // is different from the one previously stored in - // the configuration file. + // the configuration file. This is to avoid to + // re-hash a hashed password. if(password.length() != 32) { password = computeMd5HashFromCredential(username, password, realm); @@ -2728,12 +2719,12 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::ma if((iter = map_cpy.find(USERNAME)) != map_cpy.end()) { username = iter->second; } if((iter = map_cpy.find(PASSWORD)) != map_cpy.end()) { password = iter->second; } if((iter = map_cpy.find(REALM)) != map_cpy.end()) { realm = iter->second; } - + + setConfig(accountID, REALM, realm); + setConfig(accountID, USERNAME, username); + setConfig(accountID, AUTHENTICATION_USERNAME, authenticationName); if(!getMd5CredentialHashing()) { - setConfig(accountID, REALM, realm); - setConfig(accountID, USERNAME, username); setConfig(accountID, PASSWORD, password); - setConfig(accountID, AUTHENTICATION_USERNAME, authenticationName); } else { // Make sure not to re-hash the password field if // it is already saved as a MD5 Hash. diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index 2b9d78bb90c08572e77dd74c907c208b6361b76c..aa513673d85d89020a9c78312d5056b01246fcb8 100644 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -505,14 +505,6 @@ class ManagerImpl { */ void setCredential (const std::string& accountID, const int32_t& index, const std::map< std::string, std::string >& details); - /** - * Set whether we should pre-hash the credentials - * in config file. - * - * @param enabled True if hashing should be used, false otherwise. - */ - void setMd5CredentialHashing(bool enabled); - /** * Retreive the value set in the configuration file. * @return True if credentials hashing is enabled. diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index 9afb0531f39179d226f7e92cdc36ae2c1c40106c..9184d3cc8966a5ee3ea8be284b4459ab37b65e3b 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -73,27 +73,43 @@ int SIPAccount::initCredential(void) int dataType = 0; md5HashingEnabled = Manager::instance().getConfigBool(PREFERENCES, CONFIG_MD5HASH); std::string digest; - if (md5HashingEnabled) { - dataType = PJSIP_CRED_DATA_DIGEST; - } else { - dataType = PJSIP_CRED_DATA_PLAIN_PASSWD; - } - + + // Create the credential array pjsip_cred_info * cred_info = (pjsip_cred_info *) malloc(sizeof(pjsip_cred_info)*(credentialCount)); if (cred_info == NULL) { _debug("Failed to set cred_info for account %s\n", _accountID.c_str()); return !SUCCESS; } + pj_bzero (cred_info, sizeof(pjsip_cred_info)*credentialCount); + // Use authentication username if provided if (!_authenticationUsername.empty()) { cred_info[0].username = pj_str(strdup(_authenticationUsername.c_str())); } else { cred_info[0].username = pj_str(strdup(_username.c_str())); } + + // Set password cred_info[0].data = pj_str(strdup(_password.c_str())); + + // Set realm for that credential. * by default. cred_info[0].realm = pj_str(strdup(_realm.c_str())); + + // We want to make sure that the password is really + // 32 characters long. Otherwise, pjsip will fail + // on an assertion. + if (md5HashingEnabled && _password.length() == 32) { + dataType = PJSIP_CRED_DATA_DIGEST; + _debug("Setting digest \n"); + } else { + dataType = PJSIP_CRED_DATA_PLAIN_PASSWD; + } + + // Set the datatype cred_info[0].data_type = dataType; + + // Set the secheme cred_info[0].scheme = pj_str("digest"); int i; @@ -112,7 +128,18 @@ int SIPAccount::initCredential(void) cred_info[i].username = pj_str(strdup(username.c_str())); cred_info[i].data = pj_str(strdup(password.c_str())); cred_info[i].realm = pj_str(strdup(realm.c_str())); + + // We want to make sure that the password is really + // 32 characters long. Otherwise, pjsip will fail + // on an assertion. + if (md5HashingEnabled && _password.length() == 32) { + dataType = PJSIP_CRED_DATA_DIGEST; + _debug("Setting digest \n"); + } else { + dataType = PJSIP_CRED_DATA_PLAIN_PASSWD; + } cred_info[i].data_type = dataType; + cred_info[i].scheme = pj_str("digest"); _debug("Setting credential %d realm = %s passwd = %s username = %s data_type = %d\n", i, realm.c_str(), password.c_str(), username.c_str(), cred_info[i].data_type); @@ -144,8 +171,10 @@ int SIPAccount::registerVoIPLink() initTlsConfiguration(); } + // In our definition of the + // ip2ip profile (aka Direct IP Calls), + // no registration should be performed if (_accountID != IP2IP_PROFILE) { - // Start registration int status = _link->sendRegister (_accountID); ASSERT (status , SUCCESS); } diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index b21e4c58377b4e2a27952df2c609a4022fb8d05c..afaa83d7fbe46fea46c435b39d2bb8b369be34e2 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -519,7 +519,7 @@ int SIPVoIPLink::sendRegister (AccountID id) pjsip_cred_info *cred = account->getCredInfo(); int credential_count = account->getCredentialCount(); - _debug("setting %d credentials\n", credential_count); + _debug("setting %d credentials in sendRegister\n", credential_count); pjsip_regc_set_credentials (regc, credential_count, cred); // Add User-Agent Header diff --git a/sflphone-common/src/sip/sipvoiplink.h b/sflphone-common/src/sip/sipvoiplink.h index 65e91ec3a37b7dfd4618b7ed16196b84544e2a07..f46c0a198ed556689c4ddfea41cc08054f6baef2 100644 --- a/sflphone-common/src/sip/sipvoiplink.h +++ b/sflphone-common/src/sip/sipvoiplink.h @@ -3,6 +3,7 @@ * * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> * Author: Yun Liu <yun.liu@savoirfairelinux.com> + * Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by