Commit aa2a7a0f authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Added possibility to create SHA-256 accounts in tester

parent c9f43862
......@@ -270,3 +270,16 @@ void linphone_core_clear_all_auth_info(LinphoneCore *lc){
bctbx_list_free(lc->auth_info);
lc->auth_info=NULL;
}
void linphone_auth_info_fill_belle_sip_event(const LinphoneAuthInfo *auth_info, belle_sip_auth_event *event) {
if (auth_info) {
const char *auth_username = linphone_auth_info_get_username(auth_info);
const char *auth_password = linphone_auth_info_get_password(auth_info);
const char *auth_ha1 = linphone_auth_info_get_ha1(auth_info);
const char *auth_algo = linphone_auth_info_get_algorithm(auth_info);
belle_sip_auth_event_set_username(event, auth_username);
belle_sip_auth_event_set_passwd(event, auth_password);
belle_sip_auth_event_set_ha1(event, auth_ha1);
belle_sip_auth_event_set_algorithm(event, auth_algo);
}
}
......@@ -475,9 +475,7 @@ static void process_auth_requested_from_carddav_request(void *data, belle_sip_au
const char *domain = belle_generic_uri_get_host(uri);
if (cdc->auth_info) {
belle_sip_auth_event_set_username(event, linphone_auth_info_get_username(cdc->auth_info));
belle_sip_auth_event_set_passwd(event, linphone_auth_info_get_passwd(cdc->auth_info));
belle_sip_auth_event_set_ha1(event, linphone_auth_info_get_ha1(cdc->auth_info));
linphone_auth_info_fill_belle_sip_event(cdc->auth_info, event);
} else {
LinphoneCore *lc = cdc->friend_list->lc;
const bctbx_list_t *auth_infos = linphone_core_get_auth_info_list(lc);
......@@ -487,9 +485,7 @@ static void process_auth_requested_from_carddav_request(void *data, belle_sip_au
LinphoneAuthInfo *auth_info = (LinphoneAuthInfo *)auth_infos->data;
if (linphone_auth_info_get_domain(auth_info) && strcmp(domain, linphone_auth_info_get_domain(auth_info)) == 0) {
if (!linphone_auth_info_get_realm(auth_info) || strcmp(realm, linphone_auth_info_get_realm(auth_info)) == 0) {
belle_sip_auth_event_set_username(event, linphone_auth_info_get_username(auth_info));
belle_sip_auth_event_set_passwd(event, linphone_auth_info_get_passwd(auth_info));
belle_sip_auth_event_set_ha1(event, linphone_auth_info_get_ha1(auth_info));
linphone_auth_info_fill_belle_sip_event(auth_info, event);
cdc->auth_info = linphone_auth_info_clone(auth_info);
break;
}
......
......@@ -127,6 +127,7 @@ void _linphone_core_uninit(LinphoneCore *lc);
void linphone_core_write_auth_info(LinphoneCore *lc, LinphoneAuthInfo *ai);
const LinphoneAuthInfo *_linphone_core_find_tls_auth_info(LinphoneCore *lc);
const LinphoneAuthInfo *_linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username, const char *domain, bool_t ignore_realm);
void linphone_auth_info_fill_belle_sip_event(const LinphoneAuthInfo *auth_info, belle_sip_auth_event *event);
void linphone_core_update_proxy_register(LinphoneCore *lc);
const char *linphone_core_get_nat_address_resolved(LinphoneCore *lc);
......
......@@ -79,12 +79,7 @@ static void belle_request_process_auth_requested(void *ctx, belle_sip_auth_event
const LinphoneAuthInfo *auth_info = linphone_core_find_auth_info(lc, realm, username, domain);
if (auth_info) {
const char *auth_username = linphone_auth_info_get_username(auth_info);
const char *auth_password = linphone_auth_info_get_password(auth_info);
const char *auth_ha1 = linphone_auth_info_get_ha1(auth_info);
belle_sip_auth_event_set_username(event, auth_username);
belle_sip_auth_event_set_passwd(event, auth_password);
belle_sip_auth_event_set_ha1(event, auth_ha1);
linphone_auth_info_fill_belle_sip_event(auth_info, event);
} else {
linphone_configuring_terminated(lc, LinphoneConfiguringFailed, "http auth requested");
}
......
......@@ -204,10 +204,7 @@ static void process_auth_requested_from_post_xml_rpc_request(void *data, belle_s
const LinphoneAuthInfo *auth_info = linphone_core_find_auth_info(creator->core, realm, username, domain);
if (auth_info) {
const char *auth_username = linphone_auth_info_get_username(auth_info);
const char *auth_password = linphone_auth_info_get_password(auth_info);
belle_sip_auth_event_set_username(event, auth_username);
belle_sip_auth_event_set_passwd(event, auth_password);
linphone_auth_info_fill_belle_sip_event(auth_info, event);
} else {
ms_error("Authentication error during XML-RPC request sending");
if (!linphone_xml_rpc_request_aborted(request)){
......
......@@ -76,15 +76,7 @@ void LimeManager::processAuthRequested (void *data, belle_sip_auth_event_t *even
const char *domain = belle_sip_auth_event_get_domain(event);
const LinphoneAuthInfo *auth_info = linphone_core_find_auth_info(core->getCCore(), realm, username, domain);
if (auth_info) {
const char *auth_username = linphone_auth_info_get_username(auth_info);
const char *auth_password = linphone_auth_info_get_password(auth_info);
const char *auth_ha1 = linphone_auth_info_get_ha1(auth_info);
belle_sip_auth_event_set_username(event, auth_username);
belle_sip_auth_event_set_passwd(event, auth_password);
belle_sip_auth_event_set_ha1(event, auth_ha1);
}
linphone_auth_info_fill_belle_sip_event(auth_info, event);
}
LimeManager::LimeManager (
......@@ -841,7 +833,7 @@ void LimeX3dhEncryptionEngine::onRegistrationStateChanged (
if (!limeManager->is_user(localDeviceId)) {
// create user if not exist
lime::limeCallback callback = setLimeCallback("creating user" + localDeviceId);
lime::limeCallback callback = setLimeCallback("creating user " + localDeviceId);
limeManager->create_user(localDeviceId, x3dhServerUrl, curve, callback);
} else {
......
......@@ -287,6 +287,8 @@ void account_create_in_db(Account *account, LinphoneProxyConfig *cfg, const char
char *email = bctbx_strdup_printf("%s@%s", username, domain);
const char *algorithm = linphone_config_get_string(linphone_core_get_config(linphone_proxy_config_get_core(cfg)), "assistant", "algorithm", NULL);
AccountCreatorState state = {0};
// create account
......@@ -296,6 +298,7 @@ void account_create_in_db(Account *account, LinphoneProxyConfig *cfg, const char
linphone_account_creator_set_domain(creator, domain);
linphone_account_creator_set_email(creator, email);
linphone_account_creator_set_user_data(creator, &state);
linphone_account_creator_set_algorithm(creator, algorithm);
if (account->phone_alias) {
LinphoneAccountCreatorPhoneNumberStatusMask err = 0;
......@@ -319,7 +322,7 @@ void account_create_in_db(Account *account, LinphoneProxyConfig *cfg, const char
if (wait_for_until(lc, NULL, &state.account_created, TRUE, 15000) == FALSE)
ms_fatal("Could not create account %s on db", linphone_proxy_config_get_identity(cfg));
LinphoneAuthInfo *ai = linphone_auth_info_new(username, NULL, password, NULL, domain, domain);
LinphoneAuthInfo *ai = linphone_auth_info_new_for_algorithm(username, NULL, password, NULL, domain, domain, algorithm);
linphone_core_add_auth_info(lc, ai);
linphone_auth_info_unref(ai);
......@@ -407,13 +410,15 @@ static LinphoneAddress *account_manager_check_account(AccountManager *m, Linphon
if (original_ai)
linphone_core_remove_auth_info(lc,original_ai);
ai = linphone_auth_info_new(
const char *algorithm = linphone_config_get_string(linphone_core_get_config(lc), "assistant", "algorithm", NULL);
ai = linphone_auth_info_new_for_algorithm(
linphone_address_get_username(account->modified_identity),
NULL,
account->password,
NULL,
linphone_address_get_domain(account->modified_identity),
linphone_address_get_domain(account->modified_identity) // realm = domain
linphone_address_get_domain(account->modified_identity), // realm = domain
algorithm
);
linphone_core_add_auth_info(lc, ai);
linphone_auth_info_unref(ai);
......
......@@ -20,6 +20,9 @@ userid=marie
passwd=secret
realm=sip.example.org
[assistant]
algorithm=SHA-256
[proxy_0]
reg_proxy=sip.example.org;transport=tcp
reg_route=sip.example.org;transport=tcp;lr
......
......@@ -18,6 +18,9 @@ userid=marie
passwd=secret
realm=sip.example.org
[assistant]
algorithm=SHA-256
[proxy_0]
reg_proxy=sip.example.org;transport=tcp
reg_route=sip.example.org;transport=tcp;lr
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment