/** * Adds authentication information to the LinphoneCore. * * This information will be used during all SIP transacations that require authentication. **/ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info) { LinphoneAuthInfo *ai; MSList *elem; MSList *l; /* find if we are attempting to modify an existing auth info */ ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,info->realm,info->username); if (ai!=NULL){ lc->auth_info=ms_list_remove(lc->auth_info,ai); linphone_auth_info_destroy(ai); } lc->auth_info=ms_list_append(lc->auth_info,linphone_auth_info_clone(info)); /* retry pending authentication operations */ for(l=elem=sal_get_pending_auths(lc->sal);elem!=NULL;elem=elem->next){ const char *username,*realm; SalOp *op=(SalOp*)elem->data; LinphoneAuthInfo *ai; sal_op_get_auth_requested(op,&realm,&username); ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,realm,username); if (ai){ SalAuthInfo sai; sai.username=ai->username; sai.userid=ai->userid; sai.realm=ai->realm; sai.password=ai->passwd; sal_op_authenticate(op,&sai); ai->usecount++; } } ms_list_free(l); write_auth_infos(lc); }
static void text_message_with_credential_from_auth_cb(void) { char* to; LinphoneChatRoom* chat_room; LinphoneCoreVTable* vtable = linphone_core_v_table_new(); LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); text_message_with_credential_from_auth_cb_auth_info=linphone_auth_info_clone((LinphoneAuthInfo*)(linphone_core_get_auth_info_list(marie->lc)->data)); /*to force cb to be called*/ linphone_core_clear_all_auth_info(marie->lc); vtable->auth_info_requested=text_message_with_credential_from_auth_cb_auth_info_requested; linphone_core_add_listener(marie->lc, vtable); to = linphone_address_as_string(marie->identity); chat_room = linphone_core_create_chat_room(pauline->lc,to); ms_free(to); { int dummy=0; wait_for_until(marie->lc,pauline->lc,&dummy,1,100); /*just to have time to purge message stored in the server*/ reset_counters(&marie->stat); reset_counters(&pauline->stat); } linphone_chat_room_send_message(chat_room,"Bla bla bla bla"); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageReceivedLegacy,1); CU_ASSERT_PTR_NOT_NULL(linphone_core_get_chat_room(marie->lc,pauline->identity)); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
void AccountSettingsModel::setPassword(const QString& password) { if (!_authInfo) { return; } LinphoneAuthInfo *ai = linphone_auth_info_clone(_authInfo); linphone_auth_info_set_passwd(ai, password.toUtf8().constData()); linphone_core_remove_auth_info(LinphoneManager::getInstance()->getLc(), _authInfo); linphone_core_add_auth_info(LinphoneManager::getInstance()->getLc(), ai); _authInfo = ai; }
void AccountSettingsModel::setUsername(const QString& username) { if (!_authInfo || !_proxyConfig) { return; } LinphoneAuthInfo *ai = linphone_auth_info_clone(_authInfo); linphone_auth_info_set_username(ai, username.toUtf8().constData()); linphone_core_remove_auth_info(LinphoneManager::getInstance()->getLc(), _authInfo); linphone_core_add_auth_info(LinphoneManager::getInstance()->getLc(), ai); _authInfo = ai; const char *identity = linphone_proxy_config_get_identity(_proxyConfig); LinphoneAddress *addr = linphone_core_create_address(LinphoneManager::getInstance()->getLc(), identity); linphone_address_set_username(addr, username.toUtf8().constData()); linphone_proxy_config_edit(_proxyConfig); linphone_proxy_config_set_identity_address(_proxyConfig, addr); linphone_proxy_config_done(_proxyConfig); linphone_address_destroy(addr); }
/** * Adds authentication information to the LinphoneCore. * * This information will be used during all SIP transactions that require authentication. **/ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info){ LinphoneAuthInfo *ai; bctbx_list_t *elem; bctbx_list_t *l; int restarted_op_count=0; bool_t updating=FALSE; if (info->ha1==NULL && info->passwd==NULL){ ms_warning("linphone_core_add_auth_info(): info supplied with empty password or ha1."); } /* find if we are attempting to modify an existing auth info */ ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,info->realm,info->username,info->domain); if (ai!=NULL && ai->domain && info->domain && strcmp(ai->domain, info->domain)==0){ lc->auth_info=bctbx_list_remove(lc->auth_info,ai); linphone_auth_info_destroy(ai); updating=TRUE; } lc->auth_info=bctbx_list_append(lc->auth_info,linphone_auth_info_clone(info)); /* retry pending authentication operations */ for(l=elem=sal_get_pending_auths(lc->sal);elem!=NULL;elem=elem->next){ SalOp *op=(SalOp*)elem->data; LinphoneAuthInfo *ai; const SalAuthInfo *req_sai=sal_op_get_auth_requested(op); ai=(LinphoneAuthInfo*)_linphone_core_find_auth_info(lc,req_sai->realm,req_sai->username,req_sai->domain, FALSE); if (ai){ SalAuthInfo sai; bctbx_list_t* proxy; sai.username=ai->username; sai.userid=ai->userid; sai.realm=ai->realm; sai.password=ai->passwd; sai.ha1=ai->ha1; if (ai->tls_cert && ai->tls_key) { sal_certificates_chain_parse(&sai, ai->tls_cert, SAL_CERTIFICATE_RAW_FORMAT_PEM); sal_signing_key_parse(&sai, ai->tls_key, ""); } else if (ai->tls_cert_path && ai->tls_key_path) { sal_certificates_chain_parse_file(&sai, ai->tls_cert_path, SAL_CERTIFICATE_RAW_FORMAT_PEM); sal_signing_key_parse_file(&sai, ai->tls_key_path, ""); } /*proxy case*/ for (proxy=(bctbx_list_t*)linphone_core_get_proxy_config_list(lc);proxy!=NULL;proxy=proxy->next) { if (proxy->data == sal_op_get_user_pointer(op)) { linphone_proxy_config_set_state((LinphoneProxyConfig*)(proxy->data),LinphoneRegistrationProgress,"Authentication..."); break; } } sal_op_authenticate(op,&sai); restarted_op_count++; } } if (l){ ms_message("linphone_core_add_auth_info(): restarted [%i] operation(s) after %s auth info for\n" "\tusername: [%s]\n" "\trealm [%s]\n" "\tdomain [%s]\n", restarted_op_count, updating ? "updating" : "adding", info->username ? info->username : "", info->realm ? info->realm : "", info->domain ? info->domain : ""); } bctbx_list_free(l); write_auth_infos(lc); }