proxy.c: add new linphone_proxy_config_find_auth_info API

parent 42604099
......@@ -142,8 +142,8 @@ void linphone_auth_info_write_config(LpConfig *config, LinphoneAuthInfo *obj, in
{
char key[50];
bool_t store_ha1_passwd = lp_config_get_int(config, "sip", "store_ha1_passwd", 1);
sprintf(key,"auth_info_%i",pos);
lp_config_clean_section(config,key);
......@@ -275,18 +275,10 @@ const LinphoneAuthInfo *_linphone_core_find_auth_info(LinphoneCore *lc, const ch
if (ai==NULL){
ai=find_auth_info(lc,username,NULL,NULL, ignore_realm);
}
/*if (ai) ms_message("linphone_core_find_auth_info(): returning auth info username=%s, realm=%s", ai->username, ai->realm);*/
if (ai) ms_message("linphone_core_find_auth_info(): returning auth info username=%s, realm=%s", ai->username, ai->realm);
return ai;
}
/**
* Find authentication info matching realm, username, domain criteria.
* First of all, (realm,username) pair are searched. If multiple results (which should not happen because realm are supposed to be unique), then domain is added to the search.
* @param lc the LinphoneCore
* @param realm the authentication 'realm' (optional)
* @param username the SIP username to be authenticated (mandatory)
* @param domain the SIP domain name (optional)
* @return a #LinphoneAuthInfo
**/
const LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username, const char *domain){
return _linphone_core_find_auth_info(lc, realm, username, domain, TRUE);
}
......@@ -295,9 +287,9 @@ const LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const cha
void linphone_core_write_auth_info(LinphoneCore *lc, LinphoneAuthInfo *ai){
int i;
MSList *elem = lc->auth_info;
if (!lc->sip_conf.save_auth_info) return;
for (i=0; elem != NULL; elem = elem->next, i++){
if (ai == elem->data){
linphone_auth_info_write_config(lc->config, ai, i);
......
......@@ -521,6 +521,13 @@ LINPHONE_PUBLIC const char *linphone_proxy_config_get_custom_header(LinphoneProx
**/
LINPHONE_PUBLIC void linphone_proxy_config_set_custom_header(LinphoneProxyConfig *cfg, const char *header_name, const char *header_value);
/**
* Find authentication info matching proxy config, if any, similarly to linphone_core_find_auth_info.
* @param[in] cfg #LinphoneProxyConfig object.
* @return a #LinphoneAuthInfo matching proxy config criteria if possible, NULL if nothing can be found.
**/
LINPHONE_PUBLIC const struct _LinphoneAuthInfo* linphone_proxy_config_find_auth_info(const LinphoneProxyConfig *cfg);
/**
* @}
*/
......
......@@ -47,6 +47,9 @@ extern "C" {
struct _LinphoneCore;
struct _LinphoneChatRoom;
struct _LinphoneAuthInfo;
struct _SipSetupContext;
struct _LinphoneInfoMessage;
/**
* Linphone core main object created by function linphone_core_new() .
......@@ -442,10 +445,6 @@ LINPHONE_PUBLIC void linphone_address_destroy(LinphoneAddress *u);
*/
LINPHONE_PUBLIC LinphoneAddress * linphone_core_create_address(LinphoneCore *lc, const char *address);
struct _SipSetupContext;
struct _LinphoneInfoMessage;
/**
* The LinphoneInfoMessage is an object representing an informational message sent or received by the core.
**/
......@@ -1022,8 +1021,6 @@ LINPHONE_PUBLIC const char *linphone_registration_state_to_string(LinphoneRegist
#include "linphone_proxy_config.h"
struct _LinphoneAuthInfo;
/**
* @addtogroup authentication
* @{
......@@ -2900,6 +2897,15 @@ LINPHONE_PUBLIC void linphone_core_remove_auth_info(LinphoneCore *lc, const Linp
LINPHONE_PUBLIC const MSList *linphone_core_get_auth_info_list(const LinphoneCore *lc);
/**
* Find authentication info matching realm, username, domain criteria.
* First of all, (realm,username) pair are searched. If multiple results (which should not happen because realm are supposed to be unique), then domain is added to the search.
* @param lc the LinphoneCore
* @param realm the authentication 'realm' (optional)
* @param username the SIP username to be authenticated (mandatory)
* @param domain the SIP domain name (optional)
* @return a #LinphoneAuthInfo
**/
LINPHONE_PUBLIC const LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username, const char *sip_domain);
LINPHONE_PUBLIC void linphone_core_abort_authentication(LinphoneCore *lc, LinphoneAuthInfo *info);
......
......@@ -1548,3 +1548,9 @@ uint8_t linphone_proxy_config_get_avpf_rr_interval(const LinphoneProxyConfig *cf
const LinphoneAddress* linphone_proxy_config_get_contact(const LinphoneProxyConfig *cfg) {
return sal_op_get_contact_address(cfg->op);
}
const struct _LinphoneAuthInfo* linphone_proxy_config_find_auth_info(const LinphoneProxyConfig *cfg) {
const char* username = cfg->identity_address ? linphone_address_get_username(cfg->identity_address) : NULL;
const char* domain = cfg->identity_address ? linphone_address_get_domain(cfg->identity_address) : NULL;
return _linphone_core_find_auth_info(cfg->lc, cfg->realm, username, domain, TRUE);
}
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