forked from mirrors/linphone-iphone
fix compilation errors due to signature change in linphone_auth_info_new()
fix failed tests in case of failed authentication.
This commit is contained in:
parent
32efc7939c
commit
0177c5f876
15 changed files with 39 additions and 34 deletions
|
|
@ -1930,9 +1930,7 @@ static int lpc_cmd_register(LinphoneCore *lc, char *args){
|
|||
LinphoneAddress *from;
|
||||
LinphoneAuthInfo *info;
|
||||
if ((from=linphone_address_new(identity))!=NULL){
|
||||
char realm[128];
|
||||
snprintf(realm,sizeof(realm)-1,"\"%s\"",linphone_address_get_domain(from));
|
||||
info=linphone_auth_info_new(linphone_address_get_username(from),NULL,passwd,NULL,NULL);
|
||||
info=linphone_auth_info_new(NULL,NULL,passwd,NULL,NULL,linphone_address_get_username(from));
|
||||
linphone_core_add_auth_info(lc,info);
|
||||
linphone_address_destroy(from);
|
||||
linphone_auth_info_destroy(info);
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ linphonec_prompt_for_auth(LinphoneCore *lc, const char *realm, const char *usern
|
|||
return;
|
||||
}
|
||||
|
||||
pending_auth=linphone_auth_info_new(username,NULL,NULL,NULL,realm);
|
||||
pending_auth=linphone_auth_info_new(username,NULL,NULL,NULL,realm,domain);
|
||||
auth_stack.elem[auth_stack.nitems++]=pending_auth;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,9 +33,17 @@
|
|||
|
||||
/**
|
||||
* Create a LinphoneAuthInfo object with supplied information.
|
||||
*
|
||||
* The object can be created empty, that is with all arguments set to NULL.
|
||||
* Username, userid, password and realm can be set later using specific methods.
|
||||
* Username, userid, password, realm and domain can be set later using specific methods.
|
||||
* At the end, username and passwd (or ha1) are required.
|
||||
* @param username the username that needs to be authenticated
|
||||
* @param userid the userid used for authenticating (use NULL if you don't know what it is)
|
||||
* @param passwd the password in clear text
|
||||
* @param ha1 the ha1-encrypted password if password is not given in clear text.
|
||||
* @param realm the authentication domain (which can be larger than the sip domain. Unfortunately many SIP servers don't use this parameter.
|
||||
* @param domain the SIP domain for which this authentication information is valid, if it has to be restricted for a single SIP domain.
|
||||
* @return a #LinphoneAuthInfo. linphone_auth_info_destroy() must be used to destroy it when no longer needed. The LinphoneCore makes a copy of LinphoneAuthInfo
|
||||
* passed through linphone_core_add_auth_info().
|
||||
**/
|
||||
LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *userid, const char *passwd, const char *ha1, const char *realm, const char *domain){
|
||||
LinphoneAuthInfo *obj=ms_new0(LinphoneAuthInfo,1);
|
||||
|
|
@ -344,11 +352,10 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info)
|
|||
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,info->domain);
|
||||
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);
|
||||
if (ai){
|
||||
SalAuthInfo sai;
|
||||
MSList* proxy;
|
||||
|
|
|
|||
|
|
@ -284,6 +284,7 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even
|
|||
belle_sip_client_transaction_t* client_transaction = belle_sip_response_event_get_client_transaction(event);
|
||||
belle_sip_response_t* response = belle_sip_response_event_get_response(event);
|
||||
int response_code = belle_sip_response_get_status_code(response);
|
||||
|
||||
if (!client_transaction) {
|
||||
ms_warning("Discarding stateless response [%i]",response_code);
|
||||
return;
|
||||
|
|
@ -305,15 +306,12 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even
|
|||
sal_op_assign_recv_headers(op,(belle_sip_message_t*)response);
|
||||
|
||||
if (op->callbacks.process_response_event) {
|
||||
|
||||
/*handle authorization*/
|
||||
switch (response_code) {
|
||||
case 200: {
|
||||
case 200:
|
||||
break;
|
||||
}
|
||||
case 401:
|
||||
case 407:{
|
||||
|
||||
case 407:
|
||||
/*belle_sip_transaction_set_application_data(BELLE_SIP_TRANSACTION(client_transaction),NULL);*//*remove op from trans*/
|
||||
if (op->state == SalOpStateTerminating && strcmp("BYE",belle_sip_request_get_method(request))!=0) {
|
||||
/*only bye are completed*/
|
||||
|
|
@ -327,7 +325,10 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even
|
|||
sal_process_authentication(op);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 403:
|
||||
if (op->auth_info) op->base.root->callbacks.auth_failure(op,op->auth_info);
|
||||
break;
|
||||
}
|
||||
op->callbacks.process_response_event(op,event);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -81,10 +81,8 @@ void sal_op_cancel_authentication(SalOp *h){
|
|||
return ;
|
||||
}
|
||||
|
||||
int sal_op_get_auth_requested(SalOp *op, const char **realm, const char **username){
|
||||
*realm=op->auth_info?op->auth_info->realm:NULL;
|
||||
*username=op->auth_info?op->auth_info->username:NULL;
|
||||
return 0;
|
||||
SalAuthInfo * sal_op_get_auth_requested(SalOp *op){
|
||||
return op->auth_info;
|
||||
}
|
||||
|
||||
belle_sip_header_contact_t* sal_op_create_contact(SalOp *op){
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ static void register_refresher_listener (belle_sip_refresher_t* refresher
|
|||
if (op->auth_info) {
|
||||
/*add pending auth*/
|
||||
sal_add_pending_auth(op->base.root,op);
|
||||
if (status_code==403)
|
||||
op->base.root->callbacks.auth_failure(op,op->auth_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ int main(int argc, char *argv[]){
|
|||
}
|
||||
LinphoneAuthInfo *info;
|
||||
if (password!=NULL){
|
||||
info=linphone_auth_info_new(linphone_address_get_username(from),NULL,password,NULL,NULL); /*create authentication structure from identity*/
|
||||
info=linphone_auth_info_new(linphone_address_get_username(from),NULL,password,NULL,NULL,NULL); /*create authentication structure from identity*/
|
||||
linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ int main(int argc, char *argv[]){
|
|||
}
|
||||
LinphoneAuthInfo *info;
|
||||
if (password!=NULL){
|
||||
info=linphone_auth_info_new(linphone_address_get_username(from),NULL,password,NULL,NULL); /*create authentication structure from identity*/
|
||||
info=linphone_auth_info_new(linphone_address_get_username(from),NULL,password,NULL,NULL,NULL); /*create authentication structure from identity*/
|
||||
linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ int main(int argc, char *argv[]){
|
|||
}
|
||||
LinphoneAuthInfo *info;
|
||||
if (password!=NULL){
|
||||
info=linphone_auth_info_new(linphone_address_get_username(from),NULL,password,NULL,NULL); /*create authentication structure from identity*/
|
||||
info=linphone_auth_info_new(linphone_address_get_username(from),NULL,password,NULL,NULL,NULL); /*create authentication structure from identity*/
|
||||
linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -963,9 +963,9 @@ void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cf
|
|||
ms_error("linphone_core_remove_proxy_config: LinphoneProxyConfig %p is not known by LinphoneCore (programming error?)",cfg);
|
||||
return;
|
||||
}
|
||||
lc->sip_conf.proxies=ms_list_remove(lc->sip_conf.proxies,(void *)cfg);
|
||||
lc->sip_conf.proxies=ms_list_remove(lc->sip_conf.proxies,cfg);
|
||||
/* add to the list of destroyed proxies, so that the possible unREGISTER request can succeed authentication */
|
||||
lc->sip_conf.deleted_proxies=ms_list_append(lc->sip_conf.deleted_proxies,(void *)cfg);
|
||||
lc->sip_conf.deleted_proxies=ms_list_append(lc->sip_conf.deleted_proxies,cfg);
|
||||
cfg->deletion_date=ms_time(NULL);
|
||||
if (cfg->state==LinphoneRegistrationOk){
|
||||
/* this will unREGISTER */
|
||||
|
|
|
|||
|
|
@ -1039,8 +1039,7 @@ static void linphone_gtk_auth_info_requested(LinphoneCore *lc, const char *realm
|
|||
gtk_label_set_markup(GTK_LABEL(label),msg);
|
||||
g_free(msg);
|
||||
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(w,"userid_entry")),username);
|
||||
info=linphone_auth_info_new(username, NULL, NULL, NULL,realm);
|
||||
linphone_auth_info_set_domain(info,domain);
|
||||
info=linphone_auth_info_new(username, NULL, NULL, NULL,realm,domain);
|
||||
g_object_set_data(G_OBJECT(w),"auth_info",info);
|
||||
g_object_weak_ref(G_OBJECT(w),(GWeakNotify)linphone_auth_info_destroy,info);
|
||||
gtk_widget_show(w);
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ static void linphone_gtk_assistant_prepare(GtkWidget *assistant, GtkWidget *page
|
|||
}
|
||||
gchar domain[128];
|
||||
g_snprintf(domain, sizeof(domain), "\"%s\"", creator->domain + 4);
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new(username, username, creator->password, NULL, domain);
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new(username, username, creator->password, NULL, NULL, domain);
|
||||
linphone_core_add_auth_info(linphone_gtk_get_core(),info);
|
||||
g_free(username);
|
||||
|
||||
|
|
|
|||
|
|
@ -481,7 +481,7 @@ void sal_op_release(SalOp *h);
|
|||
void sal_op_authenticate(SalOp *h, const SalAuthInfo *info);
|
||||
void sal_op_cancel_authentication(SalOp *h);
|
||||
void sal_op_set_user_pointer(SalOp *h, void *up);
|
||||
int sal_op_get_auth_requested(SalOp *h, const char **realm, const char **username);
|
||||
SalAuthInfo * sal_op_get_auth_requested(SalOp *h);
|
||||
const char *sal_op_get_from(const SalOp *op);
|
||||
const SalAddress *sal_op_get_from_address(const SalOp *op);
|
||||
const char *sal_op_get_to(const SalOp *op);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ void auth_info_requested(LinphoneCore *lc, const char *realm, const char *userna
|
|||
,realm);
|
||||
counters = get_stats(lc);
|
||||
counters->number_of_auth_info_requested++;
|
||||
info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain); /*create authentication structure from identity*/
|
||||
info=linphone_auth_info_new(test_username,NULL,test_password,NULL,realm,domain); /*create authentication structure from identity*/
|
||||
linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ static void register_with_refresh_base_3(LinphoneCore* lc
|
|||
if (counters->number_of_auth_info_requested>0 && linphone_proxy_config_get_state(proxy_cfg) == LinphoneRegistrationFailed && late_auth_info) {
|
||||
if (!linphone_core_get_auth_info_list(lc)) {
|
||||
CU_ASSERT_EQUAL(linphone_proxy_config_get_error(proxy_cfg),LinphoneReasonUnauthorized);
|
||||
info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain); /*create authentication structure from identity*/
|
||||
info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
|
||||
linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
|
||||
}
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ static void register_with_refresh_with_send_error() {
|
|||
int retry=0;
|
||||
LinphoneCoreManager* lcm = create_lcm_with_auth(1);
|
||||
stats* counters = &lcm->stat;
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain); /*create authentication structure from identity*/
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
|
||||
char route[256];
|
||||
sprintf(route,"sip:%s",test_route);
|
||||
linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/
|
||||
|
|
@ -228,7 +228,7 @@ static void simple_tls_register(){
|
|||
static void simple_authenticated_register(){
|
||||
stats* counters;
|
||||
LinphoneCoreManager* lcm = create_lcm();
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain); /*create authentication structure from identity*/
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
|
||||
char route[256];
|
||||
sprintf(route,"sip:%s",test_route);
|
||||
linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/
|
||||
|
|
@ -244,7 +244,7 @@ static void ha1_authenticated_register(){
|
|||
LinphoneAuthInfo *info;
|
||||
char route[256];
|
||||
sal_auth_compute_ha1(test_username,auth_domain,test_password,ha1);
|
||||
info=linphone_auth_info_new(test_username,NULL,NULL,ha1,auth_domain); /*create authentication structure from identity*/
|
||||
info=linphone_auth_info_new(test_username,NULL,NULL,ha1,auth_domain,NULL); /*create authentication structure from identity*/
|
||||
sprintf(route,"sip:%s",test_route);
|
||||
linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/
|
||||
counters = &lcm->stat;
|
||||
|
|
@ -321,7 +321,7 @@ static void authenticated_register_with_wrong_credentials(){
|
|||
LinphoneCoreManager *mgr;
|
||||
stats* counters;
|
||||
LCSipTransports transport = {5070,5070,0,5071};
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,"wrong passwd",NULL,auth_domain); /*create authentication structure from identity*/
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,"wrong passwd",NULL,auth_domain,NULL); /*create authentication structure from identity*/
|
||||
char route[256];
|
||||
|
||||
sprintf(route,"sip:%s",test_route);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue