mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-06 21:33:08 +00:00
Fix authInfo research + allow multiples authInfos with same username/password (with different domains) in linphonerc
This commit is contained in:
parent
50f9d35804
commit
120fbea39e
4 changed files with 21 additions and 17 deletions
|
|
@ -37,13 +37,14 @@
|
|||
* 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.
|
||||
**/
|
||||
LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *userid, const char *passwd, const char *ha1,const char *realm){
|
||||
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);
|
||||
if (username!=NULL && (strlen(username)>0) ) obj->username=ms_strdup(username);
|
||||
if (userid!=NULL && (strlen(userid)>0)) obj->userid=ms_strdup(userid);
|
||||
if (passwd!=NULL && (strlen(passwd)>0)) obj->passwd=ms_strdup(passwd);
|
||||
if (ha1!=NULL && (strlen(ha1)>0)) obj->ha1=ms_strdup(ha1);
|
||||
if (realm!=NULL && (strlen(realm)>0)) obj->realm=ms_strdup(realm);
|
||||
if (domain!=NULL && (strlen(domain)>0)) obj->domain=ms_strdup(domain);
|
||||
obj->works=FALSE;
|
||||
return obj;
|
||||
}
|
||||
|
|
@ -221,8 +222,7 @@ LinphoneAuthInfo *linphone_auth_info_new_from_config_file(LpConfig * config, int
|
|||
ha1=lp_config_get_string(config,key,"ha1",NULL);
|
||||
realm=lp_config_get_string(config,key,"realm",NULL);
|
||||
domain=lp_config_get_string(config,key,"domain",NULL);
|
||||
ret=linphone_auth_info_new(username,userid,passwd,ha1,realm);
|
||||
linphone_auth_info_set_domain(ret,domain);
|
||||
ret=linphone_auth_info_new(username,userid,passwd,ha1,realm,domain);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -264,7 +264,7 @@ static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *user
|
|||
&& pinfo->domain && strcmp(domain,pinfo->domain)==0){
|
||||
return pinfo;
|
||||
}
|
||||
}else if (realm){
|
||||
} else if (realm){
|
||||
if (pinfo->realm && realm_match(realm,pinfo->realm)){
|
||||
if (ret!=NULL){
|
||||
ms_warning("Non unique realm found for %s",username);
|
||||
|
|
@ -272,7 +272,9 @@ static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *user
|
|||
}
|
||||
ret=pinfo;
|
||||
}
|
||||
}else return pinfo;
|
||||
} else if (domain && pinfo->domain && strcmp(domain,pinfo->domain)==0){
|
||||
return pinfo;
|
||||
} else return pinfo;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
|
@ -289,13 +291,15 @@ static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *user
|
|||
**/
|
||||
const LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username, const char *domain){
|
||||
const LinphoneAuthInfo *ai=NULL;
|
||||
if (realm){
|
||||
ai=find_auth_info(lc,username,realm,NULL);
|
||||
if (ai==NULL && domain){
|
||||
ai=find_auth_info(lc,username,realm,domain);
|
||||
|
||||
if (domain){
|
||||
ai=find_auth_info(lc,username,realm,domain);
|
||||
if (ai==NULL){
|
||||
ai=find_auth_info(lc,username,NULL,domain);
|
||||
}
|
||||
}
|
||||
if (ai==NULL && realm) {
|
||||
ai=find_auth_info(lc,username,realm,NULL);
|
||||
}
|
||||
if (ai==NULL){
|
||||
ai=find_auth_info(lc,username,NULL,NULL);
|
||||
}
|
||||
|
|
@ -314,8 +318,8 @@ static void write_auth_infos(LinphoneCore *lc){
|
|||
linphone_auth_info_write_config(lc->config,NULL,i); /* mark the end */
|
||||
}
|
||||
|
||||
LinphoneAuthInfo * linphone_core_create_auth_info(LinphoneCore *lc, const char *username, const char *userid, const char *passwd, const char *ha1, const char *realm) {
|
||||
return linphone_auth_info_new(username, userid, passwd, ha1, realm);
|
||||
LinphoneAuthInfo * linphone_core_create_auth_info(LinphoneCore *lc, const char *username, const char *userid, const char *passwd, const char *ha1, const char *realm, const char *domain) {
|
||||
return linphone_auth_info_new(username, userid, passwd, ha1, realm, domain);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -331,7 +335,7 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info)
|
|||
|
||||
/* 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){
|
||||
if (ai!=NULL && ai->domain && strcmp(ai->domain, info->domain)==0){
|
||||
lc->auth_info=ms_list_remove(lc->auth_info,ai);
|
||||
linphone_auth_info_destroy(ai);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -851,7 +851,7 @@ struct _LinphoneAuthInfo;
|
|||
typedef struct _LinphoneAuthInfo LinphoneAuthInfo;
|
||||
|
||||
LINPHONE_PUBLIC LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *userid,
|
||||
const char *passwd, const char *ha1,const char *realm);
|
||||
const char *passwd, const char *ha1,const char *realm, const char *domain);
|
||||
LINPHONE_PUBLIC void linphone_auth_info_set_passwd(LinphoneAuthInfo *info, const char *passwd);
|
||||
LINPHONE_PUBLIC void linphone_auth_info_set_username(LinphoneAuthInfo *info, const char *username);
|
||||
LINPHONE_PUBLIC void linphone_auth_info_set_userid(LinphoneAuthInfo *info, const char *userid);
|
||||
|
|
@ -1436,7 +1436,7 @@ LINPHONE_PUBLIC int linphone_core_get_default_proxy(LinphoneCore *lc, LinphonePr
|
|||
* @return #LinphoneAuthInfo with default values set
|
||||
* @ingroup authentication
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneAuthInfo * linphone_core_create_auth_info(LinphoneCore *lc, const char *username, const char *userid, const char *passwd, const char *ha1, const char *realm);
|
||||
LINPHONE_PUBLIC LinphoneAuthInfo * linphone_core_create_auth_info(LinphoneCore *lc, const char *username, const char *userid, const char *passwd, const char *ha1, const char *realm, const char *domain);
|
||||
|
||||
LINPHONE_PUBLIC void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info);
|
||||
|
||||
|
|
|
|||
|
|
@ -1506,7 +1506,7 @@ extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_getError(JNIEnv*
|
|||
|
||||
extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
|
||||
, jobject thiz ) {
|
||||
return (jlong)linphone_auth_info_new(NULL,NULL,NULL,NULL,NULL);
|
||||
return (jlong)linphone_auth_info_new(NULL,NULL,NULL,NULL,NULL,NULL);
|
||||
}
|
||||
extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
|
||||
, jobject thiz
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ static int sip_login_do_login(SipSetupContext * ctx, const char *uri, const char
|
|||
tmp=linphone_address_as_string(parsed_uri);
|
||||
linphone_proxy_config_set_identity(cfg,tmp);
|
||||
if (passwd ) {
|
||||
auth=linphone_auth_info_new(linphone_address_get_username(parsed_uri),NULL,passwd,NULL,NULL);
|
||||
auth=linphone_auth_info_new(linphone_address_get_username(parsed_uri),NULL,passwd,NULL,NULL,NULL);
|
||||
linphone_core_add_auth_info(lc,auth);
|
||||
}
|
||||
linphone_proxy_config_enable_register(cfg,TRUE);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue