Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
0a4ac2c2
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
0a4ac2c2
编写于
5月 27, 2023
作者:
O
openharmony_ci
提交者:
Gitee
5月 27, 2023
浏览文件
操作
浏览文件
下载
差异文件
!18188 UserIAM V1_1 HDI 检视
Merge pull request !18188 from Tianshi Liu/tianshi_dev
上级
940bb5b9
7e47a55d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
336 addition
and
174 deletion
+336
-174
zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md
zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md
+90
-39
zh-cn/device-dev/driver/driver-peripherals-fingerprint_auth-des.md
...ice-dev/driver/driver-peripherals-fingerprint_auth-des.md
+79
-38
zh-cn/device-dev/driver/driver-peripherals-pinauth-des.md
zh-cn/device-dev/driver/driver-peripherals-pinauth-des.md
+97
-53
zh-cn/device-dev/driver/driver-peripherals-user-auth-des.md
zh-cn/device-dev/driver/driver-peripherals-user-auth-des.md
+70
-44
未找到文件。
zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md
浏览文件 @
0a4ac2c2
...
...
@@ -90,7 +90,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
### 接口说明
注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/face_auth
/v1_0/
)。
注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/face_auth)。
在本文中,人脸凭据的录入、认证、识别和删除相关的HDI接口如表1所示,表2中的回调函数分别用于人脸执行器返回操作结果给框架和返回操作过程中的提示信息给上层应用。
...
...
@@ -98,23 +98,29 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
| 接口名称 | 功能介绍 |
| ----------------------------------- | ---------------------------------- |
| GetExecutorList(std::vector
<sptr
<
IExecutor
>
>& executorList) | 获取执行器列表。 |
| GetExecutorList(std::vector
\<
sptr
\<
V1_0::IExecutor>>& executorList) | 获取V1_0版本执行器列表。 |
| GetExecutorListV1_1(std::vector
\<
sptr
\<
V1_1::IExecutor>>& executorList) | 获取V1_1版本执行器列表。 |
| GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息,包括执行器类型、执行器角色、认证类型、安全等级、执行器公钥等信息,用于向用户认证框架注册执行器。 |
| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定人脸模板ID的模板信息。 |
| OnRegisterFinish(const std::vector
<uint64_t>
& templateIdList,
<br/>
const std::vector
<uint8_t>
& frameworkPublicKey, const std::vector
<uint8_t>
& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的人脸模板列表用于对账。 |
| Enroll(uint64_t scheduleId, const std::vector
<uint8_t>
& extraInfo,
<br/>
const sptr
<IExecutorCallback>
& callbackObj) | 录入人脸模板。 |
| Authenticate(uint64_t scheduleId, const std::vector
<uint64_t>
& templateIdList,
<br/>
const std::vector
<uint8_t>
& extraInfo, const sptr
<IExecutorCallback>
& callbackObj) | 认证人脸模板。 |
| Identify(uint64_t scheduleId, const std::vector
<uint8_t>
& extraInfo,
<br/>
const sptr
<IExecutorCallback>
& callbackObj) | 识别人脸模板。 |
| Delete(const std::vector
<uint64_t>
& templateIdList) | 删除人脸模板。 |
| OnRegisterFinish(const std::vector
\<
uint64_t>& templateIdList,
<br/>
const std::vector
\<
uint8_t>& frameworkPublicKey, const std::vector
\
<
uint8_t>& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的人脸模板列表用于对账。 |
| Enroll(uint64_t scheduleId, const std::vector
\<
uint8_t>& extraInfo,
<br/>
const sptr
\
<
IExecutorCallback>& callbackObj) | 录入人脸模板。 |
| Authenticate(uint64_t scheduleId, const std::vector
\<
uint64_t>& templateIdList,
<br/>
const std::vector
\<
uint8_t>& extraInfo, const sptr
\
<
IExecutorCallback>& callbackObj) | 认证人脸模板。 |
| Identify(uint64_t scheduleId, const std::vector
\<
uint8_t>& extraInfo,
<br/>
const sptr
\
<
IExecutorCallback>& callbackObj) | 识别人脸模板。 |
| Delete(const std::vector
\
<
uint64_t>& templateIdList) | 删除人脸模板。 |
| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定录入、认证、识别操作。 |
| SendCommand(int32_t commandId, const std::vector
<uint8_t>
& extraInfo,
<br/>
const sptr
<IExecutorCallback>
& callbackObj) | 人脸认证服务向Face_auth驱动传递参数的通用接口。 |
| SendCommand(int32_t commandId, const std::vector
\<
uint8_t>& extraInfo,
<br/>
const sptr
\<
IExecutorCallback>& callbackObj) | 人脸认证服务向Face_auth驱动传递参数的通用接口。 |
| SetBufferProducer(const sptr
\<
BufferProducerSequenceable> &bufferProducer) | 设置预览流缓冲区。 |
| GetProperty(const std::vector
\<
uint64_t>& templateIdList,
<br/>
const std::vector
\<
GetPropertyType>& propertyTypes, Property& property) | 获取执行器属性信息。 |
| SetCachedTemplates(const std::vector
\<
uint64_t> &templateIdList) | 设置需缓存模板列表。 |
| RegisterSaCommandCallback(const sptr
\<
ISaCommandCallback> &callbackObj) | 注册SA命令回调。 |
**表2**
回调函数介绍
| 接口名称 | 功能介绍 |
| ------------------------------------------------------------ | ------------------------ |
| IExecutorCallback::OnResult(int32_t code, const std::vector
<uint8_t>
& extraInfo) | 返回操作的最终结果。 |
| IExecutorCallback::OnTip(int32_t code, const std::vector
<uint8_t>
& extraInfo) | 返回操作的过程交互信息。 |
| IExecutorCallback::OnResult(int32_t code, const std::vector
\<
uint8_t>& extraInfo) | 返回操作的最终结果。 |
| IExecutorCallback::OnTip(int32_t code, const std::vector
\<
uint8_t>& extraInfo) | 返回操作的过程交互信息。 |
| ISaCommandCallback::OnSaCommands(const std::vector
\<
SaCommand>& commands) | 发送命令列表。 |
### 开发步骤
...
...
@@ -143,7 +149,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
struct
IDeviceIoService
ioService
;
OHOS
::
sptr
<
OHOS
::
IRemoteObject
>
stub
;
};
// 服务接口调用响应接口
static
int32_t
FaceAuthInterfaceDriverDispatch
(
struct
HdfDeviceIoClient
*
client
,
int
cmdId
,
struct
HdfSBuf
*
data
,
struct
HdfSBuf
*
reply
)
...
...
@@ -151,11 +157,11 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
IAM_LOGI
(
"start"
);
auto
*
hdfFaceAuthInterfaceHost
=
CONTAINER_OF
(
client
->
device
->
service
,
struct
HdfFaceAuthInterfaceHost
,
ioService
);
OHOS
::
MessageParcel
*
dataParcel
=
nullptr
;
OHOS
::
MessageParcel
*
replyParcel
=
nullptr
;
OHOS
::
MessageOption
option
;
if
(
SbufToParcel
(
data
,
&
dataParcel
)
!=
HDF_SUCCESS
)
{
IAM_LOGE
(
"%{public}s:invalid data sbuf object to dispatch"
,
__func__
);
return
HDF_ERR_INVALID_PARAM
;
...
...
@@ -164,10 +170,10 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
IAM_LOGE
(
"%{public}s:invalid reply sbuf object to dispatch"
,
__func__
);
return
HDF_ERR_INVALID_PARAM
;
}
return
hdfFaceAuthInterfaceHost
->
stub
->
SendRequest
(
cmdId
,
*
dataParcel
,
*
replyParcel
,
option
);
}
// 初始化接口
int
HdfFaceAuthInterfaceDriverInit
(
struct
HdfDeviceObject
*
deviceObject
)
{
...
...
@@ -178,7 +184,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
}
return
HDF_SUCCESS
;
}
// Face_auth驱动对外提供的服务绑定到HDF框架
int
HdfFaceAuthInterfaceDriverBind
(
struct
HdfDeviceObject
*
deviceObject
)
{
...
...
@@ -188,29 +194,29 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
IAM_LOGE
(
"%{public}s: failed to create HdfFaceAuthInterfaceHost object"
,
__func__
);
return
HDF_FAILURE
;
}
hdfFaceAuthInterfaceHost
->
ioService
.
Dispatch
=
FaceAuthInterfaceDriverDispatch
;
hdfFaceAuthInterfaceHost
->
ioService
.
Open
=
NULL
;
hdfFaceAuthInterfaceHost
->
ioService
.
Release
=
NULL
;
auto
serviceImpl
=
IFaceAuthInterface
::
Get
(
true
);
if
(
serviceImpl
==
nullptr
)
{
IAM_LOGE
(
"%{public}s: failed to implement service"
,
__func__
);
return
HDF_FAILURE
;
}
hdfFaceAuthInterfaceHost
->
stub
=
OHOS
::
HDI
::
ObjectCollector
::
GetInstance
().
GetOrNewObject
(
serviceImpl
,
IFaceAuthInterface
::
GetDescriptor
());
if
(
hdfFaceAuthInterfaceHost
->
stub
==
nullptr
)
{
IAM_LOGE
(
"%{public}s: failed to get stub object"
,
__func__
);
return
HDF_FAILURE
;
}
deviceObject
->
service
=
&
hdfFaceAuthInterfaceHost
->
ioService
;
IAM_LOGI
(
"success"
);
return
HDF_SUCCESS
;
}
// 释放Face_auth驱动中的资源
void
HdfFaceAuthInterfaceDriverRelease
(
struct
HdfDeviceObject
*
deviceObject
)
{
...
...
@@ -220,7 +226,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
delete
hdfFaceAuthInterfaceHost
;
IAM_LOGI
(
"success"
);
}
// 注册Face_auth驱动入口数据结构体对象
struct
HdfDriverEntry
g_faceAuthInterfaceDriverEntry
=
{
.
moduleVersion
=
1
,
...
...
@@ -229,7 +235,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
.
Init
=
HdfFaceAuthInterfaceDriverInit
,
.
Release
=
HdfFaceAuthInterfaceDriverRelease
,
};
// 调用HDF_INIT将驱动入口注册到HDF框架中。在加载驱动时HDF框架会先调用Bind函数,再调用Init函数加载该驱动。当Init调用异常时,HDF框架会调用Release释放驱动资源并退出
HDF_INIT
(
g_faceAuthInterfaceDriverEntry
);
```
...
...
@@ -238,19 +244,19 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
```
c++
// 执行器实现类
class
ExecutorImpl
:
public
IExecutor
{
class
ExecutorImpl
:
public
V1_1
::
IExecutor
{
public:
ExecutorImpl
(
struct
ExecutorInfo
executorInfo
);
virtual
~
ExecutorImpl
()
{}
private:
struct
ExecutorInfo
executorInfo_
;
// 执行器信息
};
static
constexpr
uint16_t
SENSOR_ID
=
123
;
// 执行器sensorID
static
constexpr
uint32_t
EXECUTOR_TYPE
=
123
;
// 执行器类型
static
constexpr
size_t
PUBLIC_KEY_LEN
=
32
;
// 执行器32字节公钥
// 创建HDI服务对象
extern
"C"
IFaceAuthInterface
*
FaceAuthInterfaceImplGetInstance
(
void
)
{
...
...
@@ -261,9 +267,9 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
}
return
faceAuthInterfaceService
;
}
// 获取执行器列表实现,创建执行器
int32_t
GetExecutorList
(
std
::
vector
<
sptr
<
IExecutor
>>&
executorList
)
int32_t
GetExecutorList
V1_1
(
std
::
vector
<
sptr
<
V1_1
::
IExecutor
>>&
executorList
)
{
IAM_LOGI
(
"interface mock start"
);
executorList
.
clear
();
...
...
@@ -281,10 +287,21 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
IAM_LOGE
(
"executor is nullptr"
);
return
HDF_FAILURE
;
}
executorList
.
push_back
(
sptr
<
IExecutor
>
(
executor
));
executorList
.
push_back
(
sptr
<
V1_1
::
IExecutor
>
(
executor
));
IAM_LOGI
(
"interface mock success"
);
return
HDF_SUCCESS
;
}
// 获取V1_0执行器列表实现,使用V1_1版本执行器实现V1_0版本执行器的功能
int32_t
GetExecutorList
(
std
::
vector
<
sptr
<
V1_0
::
IExecutor
>>
&
executorList
)
{
std
::
vector
<
sptr
<
V1_1
::
IExecutor
>>
executorListV1_1
;
int32_t
result
=
GetExecutorListV1_1
(
executorListV1_1
);
for
(
auto
&
executor
:
executorListV1_1
)
{
executorList
.
push_back
(
executor
);
}
return
result
;
}
```
3.
实现执行器每个功能接口,详细代码参见
[
executor_impl.cpp
](
https://gitee.com/openharmony/drivers_peripheral/blob/master/face_auth/hdi_service/src/executor_impl.cpp
)
文件。
...
...
@@ -298,7 +315,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
IAM_LOGI
(
"get executor information success"
);
return
HDF_SUCCESS
;
}
// 实现获取指定模板ID的模板信息接口
int32_t
GetTemplateInfo
(
uint64_t
templateId
,
TemplateInfo
&
info
)
{
...
...
@@ -308,7 +325,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
IAM_LOGI
(
"get template information success"
);
return
HDF_SUCCESS
;
}
// 实现执行器注册成功后,获取用户认证框架的公钥信息、获取用户认证框架的模板列表接口。将公钥信息保持,模板列表用于和本地的模板做对账
int32_t
OnRegisterFinish
(
const
std
::
vector
<
uint64_t
>&
templateIdList
,
const
std
::
vector
<
uint8_t
>&
frameworkPublicKey
,
const
std
::
vector
<
uint8_t
>&
extraInfo
)
...
...
@@ -320,7 +337,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
IAM_LOGI
(
"register finish"
);
return
HDF_SUCCESS
;
}
// 实现人脸录入接口
int32_t
Enroll
(
uint64_t
scheduleId
,
const
std
::
vector
<
uint8_t
>&
extraInfo
,
const
sptr
<
IExecutorCallback
>&
callbackObj
)
...
...
@@ -336,7 +353,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
}
return
HDF_SUCCESS
;
}
// 实现人脸认证接口
int32_t
Authenticate
(
uint64_t
scheduleId
,
const
std
::
vector
<
uint64_t
>&
templateIdList
,
const
std
::
vector
<
uint8_t
>&
extraInfo
,
const
sptr
<
IExecutorCallback
>&
callbackObj
)
...
...
@@ -353,7 +370,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
}
return
HDF_SUCCESS
;
}
// 实现人脸识别接口
int32_t
Identify
(
uint64_t
scheduleId
,
const
std
::
vector
<
uint8_t
>&
extraInfo
,
const
sptr
<
IExecutorCallback
>&
callbackObj
)
...
...
@@ -369,7 +386,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
}
return
HDF_SUCCESS
;
}
// 实现删除人脸模板接口
int32_t
Delete
(
const
std
::
vector
<
uint64_t
>&
templateIdList
)
{
...
...
@@ -378,7 +395,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
IAM_LOGI
(
"delete success"
);
return
HDF_SUCCESS
;
}
// 实现通过scheduleId取消指定操作接口
int32_t
Cancel
(
uint64_t
scheduleId
)
{
...
...
@@ -387,7 +404,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
IAM_LOGI
(
"cancel success"
);
return
HDF_SUCCESS
;
}
// 实现人脸认证服务向Face_auth驱动传递参数的通用接口,当前需要实现冻结与解锁模板命令
int32_t
SendCommand
(
int32_t
commandId
,
const
std
::
vector
<
uint8_t
>&
extraInfo
,
const
sptr
<
IExecutorCallback
>&
callbackObj
)
...
...
@@ -422,8 +439,42 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
}
return
HDF_SUCCESS
;
}
// 实现设置预览流缓冲区接口
int32_t
ExecutorImpl
::
SetBufferProducer
(
const
sptr
<
BufferProducerSequenceable
>
&
bufferProducer
)
{
IAM_LOGI
(
"interface mock start set buffer producer %{public}s"
,
UserIam
::
Common
::
GetPointerNullStateString
(
bufferProducer
.
GetRefPtr
()).
c_str
());
return
HDF_SUCCESS
;
}
// 实现获取执行器属性接口
int32_t
ExecutorImpl
::
GetProperty
(
const
std
::
vector
<
uint64_t
>
&
templateIdList
,
const
std
::
vector
<
GetPropertyType
>
&
propertyTypes
,
Property
&
property
)
{
IAM_LOGI
(
"interface mock start"
);
property
=
{};
IAM_LOGI
(
"get property success"
);
return
HDF_SUCCESS
;
}
// 实现设置需缓存模板列表接口
int32_t
ExecutorImpl
::
SetCachedTemplates
(
const
std
::
vector
<
uint64_t
>
&
templateIdList
)
{
IAM_LOGI
(
"interface mock start"
);
IAM_LOGI
(
"set cached templates success"
);
return
HDF_SUCCESS
;
}
// 实现注册SA命令回调接口
int32_t
ExecutorImpl
::
RegisterSaCommandCallback
(
const
sptr
<
ISaCommandCallback
>
&
callbackObj
)
{
IAM_LOGI
(
"interface mock start"
);
IAM_LOGI
(
"register sa command callback success"
);
return
HDF_SUCCESS
;
}
```
4.
用户身份认证框架支持多driver,当增加driver或者修改driver信息,需要修改如下文件中serviceName2Config。
```
c++
...
...
zh-cn/device-dev/driver/driver-peripherals-fingerprint_auth-des.md
浏览文件 @
0a4ac2c2
...
...
@@ -95,23 +95,27 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
| 接口名称 | 功能介绍 |
| -------------------------------- | ----------------------------------- |
| GetExecutorList(std::vector
<sptr
<
IExecutor
>
>& executorList) | 获取执行器列表。 |
| GetExecutorList(std::vector
\<
sptr
\<
V1_0::IExecutor>>& executorList) | 获取V1_0版本执行器列表。 |
| GetExecutorListV1_1(std::vector
\<
sptr
\<
V1_1::IExecutor>>& executorList) | 获取V1_1版本执行器列表。 |
| GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息,包括执行器类型、执行器角色、认证类型、安全等级、执行器公钥等信息,用于向用户认证框架注册执行器。 |
| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定模板ID的模板信息。 |
| OnRegisterFinish(const std::vector
<uint64_t>
& templateIdList,
<br/>
const std::vector
<uint8_t>
& frameworkPublicKey, const std::vector
<uint8_t>
& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的模板列表用于对账。 |
| Enroll(uint64_t scheduleId, const std::vector
<uint8_t>
& extraInfo,
<br/>
const sptr
<IExecutorCallback>
& callbackObj) | 录入指纹模板。 |
| Authenticate(uint64_t scheduleId, const std::vector
<uint64_t>
& templateIdList,
<br/>
const std::vector
<uint8_t>
& extraInfo, const sptr
<IExecutorCallback>
& callbackObj) | 认证指纹模板。 |
| Identify(uint64_t scheduleId, const std::vector
<uint8_t>
& extraInfo,
<br/>
const sptr
<IExecutorCallback>
& callbackObj) | 识别指纹模板。 |
| Delete(const std::vector
<uint64_t>
& templateIdList) | 删除指纹模板。 |
| OnRegisterFinish(const std::vector
\<
uint64_t>& templateIdList,
<br/>
const std::vector
\<
uint8_t>& frameworkPublicKey, const std::vector
\
<
uint8_t>& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的模板列表用于对账。 |
| Enroll(uint64_t scheduleId, const std::vector
\<
uint8_t>& extraInfo,
<br/>
const sptr
\
<
IExecutorCallback>& callbackObj) | 录入指纹模板。 |
| Authenticate(uint64_t scheduleId, const std::vector
\<
uint64_t>& templateIdList,
<br/>
const std::vector
\<
uint8_t>& extraInfo, const sptr
\
<
IExecutorCallback>& callbackObj) | 认证指纹模板。 |
| Identify(uint64_t scheduleId, const std::vector
\<
uint8_t>& extraInfo,
<br/>
const sptr
\
<
IExecutorCallback>& callbackObj) | 识别指纹模板。 |
| Delete(const std::vector
\
<
uint64_t>& templateIdList) | 删除指纹模板。 |
| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定录入、认证、识别操作。 |
| SendCommand(int32_t commandId, const std::vector
<uint8_t>
& extraInfo,
<br/>
const sptr
<IExecutorCallback>
& callbackObj) | 指纹认证服务向Fingerprint_auth驱动传递参数的通用接口。 |
| SendCommand(int32_t commandId, const std::vector
\<
uint8_t>& extraInfo,
<br/>
const sptr
\<
IExecutorCallback>& callbackObj) | 指纹认证服务向Fingerprint_auth驱动传递参数的通用接口。 |
| GetProperty(const std::vector
\<
uint64_t>& templateIdList,
<br/>
const std::vector
\<
GetPropertyType>& propertyTypes, Property& property) | 获取执行器属性信息。 |
| SetCachedTemplates(const std::vector
\<
uint64_t> &templateIdList) | 设置需缓存模板列表。 |
| RegisterSaCommandCallback(const sptr
\<
ISaCommandCallback> &callbackObj) | 注册SA命令回调。 |
**表2**
回调函数介绍
| 接口名称 | 功能介绍 |
| ------------------------------------------------------------ | ------------------------ |
| IExecutorCallback::OnResult(int32_t code, const std::vector
<uint8_t>
& extraInfo) | 返回操作的最终结果。 |
| IExecutorCallback::OnTip(int32_t code, const std::vector
<uint8_t>
& extraInfo) | 返回操作的过程交互信息。 |
| IExecutorCallback::OnResult(int32_t code, const std::vector
\<
uint8_t>& extraInfo) | 返回操作的最终结果。 |
| IExecutorCallback::OnTip(int32_t code, const std::vector
\<
uint8_t>& extraInfo) | 返回操作的过程交互信息。 |
| ISaCommandCallback::OnSaCommands(const std::vector
\<
SaCommand>& commands) | 发送命令列表。 |
### 开发步骤
...
...
@@ -140,7 +144,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
struct
IDeviceIoService
ioService
;
OHOS
::
sptr
<
OHOS
::
IRemoteObject
>
stub
;
};
// 服务接口调用响应接口
static
int32_t
FingerprintAuthInterfaceDriverDispatch
(
struct
HdfDeviceIoClient
*
client
,
int
cmdId
,
struct
HdfSBuf
*
data
,
struct
HdfSBuf
*
reply
)
...
...
@@ -148,11 +152,11 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
IAM_LOGI
(
"start"
);
auto
*
hdfFingerprintAuthInterfaceHost
=
CONTAINER_OF
(
client
->
device
->
service
,
struct
HdfFingerprintAuthInterfaceHost
,
ioService
);
OHOS
::
MessageParcel
*
dataParcel
=
nullptr
;
OHOS
::
MessageParcel
*
replyParcel
=
nullptr
;
OHOS
::
MessageOption
option
;
if
(
SbufToParcel
(
data
,
&
dataParcel
)
!=
HDF_SUCCESS
)
{
IAM_LOGE
(
"%{public}s:invalid data sbuf object to dispatch"
,
__func__
);
return
HDF_ERR_INVALID_PARAM
;
...
...
@@ -161,10 +165,10 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
IAM_LOGE
(
"%{public}s:invalid reply sbuf object to dispatch"
,
__func__
);
return
HDF_ERR_INVALID_PARAM
;
}
return
hdfFingerprintAuthInterfaceHost
->
stub
->
SendRequest
(
cmdId
,
*
dataParcel
,
*
replyParcel
,
option
);
}
// 初始化接口
int
HdfFingerprintAuthInterfaceDriverInit
(
struct
HdfDeviceObject
*
deviceObject
)
{
...
...
@@ -175,7 +179,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
}
return
HDF_SUCCESS
;
}
// Fingerprint_auth驱动对外提供的服务绑定到HDF框架
int
HdfFingerprintAuthInterfaceDriverBind
(
struct
HdfDeviceObject
*
deviceObject
)
{
...
...
@@ -185,29 +189,29 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
IAM_LOGE
(
"%{public}s: failed to create HdfFaceAuthInterfaceHost object"
,
__func__
);
return
HDF_FAILURE
;
}
hdfFingerprintAuthInterfaceHost
->
ioService
.
Dispatch
=
FingerprintAuthInterfaceDriverDispatch
;
hdfFingerprintAuthInterfaceHost
->
ioService
.
Open
=
NULL
;
hdfFingerprintAuthInterfaceHost
->
ioService
.
Release
=
NULL
;
auto
serviceImpl
=
IFingerprintAuthInterface
::
Get
(
true
);
if
(
serviceImpl
==
nullptr
)
{
IAM_LOGE
(
"%{public}s: failed to implement service"
,
__func__
);
return
HDF_FAILURE
;
}
hdfFingerprintAuthInterfaceHost
->
stub
=
OHOS
::
HDI
::
ObjectCollector
::
GetInstance
().
GetOrNewObject
(
serviceImpl
,
IFaceAuthInterface
::
GetDescriptor
());
if
(
hdfFingerprintAuthInterfaceHost
->
stub
==
nullptr
)
{
IAM_LOGE
(
"%{public}s: failed to get stub object"
,
__func__
);
return
HDF_FAILURE
;
}
deviceObject
->
service
=
&
hdfFingerprintAuthInterfaceHost
->
ioService
;
IAM_LOGI
(
"success"
);
return
HDF_SUCCESS
;
}
// 释放Fingerprint_auth驱动中的资源
void
HdfFingerprintAuthInterfaceDriverRelease
(
struct
HdfDeviceObject
*
deviceObject
)
{
...
...
@@ -217,7 +221,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
delete
hdfFaceAuthInterfaceHost
;
IAM_LOGI
(
"success"
);
}
// 注册Fingerprint_auth驱动入口数据结构体对象
struct
HdfDriverEntry
g_fingerprintAuthInterfaceDriverEntry
=
{
.
moduleVersion
=
1
,
...
...
@@ -226,7 +230,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
.
Init
=
HdfFingerprintAuthInterfaceDriverInit
,
.
Release
=
HdfFingerprintAuthInterfaceDriverRelease
,
};
// 调用HDF_INIT将驱动入口注册到HDF框架中。在加载驱动时HDF框架会先调用Bind函数,再调用Init函数加载该驱动。当Init调用异常时,HDF框架会调用Release释放驱动资源并退出
HDF_INIT
(
g_fingerprintAuthInterfaceDriverEntry
);
```
...
...
@@ -239,15 +243,15 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
public:
ExecutorImpl
(
struct
ExecutorInfo
executorInfo
);
virtual
~
ExecutorImpl
()
{}
private:
struct
ExecutorInfo
executorInfo_
;
// 执行器信息
};
static
constexpr
uint16_t
SENSOR_ID
=
123
;
// 执行器sensorID
static
constexpr
uint32_t
EXECUTOR_TYPE
=
123
;
// 执行器类型
static
constexpr
size_t
PUBLIC_KEY_LEN
=
32
;
// 执行器32字节公钥
// 创建HDI服务对象
extern
"C"
IFaceAuthInterface
*
FingerprintAuthInterfaceImplGetInstance
(
void
)
{
...
...
@@ -258,9 +262,9 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
}
return
fingerprintAuthInterfaceService
;
}
// 获取执行器列表实现,创建执行器
int32_t
GetExecutorList
(
std
::
vector
<
sptr
<
IExecutor
>>&
executorList
)
int32_t
GetExecutorList
V1_1
(
std
::
vector
<
sptr
<
V1_1
::
IExecutor
>>&
executorList
)
{
IAM_LOGI
(
"interface mock start"
);
executorList
.
clear
();
...
...
@@ -278,10 +282,21 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
IAM_LOGE
(
"executor is nullptr"
);
return
HDF_FAILURE
;
}
executorList
.
push_back
(
sptr
<
IExecutor
>
(
executor
));
executorList
.
push_back
(
sptr
<
V1_1
::
IExecutor
>
(
executor
));
IAM_LOGI
(
"interface mock success"
);
return
HDF_SUCCESS
;
}
// 获取V1_0执行器列表实现,使用V1_1版本执行器实现V1_0版本执行器的功能
int32_t
GetExecutorList
(
std
::
vector
<
sptr
<
V1_0
::
IExecutor
>>
&
executorList
)
{
std
::
vector
<
sptr
<
V1_1
::
IExecutor
>>
executorListV1_1
;
int32_t
result
=
GetExecutorListV1_1
(
executorListV1_1
);
for
(
auto
&
executor
:
executorListV1_1
)
{
executorList
.
push_back
(
executor
);
}
return
result
;
}
```
3.
步骤1、2完成后基本实现了Fingerprint_auth驱动和Fingerprint_auth服务对接。接下来需实现执行器每个功能接口,来完成指纹认证基础能力。关键代码如下,详细代码请参见
[
executor_impl.cpp
](
https://gitee.com/openharmony/drivers_peripheral/blob/master/fingerprint_auth/hdi_service/src/executor_impl.cpp
)
文件。
...
...
@@ -295,7 +310,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
IAM_LOGI
(
"get executor information success"
);
return
HDF_SUCCESS
;
}
// 实现获取指定模板ID的模板信息接口
int32_t
GetTemplateInfo
(
uint64_t
templateId
,
TemplateInfo
&
info
)
{
...
...
@@ -305,7 +320,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
IAM_LOGI
(
"get template information success"
);
return
HDF_SUCCESS
;
}
// 实现执行器注册成功后,获取用户认证框架的公钥信息、获取用户认证框架的模板列表接口。将公钥信息保持,模板列表用于和本地的模板做对账
int32_t
OnRegisterFinish
(
const
std
::
vector
<
uint64_t
>&
templateIdList
,
const
std
::
vector
<
uint8_t
>&
frameworkPublicKey
,
const
std
::
vector
<
uint8_t
>&
extraInfo
)
...
...
@@ -317,7 +332,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
IAM_LOGI
(
"register finish"
);
return
HDF_SUCCESS
;
}
// 实现指纹录入接口
int32_t
Enroll
(
uint64_t
scheduleId
,
const
std
::
vector
<
uint8_t
>&
extraInfo
,
const
sptr
<
IExecutorCallback
>&
callbackObj
)
...
...
@@ -333,7 +348,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
}
return
HDF_SUCCESS
;
}
// 实现指纹认证接口
int32_t
Authenticate
(
uint64_t
scheduleId
,
const
std
::
vector
<
uint64_t
>&
templateIdList
,
const
std
::
vector
<
uint8_t
>&
extraInfo
,
const
sptr
<
IExecutorCallback
>&
callbackObj
)
...
...
@@ -350,7 +365,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
}
return
HDF_SUCCESS
;
}
// 实现指纹识别接口
int32_t
Identify
(
uint64_t
scheduleId
,
const
std
::
vector
<
uint8_t
>&
extraInfo
,
const
sptr
<
IExecutorCallback
>&
callbackObj
)
...
...
@@ -366,7 +381,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
}
return
HDF_SUCCESS
;
}
// 实现删除指纹模板接口
int32_t
Delete
(
const
std
::
vector
<
uint64_t
>&
templateIdList
)
{
...
...
@@ -375,7 +390,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
IAM_LOGI
(
"delete success"
);
return
HDF_SUCCESS
;
}
// 实现通过scheduleId取消指定操作接口
int32_t
Cancel
(
uint64_t
scheduleId
)
{
...
...
@@ -384,7 +399,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
IAM_LOGI
(
"cancel success"
);
return
HDF_SUCCESS
;
}
// 实现指纹认证服务向Fingerprint_auth驱动传递参数的通用接口,当前需要实现冻结与解锁模板命令
int32_t
SendCommand
(
int32_t
commandId
,
const
std
::
vector
<
uint8_t
>&
extraInfo
,
const
sptr
<
IExecutorCallback
>&
callbackObj
)
...
...
@@ -419,8 +434,34 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
}
return
HDF_SUCCESS
;
}
// 实现获取执行器属性接口
int32_t
ExecutorImpl
::
GetProperty
(
const
std
::
vector
<
uint64_t
>
&
templateIdList
,
const
std
::
vector
<
GetPropertyType
>
&
propertyTypes
,
Property
&
property
)
{
IAM_LOGI
(
"interface mock start"
);
property
=
{};
IAM_LOGI
(
"get property success"
);
return
HDF_SUCCESS
;
}
// 实现设置需缓存模板列表接口
int32_t
ExecutorImpl
::
SetCachedTemplates
(
const
std
::
vector
<
uint64_t
>
&
templateIdList
)
{
IAM_LOGI
(
"interface mock start"
);
IAM_LOGI
(
"set cached templates success"
);
return
HDF_SUCCESS
;
}
// 实现注册SA命令回调接口
int32_t
ExecutorImpl
::
RegisterSaCommandCallback
(
const
sptr
<
ISaCommandCallback
>
&
callbackObj
)
{
IAM_LOGI
(
"interface mock start"
);
IAM_LOGI
(
"register sa command callback success"
);
return
HDF_SUCCESS
;
}
```
4.
用户身份认证框架支持多driver,当增加driver或者修改driver信息,需要修改如下文件中serviceName2Config。
```
c++
...
...
zh-cn/device-dev/driver/driver-peripherals-pinauth-des.md
浏览文件 @
0a4ac2c2
...
...
@@ -81,30 +81,32 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
### 接口说明
注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/pin_auth
/v1_0/
)。
注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/pin_auth)。
在本文中,口令凭据的录入、认证和删除相关的HDI接口如表1所示,表2中的回调函数分别用于口令执行器返回操作结果给框架和获取用户输入的口令信息。
**表1**
接口功能介绍
| 接口名称 | 功能介绍 |
| ------------------------------- | ------------------------------------------- |
| GetExecutorList(std::vector
<sptr
<
IExecutor
>
>& executorList) | 获取
执行器列表。 |
| GetExecutor
Info(ExecutorInfo& info) | 获取执行器信息
。 |
| GetExecutorList(std::vector
\<
sptr
\<
V1_0::IExecutor>>& executorList) | 获取V1_0
执行器列表。 |
| GetExecutor
ListV1_1(std::vector
\<
sptr
\<
V1_1::IExecutor>>& executorList) | 获取V1_1版本执行器列表
。 |
| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定templateId的模板信息。 |
| OnRegisterFinish(const std::vector
<uint64_t>
& templateIdList,
<br/>
const std::vector
<uint8_t>
& frameworkPublicKey,
<br/>
const std::vector
<uint8_t>
& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的template 列表用于对账。 |
| OnSetData(uint64_t scheduleId, uint64_t authSubType,
<br/>
const std::vector
<uint8_t>
&data) | 回调函数,返回用户录入的口令子类型和录入的口令脱敏数据。 |
| Enroll(uint64_t scheduleId, const std::vector
<uint8_t>
& extraInfo,
<br/>
const sptr
<IExecutorCallback>
& callbackObj) | 录入pin码。 |
| Authenticate(uint64_t scheduleId, uint64_t templateId, const std::vector
<uint8_t>
& extraInfo, const sptr
<IExecutorCallback>
& callbackObj) | pin码认证。 |
| OnRegisterFinish(const std::vector
\<
uint64_t>& templateIdList,
<br/>
const std::vector
\<
uint8_t>& frameworkPublicKey,
<br/>
const std::vector
\
<
uint8_t>& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的template 列表用于对账。 |
| OnSetData(uint64_t scheduleId, uint64_t authSubType,
<br/>
const std::vector
\
<
uint8_t> &data) | 回调函数,返回用户录入的口令子类型和录入的口令脱敏数据。 |
| Enroll(uint64_t scheduleId, const std::vector
\<
uint8_t>& extraInfo,
<br/>
const sptr
\
<
IExecutorCallback>& callbackObj) | 录入pin码。 |
| Authenticate(uint64_t scheduleId, uint64_t templateId, const std::vector
\<
uint8_t>& extraInfo, const sptr
\
<
IExecutorCallback>& callbackObj) | pin码认证。 |
| Delete(uint64_t templateId) | 删除pin码模板。 |
| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定操作。 |
| SendCommand(int32_t commandId, const std::vector
<uint8_t>
& extraInfo,
<br/>
const sptr
<IExecutorCallback>
& callbackObj) | 预留接口。 |
| SendCommand(int32_t commandId, const std::vector
\<
uint8_t>& extraInfo,
<br/>
const sptr
\<
IExecutorCallback>& callbackObj) | 预留接口。 |
| GetProperty(const std::vector
\<
uint64_t>& templateIdList,
<br/>
const std::vector
\<
GetPropertyType>& propertyTypes, Property& property) | 获取执行器属性信息。 |
**表2**
回调函数介绍
| 接口名称 | 功能介绍 |
| ------------------------------------------------------------ | -------------------- |
| IExecutorCallback::OnResult(int32_t code, const std::vector
<uint8_t>
& extraInfo) | 返回操作的最终结果。 |
| IExecutorCallback::OnGetData(uint64_t scheduleId, const std::vector
<uint8_t>
& salt,
<br/>
uint64_t authSubType)| 返回获取pin码数据信息。 |
| IExecutorCallback::OnResult(int32_t code, const std::vector
\
<
uint8_t>& extraInfo) | 返回操作的最终结果。 |
| IExecutorCallback::OnGetData(uint64_t scheduleId, const std::vector
\
<
uint8_t>& salt,
<br/>
uint64_t authSubType)| 返回获取pin码数据信息。 |
### 开发步骤
...
...
@@ -139,18 +141,18 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
struct
IDeviceIoService
ioService
;
OHOS
::
sptr
<
OHOS
::
IRemoteObject
>
stub
;
};
// 服务接口调用响应接口
static
int32_t
PinAuthInterfaceDriverDispatch
(
struct
HdfDeviceIoClient
*
client
,
int
cmdId
,
struct
HdfSBuf
*
data
,
struct
HdfSBuf
*
reply
)
{
IAM_LOGI
(
"start"
);
auto
*
hdfPinAuthInterfaceHost
=
CONTAINER_OF
(
client
->
device
->
service
,
struct
HdfPinAuthInterfaceHost
,
ioService
);
OHOS
::
MessageParcel
*
dataParcel
=
nullptr
;
OHOS
::
MessageParcel
*
replyParcel
=
nullptr
;
OHOS
::
MessageOption
option
;
if
(
SbufToParcel
(
data
,
&
dataParcel
)
!=
HDF_SUCCESS
)
{
IAM_LOGE
(
"%{public}s:invalid data sbuf object to dispatch"
,
__func__
);
return
HDF_ERR_INVALID_PARAM
;
...
...
@@ -159,10 +161,10 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
IAM_LOGE
(
"%{public}s:invalid reply sbuf object to dispatch"
,
__func__
);
return
HDF_ERR_INVALID_PARAM
;
}
return
hdfPinAuthInterfaceHost
->
stub
->
SendRequest
(
cmdId
,
*
dataParcel
,
*
replyParcel
,
option
);
}
// 初始化接口
static
int
HdfPinAuthInterfaceDriverInit
(
struct
HdfDeviceObject
*
deviceObject
)
{
...
...
@@ -176,7 +178,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
}
return
HDF_SUCCESS
;
}
// PinAuth驱动对外提供的服务绑定到HDF框架
static
int
HdfPinAuthInterfaceDriverBind
(
struct
HdfDeviceObject
*
deviceObject
)
{
...
...
@@ -186,29 +188,29 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
IAM_LOGE
(
"%{public}s: failed to create create HdfPinAuthInterfaceHost object"
,
__func__
);
return
HDF_FAILURE
;
}
hdfPinAuthInterfaceHost
->
ioService
.
Dispatch
=
PinAuthInterfaceDriverDispatch
;
hdfPinAuthInterfaceHost
->
ioService
.
Open
=
NULL
;
hdfPinAuthInterfaceHost
->
ioService
.
Release
=
NULL
;
auto
serviceImpl
=
IPinAuthInterface
::
Get
(
true
);
if
(
serviceImpl
==
nullptr
)
{
IAM_LOGE
(
"%{public}s: failed to get of implement service"
,
__func__
);
return
HDF_FAILURE
;
}
hdfPinAuthInterfaceHost
->
stub
=
OHOS
::
HDI
::
ObjectCollector
::
GetInstance
().
GetOrNewObject
(
serviceImpl
,
IPinAuthInterface
::
GetDescriptor
());
if
(
hdfPinAuthInterfaceHost
->
stub
==
nullptr
)
{
IAM_LOGE
(
"%{public}s: failed to get stub object"
,
__func__
);
return
HDF_FAILURE
;
}
deviceObject
->
service
=
&
hdfPinAuthInterfaceHost
->
ioService
;
IAM_LOGI
(
"success"
);
return
HDF_SUCCESS
;
}
// 释放PinAuth驱动中的资源
static
void
HdfPinAuthInterfaceDriverRelease
(
struct
HdfDeviceObject
*
deviceObject
)
{
...
...
@@ -218,7 +220,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
delete
hdfPinAuthInterfaceHost
;
IAM_LOGI
(
"success"
);
}
static
struct
HdfDriverEntry
g_pinAuthInterfaceDriverEntry
=
{
.
moduleVersion
=
1
,
.
moduleName
=
"pinauth_interface_service"
,
...
...
@@ -226,18 +228,18 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
.
Init
=
HdfPinAuthInterfaceDriverInit
,
.
Release
=
HdfPinAuthInterfaceDriverRelease
,
};
// 调用HDF_INIT将驱动入口注册到HDF框架中,在加载驱动时HDF框架会先调用Bind函数,再调用Init函数加载该驱动,当Init调用异常时,HDF框架会调用Release释放驱动资源并退出
HDF_INIT
(
g_pinauthinterfaceDriverEntry
);
```
1.
完成获取执行器列表接口实现,详细代码参见
[
pin_auth_interface_service.cpp
](
https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/service/src/pin_auth_interface_service.cpp
)
文件。
```
c++
// 执行器实现类
class
ExecutorImpl
:
public
IExecutor
,
public
NoCopyable
{
class
ExecutorImpl
:
public
V1_1
::
IExecutor
,
public
NoCopyable
{
public:
explicit
ExecutorImpl
(
std
::
shared_ptr
<
OHOS
::
UserIAM
::
PinAuth
::
PinAuth
>
pinHdi
);
virtual
~
ExecutorImpl
()
{}
...
...
@@ -254,7 +256,9 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
int32_t
Cancel
(
uint64_t
scheduleId
)
override
;
int32_t
SendCommand
(
int32_t
commandId
,
const
std
::
vector
<
uint8_t
>
&
extraInfo
,
const
sptr
<
IExecutorCallback
>
&
callbackObj
)
override
;
int32_t
GetProperty
(
const
std
::
vector
<
uint64_t
>
&
templateIdList
,
const
std
::
vector
<
GetPropertyType
>
&
propertyTypes
,
Property
&
property
)
override
;
private:
class
ScheduleMap
{
public:
...
...
@@ -263,7 +267,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
uint32_t
GetScheduleInfo
(
const
uint64_t
scheduleId
,
uint32_t
&
commandId
,
sptr
<
IExecutorCallback
>
&
callback
,
uint64_t
&
templateId
,
std
::
vector
<
uint8_t
>
&
salt
);
uint32_t
DeleteScheduleId
(
const
uint64_t
scheduleId
);
private:
struct
ScheduleInfo
{
uint32_t
commandId
;
...
...
@@ -271,20 +275,20 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
uint64_t
templateId
;
std
::
vector
<
uint8_t
>
salt
;
};
std
::
mutex
mutex_
;
std
::
map
<
uint64_t
,
struct
ScheduleInfo
>
scheduleInfo_
;
};
private:
uint32_t
NewSalt
(
std
::
vector
<
uint8_t
>
&
salt
);
void
CallError
(
const
sptr
<
IExecutorCallback
>
&
callbackObj
,
const
uint32_t
errorCode
);
std
::
shared_ptr
<
OHOS
::
UserIAM
::
PinAuth
::
PinAuth
>
pinHdi_
;
ScheduleMap
scheduleMap_
;
};
// 获取执行器列表实现,创建执行器(仅作示例)
int32_t
PinAuthInterfaceService
::
GetExecutorList
(
std
::
vector
<
sptr
<
IExecutor
>>
&
executorList
)
// 获取
V1_1
执行器列表实现,创建执行器(仅作示例)
int32_t
PinAuthInterfaceService
::
GetExecutorList
V1_1
(
std
::
vector
<
sptr
<
V1_1
::
IExecutor
>>
&
executorList
)
{
IAM_LOGI
(
"start"
);
std
::
shared_ptr
<
OHOS
::
UserIAM
::
PinAuth
::
PinAuth
>
pinHdi
=
...
...
@@ -302,10 +306,21 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
IAM_LOGI
(
"end"
);
return
HDF_SUCCESS
;
}
// 获取V1_0执行器列表实现,使用V1_1版本执行器实现V1_0版本执行器的功能
int32_t
PinAuthInterfaceService
::
GetExecutorList
(
std
::
vector
<
sptr
<
V1_0
::
IExecutor
>>
&
executorList
)
{
std
::
vector
<
sptr
<
V1_1
::
IExecutor
>>
executorListV1_1
;
int32_t
result
=
GetExecutorListV1_1
(
executorListV1_1
);
for
(
auto
&
executor
:
executorListV1_1
)
{
executorList
.
push_back
(
executor
);
}
return
result
;
}
```
1.
完成执行器每个功能接口实现,详细代码参见
[
executor_impl.cpp
](
https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/service/src/executor_impl.cpp
)
文件。
```
c++
...
...
@@ -329,10 +344,10 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
return
result
;
}
info
.
esl
=
static_cast
<
ExecutorSecureLevel
>
(
eslRet
);
return
HDF_SUCCESS
;
}
// 实现获取指定templateId的模板信息接口
int32_t
ExecutorImpl
::
GetTemplateInfo
(
uint64_t
templateId
,
TemplateInfo
&
info
)
{
...
...
@@ -353,14 +368,14 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
IAM_LOGE
(
"copy subType to extraInfo fail!"
);
return
HDF_FAILURE
;
}
info
.
executorType
=
EXECUTOR_TYPE
;
info
.
remainAttempts
=
infoRet
.
remainTimes
;
info
.
lockoutDuration
=
infoRet
.
freezingTime
;
return
HDF_SUCCESS
;
}
// 实现执行器注册成功后,获取用户认证框架的公钥信息、获取用户认证框架的template 列表接口,将公钥信息保存,template列表用于和本地的template做对账
int32_t
ExecutorImpl
::
OnRegisterFinish
(
const
std
::
vector
<
uint64_t
>
&
templateIdList
,
const
std
::
vector
<
uint8_t
>
&
frameworkPublicKey
,
const
std
::
vector
<
uint8_t
>
&
extraInfo
)
...
...
@@ -377,10 +392,10 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
IAM_LOGE
(
"Verify templateData failed"
);
return
result
;
}
return
HDF_SUCCESS
;
}
// 实现口令录入接口
int32_t
ExecutorImpl
::
Enroll
(
uint64_t
scheduleId
,
const
std
::
vector
<
uint8_t
>
&
extraInfo
,
const
sptr
<
IExecutorCallback
>
&
callbackObj
)
...
...
@@ -412,10 +427,10 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
}
return
result
;
}
return
HDF_SUCCESS
;
}
// 实现回调数据获取的接口
int32_t
ExecutorImpl
::
OnSetData
(
uint64_t
scheduleId
,
uint64_t
authSubType
,
const
std
::
vector
<
uint8_t
>
&
data
)
{
...
...
@@ -451,7 +466,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
default:
IAM_LOGE
(
"Error commandId"
);
}
if
(
callback
->
OnResult
(
result
,
resultTlv
)
!=
SUCCESS
)
{
IAM_LOGE
(
"callbackObj Pin failed"
);
}
...
...
@@ -459,7 +474,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
if
(
scheduleMap_
.
DeleteScheduleId
(
scheduleId
)
!=
HDF_SUCCESS
)
{
IAM_LOGI
(
"delete scheduleId failed"
);
}
return
HDF_SUCCESS
;
}
// 实现口令认证接口
...
...
@@ -499,10 +514,10 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
}
return
result
;
}
return
HDF_SUCCESS
;
}
// 实现删除口令模板接口
int32_t
ExecutorImpl
::
Delete
(
uint64_t
templateId
)
{
...
...
@@ -516,10 +531,10 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
IAM_LOGE
(
"Verify templateData failed, fail code : %{public}d"
,
result
);
return
result
;
}
return
HDF_SUCCESS
;
}
// 实现通过scheduleId取消指定操作接口
int32_t
ExecutorImpl
::
Cancel
(
uint64_t
scheduleId
)
{
...
...
@@ -530,7 +545,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
}
return
HDF_SUCCESS
;
}
// 口令预留接口
int32_t
ExecutorImpl
::
SendCommand
(
int32_t
commandId
,
const
std
::
vector
<
uint8_t
>
&
extraInfo
,
const
sptr
<
IExecutorCallback
>
&
callbackObj
)
...
...
@@ -541,8 +556,37 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
static_cast
<
void
>
(
callbackObj
);
return
HDF_SUCCESS
;
}
// 获取执行器属性信息接口
int32_t
ExecutorImpl
::
GetProperty
(
const
std
::
vector
<
uint64_t
>
&
templateIdList
,
const
std
::
vector
<
GetPropertyType
>
&
propertyTypes
,
Property
&
property
)
{
IAM_LOGI
(
"start"
);
if
(
pinHdi_
==
nullptr
)
{
IAM_LOGE
(
"pinHdi_ is nullptr"
);
return
HDF_FAILURE
;
}
if
(
templateIdList
.
size
()
!=
1
)
{
IAM_LOGE
(
"templateIdList size is not 1"
);
return
HDF_FAILURE
;
}
uint64_t
templateId
=
templateIdList
[
0
];
OHOS
::
UserIam
::
PinAuth
::
PinCredentialInfo
infoRet
=
{};
int32_t
result
=
pinHdi_
->
QueryPinInfo
(
templateId
,
infoRet
);
if
(
result
!=
SUCCESS
)
{
IAM_LOGE
(
"Get TemplateInfo failed, fail code : %{public}d"
,
result
);
return
HDF_FAILURE
;
}
property
.
authSubType
=
infoRet
.
subType
;
property
.
remainAttempts
=
infoRet
.
remainTimes
;
property
.
lockoutDuration
=
infoRet
.
freezingTime
;
return
HDF_SUCCESS
;
}
```
### 调测验证
驱动开发完成后,可基于RK3568平台验证, 通过设备的设置和锁屏功能验证口令认证功能是否正常,测试步骤如下:
...
...
zh-cn/device-dev/driver/driver-peripherals-user-auth-des.md
浏览文件 @
0a4ac2c2
...
...
@@ -71,7 +71,7 @@
-
Kit
OpenHarmony系统向第三方应用提供的基础应用编程接口。
-
Inner API
OpenHarmony系统向系统应用提供的应用编程接口。
...
...
@@ -117,26 +117,30 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
| 接口名称 | 功能介绍 |
| --------------------------- | --------------------------- |
| Init() | 初始化缓存信息。 |
| AddExecutor(const ExecutorRegisterInfo& info, uint64_t& index, std::vector
<uint8_t>
& publicKey,
<br/>
std::vector
<uint64_t>
& templateIds) | 添加认证执行器,获得此认证能力。 |
| AddExecutor(const ExecutorRegisterInfo& info, uint64_t& index, std::vector
\<
uint8_t>& publicKey,
<br/>
std::vector
\
<
uint64_t>& templateIds) | 添加认证执行器,获得此认证能力。 |
| DeleteExecutor(uint64_t index) | 根据索引值index删除认证执行器。 |
| OpenSession(int32_t userId, std::vector
<uint8_t>
& challenge) | 开启认证凭据管理Session。 |
| OpenSession(int32_t userId, std::vector
\
<
uint8_t>& challenge) | 开启认证凭据管理Session。 |
| CloseSession(int32_t userId) | 关闭认证凭据管理Session。 |
| BeginEnrollment(int32_t userId, const std::vector
<uint8_t>
& authToken, const EnrollParam& param,
<br/>
ScheduleInfo& info) | 发起用户的认证凭据的录入,当录入类型为PIN码且当前用户已录入PIN码的情况下会更新PIN码
。 |
| UpdateEnrollmentResult(int32_t userId, const std::vector
<uint8_t>
& scheduleResult, uint64_t& credentialId,
<br/>
CredentialInfo& oldInfo) | 更新录入结果,完成此次录入。 |
| BeginEnrollment(int32_t userId, const std::vector
\<
uint8_t>& authToken, const EnrollParam& param,
<br/>
ScheduleInfo& info) | 发起用户的认证凭据的录入,当录入类型为PIN码且当前用户已录入PIN码的情况下会更新PIN码(V1_0版本)
。 |
| UpdateEnrollmentResult(int32_t userId, const std::vector
\
<
uint8_t>& scheduleResult, uint64_t& credentialId,
<br/>
CredentialInfo& oldInfo) | 更新录入结果,完成此次录入。 |
| CancelEnrollment(int32_t userId) | 取消此次录入。 |
| DeleteCredential(int32_t userId, uint64_t credentialId, const std::vector
<uint8_t>
& authToken,
<br/>
CredentialInfo& info) | 根据credentialId删除凭据信息。 |
| DeleteUser(int32_t userId, const std::vector
<uint8_t>
& authToken,
<br/>
std::vector
<CredentialInfo>
& deletedInfos) | 删除PIN码即在用户认证框架中删除用户。 |
| EnforceDeleteUser(int32_t userId, std::vector
<CredentialInfo>
& deletedInfos) | 强制删除用户,当系统内此用户被删除时强制调用。 |
| GetCredential(int32_t userId, AuthType authType, std::vector
<CredentialInfo>
& infos) | 查询用户某种认证类型下的凭据信息。 |
| GetSecureInfo(int32_t userId, uint64_t& secureUid, std::vector
<EnrolledInfo>
& infos) | 查询用户的安全用户Id和每种认证类型的录入标记Id。 |
| BeginAuthentication(uint64_t contextId, const AuthSolution& param,
<br/>
std::vector
<ScheduleInfo>
& scheduleInfos) | 发起认证,生成认证方案和调度信息
。 |
| UpdateAuthenticationResult(uint64_t contextId, const std::vector
<uint8_t>
& scheduleResult,
<br/>
AuthResultInfo& info) | 更新认证结果,进行此次认证方案结果的评估。 |
| DeleteCredential(int32_t userId, uint64_t credentialId, const std::vector
\
<
uint8_t>& authToken,
<br/>
CredentialInfo& info) | 根据credentialId删除凭据信息。 |
| DeleteUser(int32_t userId, const std::vector
\<
uint8_t>& authToken,
<br/>
std::vector
\
<
CredentialInfo>& deletedInfos) | 删除PIN码即在用户认证框架中删除用户。 |
| EnforceDeleteUser(int32_t userId, std::vector
\
<
CredentialInfo>& deletedInfos) | 强制删除用户,当系统内此用户被删除时强制调用。 |
| GetCredential(int32_t userId, AuthType authType, std::vector
\
<
CredentialInfo>& infos) | 查询用户某种认证类型下的凭据信息。 |
| GetSecureInfo(int32_t userId, uint64_t& secureUid, std::vector
\
<
EnrolledInfo>& infos) | 查询用户的安全用户Id和每种认证类型的录入标记Id。 |
| BeginAuthentication(uint64_t contextId, const AuthSolution& param,
<br/>
std::vector
\<
ScheduleInfo>& scheduleInfos) | 发起认证,生成认证方案和调度信息(V1_0版本)
。 |
| UpdateAuthenticationResult(uint64_t contextId, const std::vector
\
<
uint8_t>& scheduleResult,
<br/>
AuthResultInfo& info) | 更新认证结果,进行此次认证方案结果的评估。 |
| CancelAuthentication(uint64_t contextId) | 取消此次认证。 |
| BeginIdentification(uint64_t contextId, AuthType authType, const std::vector
<int8_t>
& challenge,
<br/>
uint32_t executorId, ScheduleInfo& scheduleInfo) | 发起识别,生成识别方案和调度信息
。 |
| UpdateIdentificationResult(uint64_t contextId, const std::vector
<uint8_t>
& scheduleResult,
<br/>
IdentifyResultInfo& info) | 更新识别结果,进行此次识别方案结果的评估。 |
| BeginIdentification(uint64_t contextId, AuthType authType, const std::vector
\<
int8_t>& challenge,
<br/>
uint32_t executorId, ScheduleInfo& scheduleInfo) | 发起识别,生成识别方案和调度信息(V1_0版本)
。 |
| UpdateIdentificationResult(uint64_t contextId, const std::vector
\
<
uint8_t>& scheduleResult,
<br/>
IdentifyResultInfo& info) | 更新识别结果,进行此次识别方案结果的评估。 |
| CancelIdentification(uint64_t contextId) | 取消此次识别。 |
| GetAuthTrustLevel(int32_t userId, AuthType authType, uint32_t& authTrustLevel) | 获取此用户当前认证类型的认证可信等级。 |
| GetValidSolution(int32_t userId, const std::vector
<AuthType>
& authTypes, uint32_t authTrustLevel,
<br/>
std::vector
<AuthType>
& validTypes) | 筛选此用户当前认证可信等级下可用的认证方式。 |
| GetValidSolution(int32_t userId, const std::vector
\<
AuthType>& authTypes, uint32_t authTrustLevel,
<br/>
std::vector
\<
AuthType>& validTypes) | 筛选此用户当前认证可信等级下可用的认证方式。 |
| BeginEnrollmentV1_1(int32_t userId, const std::vector
\<
uint8_t>& authToken, const EnrollParam& param, ScheduleInfoV1_1& info) | 发起用户的认证凭据的录入,当录入类型为PIN码且当前用户已录入PIN码的情况下会更新PIN码(V1_1版本)。 |
| BeginAuthenticationV1_1(uint64_t contextId, const AuthSolution& param, std::vector
\<
ScheduleInfoV1_1>& scheduleInfos) | 发起认证,生成认证方案和调度信息(V1_1版本)。 |
| BeginIdentificationV1_1(uint64_t contextId, AuthType authType,
const std::vector
\<
uint8_t>& challenge, uint32_t executorSensorHint, ScheduleInfoV1_1& scheduleInfo)| 发起识别,生成识别方案和调度信息(V1_1版本)。 |
### 开发步骤
...
...
@@ -164,17 +168,17 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
struct
IDeviceIoService
ioService
;
OHOS
::
sptr
<
OHOS
::
IRemoteObject
>
stub
;
};
// 服务接口调用响应接口
static
int32_t
UserAuthInterfaceDriverDispatch
(
struct
HdfDeviceIoClient
*
client
,
int
cmdId
,
struct
HdfSBuf
*
data
,
struct
HdfSBuf
*
reply
)
{
auto
*
hdfUserAuthInterfaceHost
=
CONTAINER_OF
(
client
->
device
->
service
,
struct
HdfUserAuthInterfaceHost
,
ioService
);
OHOS
::
MessageParcel
*
dataParcel
=
nullptr
;
OHOS
::
MessageParcel
*
replyParcel
=
nullptr
;
OHOS
::
MessageOption
option
;
if
(
SbufToParcel
(
data
,
&
dataParcel
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"%{public}s:invalid data sbuf object to dispatch"
,
__func__
);
return
HDF_ERR_INVALID_PARAM
;
...
...
@@ -183,10 +187,10 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
HDF_LOGE
(
"%{public}s:invalid reply sbuf object to dispatch"
,
__func__
);
return
HDF_ERR_INVALID_PARAM
;
}
return
hdfUserAuthInterfaceHost
->
stub
->
SendRequest
(
cmdId
,
*
dataParcel
,
*
replyParcel
,
option
);
}
// 初始化接口
int
HdfUserAuthInterfaceDriverInit
(
struct
HdfDeviceObject
*
deviceObject
)
{
...
...
@@ -194,46 +198,46 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
OHOS
::
UserIAM
::
Common
::
Init
();
return
HDF_SUCCESS
;
}
// User_auth驱动对外提供的服务绑定到HDF框架
int
HdfUserAuthInterfaceDriverBind
(
struct
HdfDeviceObject
*
deviceObject
)
{
HDF_LOGI
(
"HdfUserAuthInterfaceDriverBind enter"
);
auto
*
hdfUserAuthInterfaceHost
=
new
(
std
::
nothrow
)
HdfUserAuthInterfaceHost
;
if
(
hdfUserAuthInterfaceHost
==
nullptr
)
{
HDF_LOGE
(
"%{public}s: failed to create HdfUserAuthInterfaceHost object"
,
__func__
);
return
HDF_FAILURE
;
}
hdfUserAuthInterfaceHost
->
ioService
.
Dispatch
=
UserAuthInterfaceDriverDispatch
;
hdfUserAuthInterfaceHost
->
ioService
.
Open
=
NULL
;
hdfUserAuthInterfaceHost
->
ioService
.
Release
=
NULL
;
auto
serviceImpl
=
IUserAuthInterface
::
Get
(
true
);
if
(
serviceImpl
==
nullptr
)
{
HDF_LOGE
(
"%{public}s: failed to implement service"
,
__func__
);
return
HDF_FAILURE
;
}
hdfUserAuthInterfaceHost
->
stub
=
OHOS
::
HDI
::
ObjectCollector
::
GetInstance
().
GetOrNewObject
(
serviceImpl
,
IUserAuthInterface
::
GetDescriptor
());
if
(
hdfUserAuthInterfaceHost
->
stub
==
nullptr
)
{
HDF_LOGE
(
"%{public}s: failed to get stub object"
,
__func__
);
return
HDF_FAILURE
;
}
deviceObject
->
service
=
&
hdfUserAuthInterfaceHost
->
ioService
;
return
HDF_SUCCESS
;
}
// 释放User_auth驱动中的资源
void
HdfUserAuthInterfaceDriverRelease
(
struct
HdfDeviceObject
*
deviceObject
){
HDF_LOGI
(
"HdfUserAuthInterfaceDriverRelease enter"
);
auto
*
hdfUserAuthInterfaceHost
=
CONTAINER_OF
(
deviceObject
->
service
,
struct
HdfUserAuthInterfaceHost
,
ioService
);
delete
hdfUserAuthInterfaceHost
;
}
// 注册User_auth驱动入口数据结构体对象
struct
HdfDriverEntry
g_userAuthInterfaceDriverEntry
=
{
.
moduleVersion
=
1
,
...
...
@@ -242,7 +246,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
.
Init
=
HdfUserAuthInterfaceDriverInit
,
.
Release
=
HdfUserAuthInterfaceDriverRelease
,
};
// 调用HDF_INIT将驱动入口注册到HDF框架中,在加载驱动时HDF框架会先调用Bind函数,再调用Init函数加载该驱动,当Init调用异常时,HDF框架会调用Release释放驱动资源并退出
#ifndef __cplusplus
extern
"C"
{
...
...
@@ -267,14 +271,14 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
GlobalUnLock
();
return
ret
;
}
// 删除执行器
int32_t
UserAuthInterfaceService
::
DeleteExecutor
(
uint64_t
index
)
{
return
UnRegisterExecutor
(
index
);
}
```
3.
录入接口举例实现,详细代码参见
[
user_auth_interface_service.cpp
](
https://gitee.com/openharmony/drivers_peripheral/blob/master/user_auth/hdi_service/service/user_auth_interface_service.cpp
)
文件。
```
c++
...
...
@@ -292,7 +296,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
GlobalUnLock
();
return
ret
;
}
// 关闭认证凭据管理会话
int32_t
UserAuthInterfaceService
::
CloseSession
(
int32_t
userId
)
{
...
...
@@ -301,10 +305,10 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
GlobalUnLock
();
return
ret
;
}
// 发起
认证,生成录入调度信息
int32_t
UserAuthInterfaceService
::
BeginEnrollment
(
int32_t
userId
,
const
std
::
vector
<
uint8_t
>&
authToken
,
const
EnrollParam
&
param
,
ScheduleInfo
&
info
)
// 发起
录入,生成录入调度信息(V1_1版本)
int32_t
UserAuthInterfaceService
::
BeginEnrollment
V1_1
(
int32_t
userId
,
const
std
::
vector
<
uint8_t
>&
authToken
,
const
EnrollParam
&
param
,
ScheduleInfo
V1_1
&
info
)
{
IAM_LOGI
(
"start"
);
GlobalLock
();
...
...
@@ -342,7 +346,18 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
GlobalUnLock
();
return
ret
;
}
// 发起录入,生成录入调度信息(V1_0版本),通过调用 V1_1 版本相应接口实现功能
int32_t
UserAuthInterfaceService
::
BeginEnrollment
(
int32_t
userId
,
const
std
::
vector
<
uint8_t
>
&
authToken
,
const
EnrollParam
&
param
,
ScheduleInfo
&
info
)
{
IAM_LOGI
(
"start"
);
ScheduleInfoV1_1
infoV1_1
;
int32_t
ret
=
BeginEnrollmentV1_1
(
userId
,
authToken
,
param
,
infoV1_1
);
CopyScheduleInfoV1_1ToV1_0
(
infoV1_1
,
info
);
return
ret
;
}
// 取消录入接口实现
int32_t
UserAuthInterfaceService
::
CancelEnrollment
(
int32_t
userId
)
{
...
...
@@ -350,7 +365,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
BreakOffCoauthSchedule
(
userId
);
return
RESULT_SUCCESS
;
}
// 录入凭据信息存储接口实现
int32_t
UserAuthInterfaceService
::
UpdateEnrollmentResult
(
int32_t
userId
,
const
std
::
vector
<
uint8_t
>&
scheduleResult
,
uint64_t
&
credentialId
,
CredentialInfo
&
oldInfo
)
...
...
@@ -405,10 +420,10 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
}
return
userAuthInterfaceService
;
}
// 发起认证,生成认证方案和调度信息
int32_t
UserAuthInterfaceService
::
BeginAuthentication
(
uint64_t
contextId
,
const
AuthSolution
&
param
,
std
::
vector
<
ScheduleInfo
>&
infos
)
int32_t
UserAuthInterfaceService
::
BeginAuthentication
V1_1
(
uint64_t
contextId
,
const
AuthSolution
&
param
,
std
::
vector
<
ScheduleInfo
V1_1
>&
infos
)
{
IAM_LOGI
(
"start"
);
if
(
param
.
challenge
.
size
()
!=
sizeof
(
uint64_t
))
{
...
...
@@ -436,7 +451,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
return
ret
;
}
for
(
uint32_t
i
=
0
;
i
<
scheduleIdNum
;
i
++
)
{
ScheduleInfo
temp
;
ScheduleInfo
V1_1
temp
;
if
(
!
CopyScheduleInfo
(
schedulesGet
+
i
,
&
temp
))
{
infos
.
clear
();
ret
=
RESULT_GENERAL_ERROR
;
...
...
@@ -448,7 +463,18 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
GlobalUnLock
();
return
ret
;
}
// 发起认证,生成认证方案和调度信息(V1_0版本),通过调用 V1_1 版本相应接口实现功能
int32_t
UserAuthInterfaceService
::
BeginAuthentication
(
uint64_t
contextId
,
const
AuthSolution
&
param
,
std
::
vector
<
ScheduleInfo
>
&
infos
)
{
IAM_LOGI
(
"start"
);
std
::
vector
<
ScheduleInfoV1_1
>
infosV1_1
;
int32_t
ret
=
BeginAuthenticationV1_1
(
contextId
,
param
,
infosV1_1
);
CopyScheduleInfosV1_1ToV1_0
(
infosV1_1
,
infos
);
return
ret
;
}
// 更新认证结果,进行此次认证方案结果的评估
int32_t
UserAuthInterfaceService
::
UpdateAuthenticationResult
(
uint64_t
contextId
,
const
std
::
vector
<
uint8_t
>&
scheduleResult
,
AuthResultInfo
&
info
)
...
...
@@ -487,7 +513,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
GlobalUnLock
();
return
RESULT_SUCCESS
;
}
// 取消认证
int32_t
UserAuthInterfaceService
::
CancelAuthentication
(
uint64_t
contextId
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录