Managing authentication: userid and passwords 管理身份验证:用户ID和密码
自定义类型
typedef struct _LinphoneAuthInfo LinphoneAuthInfo
函数
详细说明
自定义类型文档
typedef struct _LinphoneAuthInfo LinphoneAuthInfo
包含身份验证信息的对象
注意:
这对象的字段不应该被直接访问.最好使用访问器方法
大多数情况下,身份认证信息包括用户名和密码.有时,代理需要用户id,并且realm有利于区分不同的SIP域名.
一旦创建和赋值,LinphoneAuthInfo必须被添加到LinphoneCore,为了在使用的时候可见并被自动调用.使用linphone_core_add_auth_info()实现.
在应用程序需要的时候,LinphoneCore对象可以主动请求请求身份验证信息,通过LinphoneCoreVTable结构体的auth_info_requested回调函数来实现
应用程序可以回复这个消息请求,在调用linphone_core_add_auth_info().这会接通所有等待的验证事务并用认证头重试他们.
函数文档
LinphoneAuthInfo* linphone_auth_info_clone(const LinphoneAuthInfo* source)
实例化一个新的LinphoneAuthInfo对象从source
参数
[in] source 被克隆的LinphoneAuthInfo对象
返回
新创建的LinphoneAuthonInfo对象
void linphone_auth_info_destroy(LinphoneAuthInfo* obj)
销毁一个LinphoneAuthInfo对象
const char* linphone_auth_info_get_domain(const LinphoneAuthInfo* info)
获取domainc成员变量
参数
[in] info LinphoneAuthInfo对象
返回
domain
const char* linphone_auth_info_get_ha1(const LinphoneAuthInfo* info)
获取 ha1成员变量.
参数
ha1
const char* linphone_auth_info_get_realm(const LinphoneAuthInfo* info)
获取password成员变量
参数
[in] info LinphoneAuthInfo对象
返回
password成员变量
const char* linphone_auth_info_get_realm(const LinphoneAuthInfo* info)
获取realm成员变量
参数
[in] info LinphoneAuthInfo对象
返回
realm成员变量
const char* linphone_auth_info_get_userid(const LinphoneAuthInfo* info)
获取userid成员变量
参数
[in] info LinphoneAuthInfo对象
返回
userid成员变量
const char* linphone_auth_info_get_username(const LinphoneAuthInfo* info)
获取username成员变量
参数
[in] info LinphoneAuthInfo对象
返回
username成员变量
LinphoneAuthInfo* linphone_auth_info_new(const char* username,
const char* userid,
const char* passwd,
const char* ha1,
const char* realm,
const char* domain)
创建一个LinphoneAuthInfo对象.这个对象可以是空的,所有的参数都设置被NULL.Username,userid,password,realm和domain可以以后再用特定的方法设置.最后,username和passwd(或者ha1)是必需的
参数
username 用户名需要进行身份验证
userid 用于身份验证的用户id(如果你不知道是什么,用NULL)
passwd 明文密码
ha1 ha1加密过的密码,如果没有给出明文密码
realm 认证域名(可大于sip域名)不幸的是许多SIP服务器不使用这个参数
domain 关于这个身份验证信息的有效的SIP域名.如果他必须被限制为一个SIP域
返回
一个LinphoneAuthInfo对象.linphone_auth_info_destroy()必须被用来销毁它,当它不再需要时.LinphoneCore复制LinphoneAuthInfo通过linphone_core_add_auth_info().
void linphone_auth_info_set_domain(LinphoneAuthInfo* info, const char* domain)
为LinphoneAuthInfo对象设置domain成员变量
参数
[in] LinphoneAuthInfo对象
[in] domain 这应该不是必要的,因为realm被提供唯一的和充分的.然而,许多SIO服务器不正确地设置realm,那么domain必须被用来区分多个同username的SIP账户
void linphone_auth_info_set_ha1(LinphoneAuthInfo* info, const char* ha1)
设置ha1成员变量
参数
[in] info LinphoneAuthInfo对象
[in] ha1 ha1
void linphone_auth_info_set_passwd(LinphoneAuthInfo* info, const char* passwd)
设置password成员变量
参数
[in] info LinphoneAuthInfo对象
[in] passwd password
void linphone_auth_info_set_realm(LinphoneAuthInfo* info, const char* realm)
设置realm成员变量
参数
[in] info LinphoneAuthInfo对象
[in] realm realm
void linphone_auth_info_set_username(LinphoneAuthInfo* info, const char* username)
设置username成员变量
参数
[in] info LinphoneAuthInfo对象
[in] username username
void linphone_core_abort_authtication(LinphoneCore* lc, LinphoneAuthInfo* info)
这个方法被用来中止一个用户的身份验证请求(由LinphoneCore发起的 LinphoneCoreVTable的auth_info_requested回调函数)
void linphone_core_add_auth_info(LinphoneCore* lc, const LinphonAuthInfo* info)
添加身份验证信息到LinphoneCore
这个信息会被用于所有需要身份验证的SIP事务
void linphone_core_clear_all_auth_info(LinphoneCore* lc)
清除所有身份验证信息
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)
用LinphoneCore的默认值来创建一个身份验证信息对象
参见
[in] lc LinphonCore对象
[in] username 包含身份验证凭证username部分的字符串
[in] userid (可选)
[in] passwd 包含身份验证凭证password的字符串(可选,password和ha1之间必须设置一个)
[in] ha1 包含password的ha1哈希值的字符串(可选,password和ha1之间必须设置一个)
[in] realm 用于区分不同的SIP身份验证domain的字符串(可选)
[in] domain 有效的身份验证的SIP domain,如果它必须被限制为一个SIP domain.
返回
设置默认值的LinphoneAuthInfo
const LinphoneAuthInfo* linphone_core_find_auth_info(Linphone* lc, const char* realm, const char* username, const char* sip_domain)
找到与realm,username,domain匹配的身份验证信息.首先,(realm,username)对被搜索.如果多个结果(这应该不会发生因为realm是唯一的),然后domain被添加到搜索参数中.
参数
lc LinphoneCore对象
real 身份验证信息的'realm'(可选)
username SIP username用于身份验证的(强制的)
sip_domain SIP domain名字(可选)
返回
一个 LinphoneAuthInfo对象
const bctbx_list_t* linphone_core_get_auth_info_list(const LinphoneCore* lc)
返回一个关于目前已登记的LinphoneAuthonInfo的不可变列表
参数
[in] lc LinphoneCore对象
返回
LinphoneAuthInfo对象列表
void linphone_core_remove_auth_info(LinphoneCore* lc, const LinphoneAuthInfo* info)
删除一个身份验证信息对象