mirror of
https://github.com/openharmony/useriam_user_idm.git
synced 2026-06-30 21:07:55 -04:00
fix useridm issue
Signed-off-by: https://gitee.com/WALL_EYE <wangguoqiang12@huawei.com> Change-Id: Ied331d1028086151ee38cc0b34aba07ea2d3b70f
This commit is contained in:
+1
-1
@@ -49,7 +49,7 @@
|
||||
|
||||
| 接口名 | 描述 |
|
||||
| ------ | -------------------------------- |
|
||||
| getAuthInfo(callback : AsyncCallback<Array<EnrolledCredInfo>>,authType? : AuthType) : void; | 信息查询 接口,支持查询用户录入的一类或全部类型认证凭据 |
|
||||
| getAuthInfo(callback : AsyncCallback<Array<EnrolledCredInfo>>,authType? : AuthType) : void; | 信息查询接口,支持查询用户录入的一类或全部类型认证凭据 |
|
||||
|
||||
### 使用说明
|
||||
|
||||
|
||||
@@ -24,17 +24,100 @@ namespace UserIDM {
|
||||
class IUserIDM : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.useridm.IUserIDM");
|
||||
|
||||
/*
|
||||
* start an IDM operation to obtain challenge value, a challenge value of 0 indicates that opensession failed.
|
||||
*
|
||||
* return uint8Array is success or fail.
|
||||
*/
|
||||
virtual uint64_t OpenSession() = 0;
|
||||
|
||||
/*
|
||||
* end an IDM operation.
|
||||
*/
|
||||
virtual void CloseSession() = 0;
|
||||
|
||||
/*
|
||||
* get authentication information.
|
||||
*
|
||||
* param authType credential type.
|
||||
* param callback returns all registered credential information of this type for the current user.
|
||||
*/
|
||||
virtual int32_t GetAuthInfo(AuthType authType, const sptr<IGetInfoCallback>& callback) = 0;
|
||||
|
||||
/*
|
||||
* get authentication information.
|
||||
*
|
||||
* param userId current user id.
|
||||
* param authType credential type.
|
||||
* param callback returns all registered credential information of this type for the current user.
|
||||
*/
|
||||
virtual int32_t GetAuthInfo(int32_t userId, AuthType authType, const sptr<IGetInfoCallback>& callback) = 0;
|
||||
|
||||
/*
|
||||
* get user security ID.
|
||||
*
|
||||
* param userId current user id.
|
||||
* param callback returns all registered security information for the current user.
|
||||
*/
|
||||
virtual int32_t GetSecInfo(int32_t userId, const sptr<IGetSecInfoCallback>& callback) = 0;
|
||||
|
||||
/**
|
||||
* add user credential information, pass in credential addition method and credential information
|
||||
* (credential type, subtype, if adding user's non password credentials, pass in password authentication token),
|
||||
* and get the result / acquireinfo callback.
|
||||
*
|
||||
* param credInfo Incoming credential addition method and credential information
|
||||
* (credential type, subtype, password authentication token).
|
||||
* param callback get results / acquireinfo callback.
|
||||
*/
|
||||
virtual void AddCredential(AddCredInfo& credInfo, const sptr<IIDMCallback>& callback) = 0;
|
||||
|
||||
/*
|
||||
* update user credential information.
|
||||
*
|
||||
* param credInfo Incoming credential addition method and credential information
|
||||
* (credential type, subtype, password authentication token).
|
||||
* param callback update results / acquireinfo callback.
|
||||
*/
|
||||
virtual void UpdateCredential(AddCredInfo& credInfo, const sptr<IIDMCallback>& callback) = 0;
|
||||
|
||||
/*
|
||||
* Cancel entry and pass in challenge value.
|
||||
*
|
||||
* param challenge challenge value.
|
||||
*/
|
||||
virtual int32_t Cancel(uint64_t challenge) = 0;
|
||||
|
||||
/*
|
||||
* enforce delete the user credential information, pass in the user password authentication token and callback,
|
||||
* and obtain the deletion result through the callback.
|
||||
*
|
||||
* param authToken user password authentication token.
|
||||
* param callback get deletion result through callback.
|
||||
*/
|
||||
virtual int32_t EnforceDelUser(int32_t userId, const sptr<IIDMCallback>& callback) = 0;
|
||||
|
||||
/*
|
||||
* delete the user credential information, pass in the user password authentication token and callback,
|
||||
* and obtain the deletion result through the callback.
|
||||
*
|
||||
* param authToken user password authentication token.
|
||||
* param callback get deletion result through callback.
|
||||
*/
|
||||
virtual void DelUser(std::vector<uint8_t> authToken, const sptr<IIDMCallback>& callback) = 0;
|
||||
virtual void DelCred(uint64_t credentialId, std::vector<uint8_t> authToken, const sptr<IIDMCallback>& callback) = 0;
|
||||
|
||||
/*
|
||||
* delete the user credential information, pass in the credential id, password authentication token and callback,
|
||||
* and obtain the deletion result through the callback.
|
||||
* Only deleting non password credentials is supported.
|
||||
*
|
||||
* param credentialId credential index.
|
||||
* param authToken password authentication token.
|
||||
* param callback get deletion result through callback.
|
||||
*/
|
||||
virtual void DelCred(uint64_t credentialId, std::vector<uint8_t> authToken,
|
||||
const sptr<IIDMCallback>& callback) = 0;
|
||||
|
||||
enum {
|
||||
USERIDM_OPEN_SESSION = 0,
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace UserIAM {
|
||||
namespace UserIDM {
|
||||
class IGetInfoCallback : public IRemoteBroker {
|
||||
public:
|
||||
/*
|
||||
* return all registered credential information.
|
||||
*/
|
||||
virtual void OnGetInfo(std::vector<CredentialInfo> &info) = 0;
|
||||
|
||||
enum {
|
||||
@@ -35,6 +38,9 @@ public:
|
||||
|
||||
class IGetSecInfoCallback : public IRemoteBroker {
|
||||
public:
|
||||
/*
|
||||
* return all registered security information.
|
||||
*/
|
||||
virtual void OnGetSecInfo(SecInfo &info) = 0;
|
||||
|
||||
enum {
|
||||
@@ -46,7 +52,15 @@ public:
|
||||
|
||||
class IIDMCallback : public IRemoteBroker {
|
||||
public:
|
||||
|
||||
/*
|
||||
* return result code and additional information through callback.
|
||||
*/
|
||||
virtual void OnResult(int32_t result, RequestResult reqRet) = 0;
|
||||
|
||||
/*
|
||||
* return result code and additional information through acquireinfo.
|
||||
*/
|
||||
virtual void OnAcquireInfo(int32_t module, int32_t acquire, RequestResult reqRet) = 0;
|
||||
|
||||
enum {
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
static std::vector<uint8_t> GetNamedAttribute(napi_env env, napi_value obj);
|
||||
static napi_status JudgeObjectType(napi_env env, napi_callback_info info,
|
||||
AsyncCallbackContext* asyncCallbackContext);
|
||||
static std::vector<uint8_t> JudgeArryType(napi_env env, size_t argc, napi_value* argv);
|
||||
static std::vector<uint8_t> JudgeArrayType(napi_env env, size_t argc, napi_value* argv);
|
||||
static void JudgeDelUserType(napi_env env, napi_callback_info info, AsyncCallbackContext* asyncCallbackContext);
|
||||
static void JudgeDelCredType(napi_env env, napi_callback_info info, AsyncCallbackContext* asyncCallbackContext);
|
||||
static void SaveCallback(napi_env env, size_t argc, napi_value* argv, AsyncCallbackContext* asyncCallbackContext);
|
||||
|
||||
@@ -197,9 +197,9 @@ void AuthCommon::JudgeDelUserType(napi_env env, napi_callback_info info, AsyncCa
|
||||
USERIDM_HILOGE(MODULE_JS_NAPI, "napi_get_cb_info failed");
|
||||
return;
|
||||
}
|
||||
asyncCallbackContext->token = JudgeArryType(env, ZERO_PARAMETER, argv);
|
||||
asyncCallbackContext->token = JudgeArrayType(env, ZERO_PARAMETER, argv);
|
||||
if (asyncCallbackContext->token.empty()) {
|
||||
USERIDM_HILOGE(MODULE_JS_NAPI, "JudgeArryType token failed");
|
||||
USERIDM_HILOGE(MODULE_JS_NAPI, "JudgeArrayType token failed");
|
||||
asyncCallbackContext->token.push_back(0);
|
||||
}
|
||||
SaveCallback(env, ONE_PARAMETER, argv, asyncCallbackContext);
|
||||
@@ -216,20 +216,20 @@ void AuthCommon::JudgeDelCredType(napi_env env, napi_callback_info info, AsyncCa
|
||||
USERIDM_HILOGE(MODULE_JS_NAPI, "napi_get_cb_info failed");
|
||||
return;
|
||||
}
|
||||
asyncCallbackContext->credentialId = JudgeArryType(env, ZERO_PARAMETER, argv);
|
||||
asyncCallbackContext->credentialId = JudgeArrayType(env, ZERO_PARAMETER, argv);
|
||||
if (asyncCallbackContext->credentialId.empty()) {
|
||||
USERIDM_HILOGE(MODULE_JS_NAPI, "JudgeArryType credentialId failed");
|
||||
USERIDM_HILOGE(MODULE_JS_NAPI, "JudgeArrayType credentialId failed");
|
||||
return;
|
||||
}
|
||||
asyncCallbackContext->token = JudgeArryType(env, ONE_PARAMETER, argv);
|
||||
asyncCallbackContext->token = JudgeArrayType(env, ONE_PARAMETER, argv);
|
||||
if (asyncCallbackContext->token.empty()) {
|
||||
USERIDM_HILOGE(MODULE_JS_NAPI, "JudgeArryType token failed");
|
||||
USERIDM_HILOGE(MODULE_JS_NAPI, "JudgeArrayType token failed");
|
||||
return;
|
||||
}
|
||||
SaveCallback(env, TWO_PARAMETER, argv, asyncCallbackContext);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> AuthCommon::JudgeArryType(napi_env env, size_t argc, napi_value* argv)
|
||||
std::vector<uint8_t> AuthCommon::JudgeArrayType(napi_env env, size_t argc, napi_value* argv)
|
||||
{
|
||||
USERIDM_HILOGI(MODULE_JS_NAPI, "%{public}s, start", __func__);
|
||||
std::vector<uint8_t> retNull = {0};
|
||||
|
||||
@@ -47,6 +47,9 @@ napi_value UserIdentityManager::NAPI_OpenSession(napi_env env, napi_callback_inf
|
||||
}
|
||||
napi_value ret = OpenSessionWrap(env, info, asyncInfo);
|
||||
if (ret == nullptr) {
|
||||
if (asyncInfo->callback != nullptr) {
|
||||
napi_delete_reference(env, asyncInfo->callback);
|
||||
}
|
||||
if (asyncInfo != nullptr) {
|
||||
delete asyncInfo;
|
||||
asyncInfo = nullptr;
|
||||
@@ -377,7 +380,7 @@ napi_value UserIdentityManager::NAPI_Cancel(napi_env env, napi_callback_info inf
|
||||
|
||||
syncCancelContext->env = env;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
|
||||
syncCancelContext->challenge = AuthCommon::JudgeArryType(env, ZERO_PARAMETER, argv);
|
||||
syncCancelContext->challenge = AuthCommon::JudgeArrayType(env, ZERO_PARAMETER, argv);
|
||||
if (syncCancelContext->challenge.empty() || syncCancelContext->challenge.size() < sizeof(uint64_t)) {
|
||||
USERIDM_HILOGE(MODULE_JS_NAPI, "syncCancelContext->challenge is null or size is wrong!");
|
||||
delete syncCancelContext;
|
||||
@@ -565,6 +568,9 @@ napi_value UserIdentityManager::NAPI_GetAuthInfo(napi_env env, napi_callback_inf
|
||||
napi_value ret = GetAuthInfoWrap(env, info, asyncHolder);
|
||||
if (ret == nullptr) {
|
||||
USERIDM_HILOGE(MODULE_JS_NAPI, "NAPI_GetAuthInfo GetAuthInfoWrap fail");
|
||||
if (asyncGetAuthInfo->callback != nullptr) {
|
||||
napi_delete_reference(env, asyncGetAuthInfo->callback);
|
||||
}
|
||||
delete asyncGetAuthInfo;
|
||||
if (asyncHolder->asyncWork != nullptr) {
|
||||
napi_delete_async_work(env, asyncHolder->asyncWork);
|
||||
@@ -710,7 +716,7 @@ extern "C" __attribute__((constructor)) void RegisterModule(void)
|
||||
.nm_filename = nullptr,
|
||||
.nm_register_func = Init,
|
||||
.nm_modname = "UserIDM",
|
||||
.nm_priv = (reinterpret_cast<void *>(0)),
|
||||
.nm_priv = nullptr,
|
||||
.reserved = {0}
|
||||
};
|
||||
napi_module_register(&module);
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
void CloseEditSession();
|
||||
int32_t QueryCredential(int32_t userId, AuthType authType, std::vector<CredentialInfo>& credInfos);
|
||||
int32_t GetSecureUid(int32_t userId, uint64_t& secureUid, std::vector<EnrolledInfo>& enrolledInfos);
|
||||
int32_t InitSchedulation(std::vector<uint8_t> autoToken, int32_t userId, AuthType authType,
|
||||
int32_t InitSchedule(std::vector<uint8_t> autoToken, int32_t userId, AuthType authType,
|
||||
AuthSubType authSubType, uint64_t& sessionId);
|
||||
int32_t DeleteCredential(int32_t userId, uint64_t credentialId, std::vector<uint8_t> authToken,
|
||||
CredentialInfo& credInfo);
|
||||
|
||||
@@ -92,10 +92,10 @@ int32_t UserIDMAdapter::GetSecureUid(int32_t userId, uint64_t& secureUid,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UserIDMAdapter::InitSchedulation(std::vector<uint8_t> autoToken, int32_t userId, AuthType authType,
|
||||
int32_t UserIDMAdapter::InitSchedule(std::vector<uint8_t> autoToken, int32_t userId, AuthType authType,
|
||||
AuthSubType authSubType, uint64_t& sessionId)
|
||||
{
|
||||
USERIDM_HILOGD(MODULE_SERVICE, "UserIDMAdapter InitSchedulation start");
|
||||
USERIDM_HILOGD(MODULE_SERVICE, "UserIDMAdapter InitSchedule start");
|
||||
int32_t ret = OHOS::UserIAM::UserIDM::Hal::InitSchedulation(autoToken, userId, authType, authSubType, sessionId);
|
||||
USERIDM_HILOGI(MODULE_SERVICE, "Call TA info: GetScheduleId: %{public}d", ret);
|
||||
return ret;
|
||||
|
||||
@@ -160,12 +160,12 @@ int32_t UserIDMController::AddCredentialCtrl(int32_t userId, uint64_t callerID,
|
||||
innerkitsCallback->OnResult(BUSY, reqRet);
|
||||
return BUSY;
|
||||
}
|
||||
int32_t ret = UserIDMAdapter::GetInstance().InitSchedulation(credInfo.token, userId, credInfo.authType,
|
||||
int32_t ret = UserIDMAdapter::GetInstance().InitSchedule(credInfo.token, userId, credInfo.authType,
|
||||
credInfo.authSubType, scheduleId);
|
||||
if (ret == SUCCESS) {
|
||||
ret = AddCredentialCallCoauth(callerID, credInfo, innerkitsCallback, challenge, scheduleId);
|
||||
} else {
|
||||
USERIDM_HILOGE(MODULE_SERVICE, "call TA info: InitSchedulation failed");
|
||||
USERIDM_HILOGE(MODULE_SERVICE, "call TA info: InitSchedule failed");
|
||||
RequestResult reqRet;
|
||||
innerkitsCallback->OnResult(FAIL, reqRet);
|
||||
}
|
||||
@@ -197,10 +197,10 @@ int32_t UserIDMController::UpdateCredentialCtrl(int32_t userId, uint64_t callerI
|
||||
innerkitsCallback->OnResult(BUSY, reqRet);
|
||||
return BUSY;
|
||||
}
|
||||
int32_t ret = UserIDMAdapter::GetInstance().InitSchedulation(credInfo.token, userId, credInfo.authType,
|
||||
int32_t ret = UserIDMAdapter::GetInstance().InitSchedule(credInfo.token, userId, credInfo.authType,
|
||||
credInfo.authSubType, scheduleId);
|
||||
if (ret == SUCCESS) {
|
||||
USERIDM_HILOGI(MODULE_SERVICE, "InitSchedulation SUCCESS");
|
||||
USERIDM_HILOGI(MODULE_SERVICE, "InitSchedule SUCCESS");
|
||||
data_->InsertScheduleId(scheduleId);
|
||||
std::shared_ptr<UserIDMCoAuthHandler> coAuthCallback =
|
||||
std::make_shared<UserIDMCoAuthHandler>(MODIFY_CRED, challenge, scheduleId, data_, innerkitsCallback);
|
||||
@@ -213,7 +213,7 @@ int32_t UserIDMController::UpdateCredentialCtrl(int32_t userId, uint64_t callerI
|
||||
paramInfo.SetCallerUid(callerID);
|
||||
CoAuth::CoAuth::GetInstance().BeginSchedule(scheduleId, paramInfo, coAuthCallback);
|
||||
} else {
|
||||
USERIDM_HILOGE(MODULE_SERVICE, "call TA info: InitSchedulation failed");
|
||||
USERIDM_HILOGE(MODULE_SERVICE, "call TA info: BeginSchedule failed");
|
||||
RequestResult reqRet;
|
||||
innerkitsCallback->OnResult(FAIL, reqRet);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user