From e28d99787dc1431e5b057484380c2273809a3821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Fri, 3 Jan 2025 19:20:51 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BF=A1=E4=BB=BB?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/include/dm_constants.h | 2 ++ .../include/authentication/dm_auth_manager.h | 2 ++ .../src/authentication/auth_message_processor.cpp | 10 ++++++++++ .../src/authentication/dm_auth_manager.cpp | 10 +++++++++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 768a9126a..7c3e57cef 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -155,6 +155,7 @@ constexpr int32_t PKG_NAME_SIZE_MAX = 256; constexpr const char* DM_TYPE_MINE = "MINE"; constexpr const char* DM_TYPE_OH = "OH"; constexpr const char* TAG_SESSION_HEARTBEAT = "session_heartbeat"; +constexpr const char* TAG_ALLOW_AUTH_ALWAYS = "allow_auth_always"; //The following constant are provided only for HiLink. const static char *EXT_PART = "ext_part"; @@ -252,6 +253,7 @@ constexpr const char* PARAM_KEY_POLICY_TIME_OUT = "DM_POLICY_TIMEOUT"; constexpr const char* DEVICE_SCREEN_STATUS = "DEVICE_SCREEN_STATUS"; constexpr const char* PROCESS_NAME = "PROCESS_NAME"; constexpr const char* PARAM_CLOSE_SESSION_DELAY_SECONDS = "DM_CLOSE_SESSION_DELAY_SECONDS"; +constexpr const char* PARAM_ALLOW_AUTH_ALWAYS = "DM_AUTHENTICATION_TYPE"; // screen state constexpr int32_t DM_SCREEN_UNKNOWN = -1; diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index d0ac1fc8a..670593ee0 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -134,6 +134,7 @@ typedef struct DmAuthRequestContext { std::string addr; std::string hostPkgLabel; int32_t closeSessionDelaySeconds = 0; + bool allowAuthAlways = false; } DmAuthRequestContext; typedef struct DmAuthResponseContext { @@ -191,6 +192,7 @@ typedef struct DmAuthResponseContext { bool isFinish = false; std::string edition; int32_t localBindLevel; + bool allowAuthAlways = false; } DmAuthResponseContext; class AuthMessageProcessor; diff --git a/services/implementation/src/authentication/auth_message_processor.cpp b/services/implementation/src/authentication/auth_message_processor.cpp index b67246a0b..921adb172 100644 --- a/services/implementation/src/authentication/auth_message_processor.cpp +++ b/services/implementation/src/authentication/auth_message_processor.cpp @@ -71,6 +71,11 @@ void AuthMessageProcessor::GetJsonObj(nlohmann::json &jsonObj) } else { jsonObj[TAG_IS_SHOW_DIALOG] = true; } + if (authRequestContext_->allowAuthAlways) { + jsonObj[TAG_ALLOW_AUTH_ALWAYS] = true; + } else { + jsonObj[TAG_ALLOW_AUTH_ALWAYS] = false; + } jsonObj[TAG_APP_OPERATION] = authRequestContext_->appOperation; jsonObj[TAG_CUSTOM_DESCRIPTION] = authRequestContext_->customDesc; jsonObj[TAG_APP_NAME] = authRequestContext_->appName; @@ -457,6 +462,11 @@ int32_t AuthMessageProcessor::ParseAuthRequestMessage(nlohmann::json &json) } else { authResponseContext_->isShowDialog = true; } + if (IsBool(json, TAG_ALLOW_AUTH_ALWAYS)) { + authResponseContext_->allowAuthAlways = json[TAG_ALLOW_AUTH_ALWAYS].get(); + } else { + authResponseContext_->allowAuthAlways = false; + } if (IsInt32(json, TAG_BIND_TYPE_SIZE)) { int32_t bindTypeSize = json[TAG_BIND_TYPE_SIZE].get(); if (bindTypeSize > MAX_BINDTYPE_SIZE) { diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 1178814f0..9e9daff41 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -277,6 +277,10 @@ void DmAuthManager::ParseJsonObject(nlohmann::json jsonObject) } else { authRequestContext_->peerBundleName = authRequestContext_->hostPkgName; } + authRequestContext_->allowAuthAlways = false; + if (IsString(jsonObject, PARAM_ALLOW_AUTH_ALWAYS)) { + authRequestContext_->allowAuthAlways = true; + } } authRequestContext_->bundleName = GetBundleName(jsonObject); } @@ -1520,7 +1524,11 @@ void DmAuthManager::ShowConfigDialog() } if (!authResponseContext_->isShowDialog) { LOGI("start auth process"); - StartAuthProcess(USER_OPERATION_TYPE_ALLOW_AUTH); + int32_t action = USER_OPERATION_TYPE_ALLOW_AUTH; + if (authResponseContext_->allowAuthAlways) { + action = USER_OPERATION_TYPE_ALLOW_AUTH_ALWAYS; + } + StartAuthProcess(action); return; } LOGI("ShowConfigDialog start"); -- Gitee From 9842b9988412d19ccccd015f95094e75070324eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Fri, 3 Jan 2025 19:28:10 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/include/dm_constants.h | 1 - 1 file changed, 1 deletion(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 7c3e57cef..39459d157 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -253,7 +253,6 @@ constexpr const char* PARAM_KEY_POLICY_TIME_OUT = "DM_POLICY_TIMEOUT"; constexpr const char* DEVICE_SCREEN_STATUS = "DEVICE_SCREEN_STATUS"; constexpr const char* PROCESS_NAME = "PROCESS_NAME"; constexpr const char* PARAM_CLOSE_SESSION_DELAY_SECONDS = "DM_CLOSE_SESSION_DELAY_SECONDS"; -constexpr const char* PARAM_ALLOW_AUTH_ALWAYS = "DM_AUTHENTICATION_TYPE"; // screen state constexpr int32_t DM_SCREEN_UNKNOWN = -1; -- Gitee From e5169368b095cc77a02fa848b4cebe82bf65eb65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 4 Jan 2025 10:27:39 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/include/dm_constants.h | 2 +- .../src/authentication/auth_message_processor.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 39459d157..9d5fee8c0 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -155,7 +155,6 @@ constexpr int32_t PKG_NAME_SIZE_MAX = 256; constexpr const char* DM_TYPE_MINE = "MINE"; constexpr const char* DM_TYPE_OH = "OH"; constexpr const char* TAG_SESSION_HEARTBEAT = "session_heartbeat"; -constexpr const char* TAG_ALLOW_AUTH_ALWAYS = "allow_auth_always"; //The following constant are provided only for HiLink. const static char *EXT_PART = "ext_part"; @@ -253,6 +252,7 @@ constexpr const char* PARAM_KEY_POLICY_TIME_OUT = "DM_POLICY_TIMEOUT"; constexpr const char* DEVICE_SCREEN_STATUS = "DEVICE_SCREEN_STATUS"; constexpr const char* PROCESS_NAME = "PROCESS_NAME"; constexpr const char* PARAM_CLOSE_SESSION_DELAY_SECONDS = "DM_CLOSE_SESSION_DELAY_SECONDS"; +constexpr const char* DM_ALLOW_AUTH_ALWAYS = "ALLOW_AUTH_ALWAYS"; // screen state constexpr int32_t DM_SCREEN_UNKNOWN = -1; diff --git a/services/implementation/src/authentication/auth_message_processor.cpp b/services/implementation/src/authentication/auth_message_processor.cpp index 921adb172..317158e04 100644 --- a/services/implementation/src/authentication/auth_message_processor.cpp +++ b/services/implementation/src/authentication/auth_message_processor.cpp @@ -72,9 +72,9 @@ void AuthMessageProcessor::GetJsonObj(nlohmann::json &jsonObj) jsonObj[TAG_IS_SHOW_DIALOG] = true; } if (authRequestContext_->allowAuthAlways) { - jsonObj[TAG_ALLOW_AUTH_ALWAYS] = true; + jsonObj[DM_ALLOW_AUTH_ALWAYS] = true; } else { - jsonObj[TAG_ALLOW_AUTH_ALWAYS] = false; + jsonObj[DM_ALLOW_AUTH_ALWAYS] = false; } jsonObj[TAG_APP_OPERATION] = authRequestContext_->appOperation; jsonObj[TAG_CUSTOM_DESCRIPTION] = authRequestContext_->customDesc; @@ -462,8 +462,8 @@ int32_t AuthMessageProcessor::ParseAuthRequestMessage(nlohmann::json &json) } else { authResponseContext_->isShowDialog = true; } - if (IsBool(json, TAG_ALLOW_AUTH_ALWAYS)) { - authResponseContext_->allowAuthAlways = json[TAG_ALLOW_AUTH_ALWAYS].get(); + if (IsBool(json, DM_ALLOW_AUTH_ALWAYS)) { + authResponseContext_->allowAuthAlways = json[DM_ALLOW_AUTH_ALWAYS].get(); } else { authResponseContext_->allowAuthAlways = false; } -- Gitee From ab047631bfe053a96be347521437f5bdb67c9e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 4 Jan 2025 10:32:26 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- services/implementation/src/authentication/dm_auth_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 9e9daff41..3ffcf1c54 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -278,7 +278,7 @@ void DmAuthManager::ParseJsonObject(nlohmann::json jsonObject) authRequestContext_->peerBundleName = authRequestContext_->hostPkgName; } authRequestContext_->allowAuthAlways = false; - if (IsString(jsonObject, PARAM_ALLOW_AUTH_ALWAYS)) { + if (IsString(jsonObject, DM_ALLOW_AUTH_ALWAYS)) { authRequestContext_->allowAuthAlways = true; } } -- Gitee From a5d4742a8b9ea8c3183b44bc25753b3b9e128eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 4 Jan 2025 14:33:44 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=B6=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../src/authentication/dm_auth_manager.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 3ffcf1c54..eb9efdb46 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -1353,10 +1353,6 @@ void DmAuthManager::SrcAuthenticateFinish() authUiStateMgr_->UpdateUiState(DmUiStateMsg::MSG_CANCEL_PIN_CODE_INPUT); } usleep(USLEEP_TIME_US_500000); // 500ms - listener_->OnAuthResult(processInfo_, peerTargetId_.deviceId, authRequestContext_->token, - authResponseContext_->state, authRequestContext_->reason); - listener_->OnBindResult(processInfo_, peerTargetId_, authRequestContext_->reason, - authResponseContext_->state, GenerateBindResultContent()); int32_t sessionId = authRequestContext_->sessionId; auto taskFunc = [this, sessionId]() { @@ -1368,6 +1364,11 @@ void DmAuthManager::SrcAuthenticateFinish() int32_t delaySeconds = authRequestContext_->closeSessionDelaySeconds; ffrt::submit(taskFunc, ffrt::task_attr().delay(delaySeconds * MICROSECOND_PER_SECOND)); + listener_->OnAuthResult(processInfo_, peerTargetId_.deviceId, authRequestContext_->token, + authResponseContext_->state, authRequestContext_->reason); + listener_->OnBindResult(processInfo_, peerTargetId_, authRequestContext_->reason, + authResponseContext_->state, GenerateBindResultContent()); + authRequestContext_ = nullptr; authRequestState_ = nullptr; authTimes_ = 0; -- Gitee From 2192b596ebeb94666279364a05efbc05d5b38ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Mon, 6 Jan 2025 11:50:11 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../include/authentication/dm_auth_manager.h | 5 ++-- .../authentication/auth_message_processor.cpp | 12 ++------ .../src/authentication/dm_auth_manager.cpp | 28 +++++++++++++------ 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index 670593ee0..1bcb7eb06 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -134,7 +134,7 @@ typedef struct DmAuthRequestContext { std::string addr; std::string hostPkgLabel; int32_t closeSessionDelaySeconds = 0; - bool allowAuthAlways = false; + int32_t userOperationType = USER_OPERATION_TYPE_ALLOW_AUTH; } DmAuthRequestContext; typedef struct DmAuthResponseContext { @@ -192,7 +192,7 @@ typedef struct DmAuthResponseContext { bool isFinish = false; std::string edition; int32_t localBindLevel; - bool allowAuthAlways = false; + int32_t userOperationType = USER_OPERATION_TYPE_ALLOW_AUTH; } DmAuthResponseContext; class AuthMessageProcessor; @@ -556,6 +556,7 @@ private: void ConverToFinish(); bool IsSinkMsgValid(); bool IsSourceMsgValid(); + int32_t GetUserOperationType(std::string &userOperationTypeStr); private: std::shared_ptr softbusConnector_; diff --git a/services/implementation/src/authentication/auth_message_processor.cpp b/services/implementation/src/authentication/auth_message_processor.cpp index 317158e04..bf4c42798 100644 --- a/services/implementation/src/authentication/auth_message_processor.cpp +++ b/services/implementation/src/authentication/auth_message_processor.cpp @@ -71,11 +71,6 @@ void AuthMessageProcessor::GetJsonObj(nlohmann::json &jsonObj) } else { jsonObj[TAG_IS_SHOW_DIALOG] = true; } - if (authRequestContext_->allowAuthAlways) { - jsonObj[DM_ALLOW_AUTH_ALWAYS] = true; - } else { - jsonObj[DM_ALLOW_AUTH_ALWAYS] = false; - } jsonObj[TAG_APP_OPERATION] = authRequestContext_->appOperation; jsonObj[TAG_CUSTOM_DESCRIPTION] = authRequestContext_->customDesc; jsonObj[TAG_APP_NAME] = authRequestContext_->appName; @@ -85,6 +80,7 @@ void AuthMessageProcessor::GetJsonObj(nlohmann::json &jsonObj) std::string itemStr = std::to_string(item); jsonObj[itemStr] = authResponseContext_->bindType[item]; } + jsonObj[DM_USER_OPERATION_TYPE] = authRequestContext_->userOperationType; } std::vector AuthMessageProcessor::CreateAuthRequestMessage() @@ -462,10 +458,8 @@ int32_t AuthMessageProcessor::ParseAuthRequestMessage(nlohmann::json &json) } else { authResponseContext_->isShowDialog = true; } - if (IsBool(json, DM_ALLOW_AUTH_ALWAYS)) { - authResponseContext_->allowAuthAlways = json[DM_ALLOW_AUTH_ALWAYS].get(); - } else { - authResponseContext_->allowAuthAlways = false; + if (IsInt32(json, DM_USER_OPERATION_TYPE)) { + authResponseContext_->userOperationType = json[DM_USER_OPERATION_TYPE].get(); } if (IsInt32(json, TAG_BIND_TYPE_SIZE)) { int32_t bindTypeSize = json[TAG_BIND_TYPE_SIZE].get(); diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index eb9efdb46..c84f95b83 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -277,14 +277,30 @@ void DmAuthManager::ParseJsonObject(nlohmann::json jsonObject) } else { authRequestContext_->peerBundleName = authRequestContext_->hostPkgName; } - authRequestContext_->allowAuthAlways = false; - if (IsString(jsonObject, DM_ALLOW_AUTH_ALWAYS)) { - authRequestContext_->allowAuthAlways = true; + authRequestContext_->userOperationType = USER_OPERATION_TYPE_ALLOW_AUTH; + if (IsString(jsonObject, DM_USER_OPERATION_TYPE)) { + std::string operatorTypeStr = jsonObject[DM_USER_OPERATION_TYPE].get(); + authRequestContext_->userOperationType = GetUserOperationType(operatorTypeStr); } } authRequestContext_->bundleName = GetBundleName(jsonObject); } +int32_t DmAuthManager::GetUserOperationType(std::string &userOperationTypeStr) +{ + int32_t userOperationType = USER_OPERATION_TYPE_ALLOW_AUTH; + if (!IsNumberString(userOperationStr)) { + LOGE("Invalid parameter, param is not number."); + return userOperationType; + } + userOperationType = std::atoi(userOperationStr.c_str()); + if (userOperationType < 0 || userOperationType > USER_OPERATION_TYPE_ALLOW_AUTH_ALWAYS) { + LOGE("Invalid parameter, param out of range."); + return userOperationType; + } + return userOperationType; +} + int32_t DmAuthManager::GetCloseSessionDelaySeconds(std::string &delaySecondsStr) { if (!IsNumberString(delaySecondsStr)) { @@ -1525,11 +1541,7 @@ void DmAuthManager::ShowConfigDialog() } if (!authResponseContext_->isShowDialog) { LOGI("start auth process"); - int32_t action = USER_OPERATION_TYPE_ALLOW_AUTH; - if (authResponseContext_->allowAuthAlways) { - action = USER_OPERATION_TYPE_ALLOW_AUTH_ALWAYS; - } - StartAuthProcess(action); + StartAuthProcess(authResponseContext_->userOperationType); return; } LOGI("ShowConfigDialog start"); -- Gitee From 658300be96ccb490572911611e40a3aa56c5ddd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Mon, 6 Jan 2025 11:55:00 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/include/dm_constants.h | 2 +- .../src/authentication/auth_message_processor.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 9d5fee8c0..f070ce2b8 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -252,7 +252,7 @@ constexpr const char* PARAM_KEY_POLICY_TIME_OUT = "DM_POLICY_TIMEOUT"; constexpr const char* DEVICE_SCREEN_STATUS = "DEVICE_SCREEN_STATUS"; constexpr const char* PROCESS_NAME = "PROCESS_NAME"; constexpr const char* PARAM_CLOSE_SESSION_DELAY_SECONDS = "DM_CLOSE_SESSION_DELAY_SECONDS"; -constexpr const char* DM_ALLOW_AUTH_ALWAYS = "ALLOW_AUTH_ALWAYS"; +constexpr const char* DM_USER_OPERATION_TYPE = "DM_USER_OPERATION_TYPE"; // screen state constexpr int32_t DM_SCREEN_UNKNOWN = -1; diff --git a/services/implementation/src/authentication/auth_message_processor.cpp b/services/implementation/src/authentication/auth_message_processor.cpp index bf4c42798..ddbac7173 100644 --- a/services/implementation/src/authentication/auth_message_processor.cpp +++ b/services/implementation/src/authentication/auth_message_processor.cpp @@ -458,6 +458,7 @@ int32_t AuthMessageProcessor::ParseAuthRequestMessage(nlohmann::json &json) } else { authResponseContext_->isShowDialog = true; } + authResponseContext_->userOperationType = USER_OPERATION_TYPE_ALLOW_AUTH; if (IsInt32(json, DM_USER_OPERATION_TYPE)) { authResponseContext_->userOperationType = json[DM_USER_OPERATION_TYPE].get(); } -- Gitee From c91da51f2a8ebc9e176691684a5a3855da468a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Mon, 6 Jan 2025 14:29:06 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../src/authentication/dm_auth_manager.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index c84f95b83..1a73d2354 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -288,15 +288,14 @@ void DmAuthManager::ParseJsonObject(nlohmann::json jsonObject) int32_t DmAuthManager::GetUserOperationType(std::string &userOperationTypeStr) { - int32_t userOperationType = USER_OPERATION_TYPE_ALLOW_AUTH; - if (!IsNumberString(userOperationStr)) { + if (!IsNumberString(userOperationTypeStr)) { LOGE("Invalid parameter, param is not number."); - return userOperationType; + return USER_OPERATION_TYPE_ALLOW_AUTH; } - userOperationType = std::atoi(userOperationStr.c_str()); + int32_t userOperationType = std::atoi(userOperationTypeStr.c_str()); if (userOperationType < 0 || userOperationType > USER_OPERATION_TYPE_ALLOW_AUTH_ALWAYS) { LOGE("Invalid parameter, param out of range."); - return userOperationType; + return USER_OPERATION_TYPE_ALLOW_AUTH; } return userOperationType; } -- Gitee From 8a1855c8e80f056d8bf880301fea42636d717dfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Mon, 6 Jan 2025 20:28:23 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../src/authentication/auth_message_processor.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/implementation/src/authentication/auth_message_processor.cpp b/services/implementation/src/authentication/auth_message_processor.cpp index ddbac7173..5c1404db5 100644 --- a/services/implementation/src/authentication/auth_message_processor.cpp +++ b/services/implementation/src/authentication/auth_message_processor.cpp @@ -460,7 +460,12 @@ int32_t AuthMessageProcessor::ParseAuthRequestMessage(nlohmann::json &json) } authResponseContext_->userOperationType = USER_OPERATION_TYPE_ALLOW_AUTH; if (IsInt32(json, DM_USER_OPERATION_TYPE)) { - authResponseContext_->userOperationType = json[DM_USER_OPERATION_TYPE].get(); + int32_t userOperationType = json[DM_USER_OPERATION_TYPE].get(); + if (userOperationType < 0 || userOperationType > USER_OPERATION_TYPE_ALLOW_AUTH_ALWAYS) { + authResponseContext_->userOperationType = USER_OPERATION_TYPE_ALLOW_AUTH; + } else { + authResponseContext_->userOperationType = userOperationType; + } } if (IsInt32(json, TAG_BIND_TYPE_SIZE)) { int32_t bindTypeSize = json[TAG_BIND_TYPE_SIZE].get(); -- Gitee