From a953e75b628485376a18a1c48b3d1541e01ee71a Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Thu, 12 Dec 2024 21:34:15 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- .../include/authentication/auth_response_state.h | 6 ++++++ .../include/authentication/dm_auth_manager.h | 2 ++ .../src/authentication/auth_request_state.cpp | 10 ++++++++++ .../src/authentication/auth_response_state.cpp | 10 ++++++++++ .../src/authentication/dm_auth_manager.cpp | 6 +++++- 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/services/implementation/include/authentication/auth_response_state.h b/services/implementation/include/authentication/auth_response_state.h index c84a83aeb..cbf9eb912 100644 --- a/services/implementation/include/authentication/auth_response_state.h +++ b/services/implementation/include/authentication/auth_response_state.h @@ -112,6 +112,12 @@ public: int32_t GetStateType() override; int32_t Enter() override; }; + +class AuthResponseAuthFinish : public AuthResponseState { +public: + int32_t GetStateType() override; + int32_t Enter() override; +}; } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DM_AUTH_RESPONSE_STATE_H diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index 75d187561..a76f33771 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -47,6 +47,7 @@ typedef enum AuthState { AUTH_REQUEST_FINISH, AUTH_REQUEST_CREDENTIAL, AUTH_REQUEST_CREDENTIAL_DONE, + AUTH_REQUEST_AUTH_FINISH, AUTH_RESPONSE_INIT = 20, AUTH_RESPONSE_NEGOTIATE, @@ -55,6 +56,7 @@ typedef enum AuthState { AUTH_RESPONSE_SHOW, AUTH_RESPONSE_FINISH, AUTH_RESPONSE_CREDENTIAL, + AUTH_RESPONSE_AUTH_FINISH, } AuthState; enum DmMsgType : int32_t { diff --git a/services/implementation/src/authentication/auth_request_state.cpp b/services/implementation/src/authentication/auth_request_state.cpp index 7181d2947..8dbcb3b84 100644 --- a/services/implementation/src/authentication/auth_request_state.cpp +++ b/services/implementation/src/authentication/auth_request_state.cpp @@ -204,5 +204,15 @@ int32_t AuthRequestCredentialDone::Enter() stateAuthManager->RequestCredentialDone(); return DM_OK; } + +int32_t AuthRequestAuthFinish::GetStateType() +{ + return AuthState::AUTH_REQUEST_AUTH_FINISH; +} + +int32_t AuthRequestAuthFinish::Enter() +{ + return DM_OK; +} } // namespace DistributedHardware } // namespace OHOS diff --git a/services/implementation/src/authentication/auth_response_state.cpp b/services/implementation/src/authentication/auth_response_state.cpp index 7f1803fa0..afe61b0dc 100644 --- a/services/implementation/src/authentication/auth_response_state.cpp +++ b/services/implementation/src/authentication/auth_response_state.cpp @@ -168,5 +168,15 @@ int32_t AuthResponseCredential::Enter() stateAuthManager->ResponseCredential(); return DM_OK; } + +int32_t AuthResponseAuthFinish::GetStateType() +{ + return AuthState::AUTH_RESPONSE_AUTH_FINISH; +} + +int32_t AuthResponseAuthFinish::Enter() +{ + return DM_OK; +} } // namespace DistributedHardware } // namespace OHOS diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index a7772eb63..18610d61c 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -545,7 +545,7 @@ void DmAuthManager::ProcessSinkMsg() } break; case MSG_TYPE_REQ_PUBLICKEY: - if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_SHOW) { + if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_AUTH_FINISH) { authResponseState_->TransitionTo(std::make_shared()); } break; @@ -1984,6 +1984,8 @@ bool DmAuthManager::AuthDeviceTransmit(int64_t requestId, const uint8_t *data, u void DmAuthManager::SrcAuthDeviceFinish() { + CHECK_NULL_VOID(authRequestState_); + authRequestState_->TransitionTo(std::make_shared()); if (authResponseContext_->isOnline) { if (authResponseContext_->confirmOperation == USER_OPERATION_TYPE_ALLOW_AUTH || (authResponseContext_->confirmOperation == USER_OPERATION_TYPE_ALLOW_AUTH_ALWAYS && @@ -2030,6 +2032,8 @@ void DmAuthManager::SrcAuthDeviceFinish() void DmAuthManager::SinkAuthDeviceFinish() { + CHECK_NULL_VOID(authResponseState_); + authResponseState_->TransitionTo(std::make_shared()); if (!authResponseContext_->haveCredential) { authUiStateMgr_->UpdateUiState(DmUiStateMsg::MSG_CANCEL_PIN_CODE_SHOW); } -- Gitee From 4f7219bb4b9b5649b0bbe341cdaa50d85fbbc44b Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Thu, 12 Dec 2024 21:38:54 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- .../src/dependency/hichain/hichain_auth_connector.cpp | 2 +- .../implementation/src/dependency/hichain/hichain_connector.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp index f0614dcf2..af17a8237 100644 --- a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp @@ -102,7 +102,7 @@ char *HiChainAuthConnector::onRequest(int64_t requestId, int operationCode, cons } nlohmann::json jsonObj; int32_t pinCode = -1; - if (dmDeviceAuthCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == -1) { + if (dmDeviceAuthCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == -1 || pinCode = 0) { jsonObj[FIELD_CONFIRMATION] = RequestResponse::REQUEST_REJECTED; } else { jsonObj[FIELD_CONFIRMATION] = RequestResponse::REQUEST_ACCEPTED; diff --git a/services/implementation/src/dependency/hichain/hichain_connector.cpp b/services/implementation/src/dependency/hichain/hichain_connector.cpp index c1b4f837b..99d8554dd 100644 --- a/services/implementation/src/dependency/hichain/hichain_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_connector.cpp @@ -476,7 +476,7 @@ char *HiChainConnector::onRequest(int64_t requestId, int operationCode, const ch } nlohmann::json jsonObj; int32_t pinCode = -1; - if (hiChainConnectorCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == -1) { + if (hiChainConnectorCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == -1 || pinCode == 0) { jsonObj[FIELD_CONFIRMATION] = REQUEST_REJECTED; } else { jsonObj[FIELD_CONFIRMATION] = REQUEST_ACCEPTED; -- Gitee From 73bb81fd728bc6581f062f71c967e1e9f674011c Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Thu, 12 Dec 2024 21:51:49 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- .../include/authentication/auth_request_state.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/implementation/include/authentication/auth_request_state.h b/services/implementation/include/authentication/auth_request_state.h index 05b4642df..997012de7 100644 --- a/services/implementation/include/authentication/auth_request_state.h +++ b/services/implementation/include/authentication/auth_request_state.h @@ -193,6 +193,12 @@ public: int32_t GetStateType() override; int32_t Enter() override; }; + +class AuthRequestAuthFinish : public AuthRequestState { +public: + int32_t GetStateType() override; + int32_t Enter() override; +}; } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DM_AUTH_REQUEST_STATE_H -- Gitee From 6ff07878d27d8fca1d8a3e07d8a8ea2e2be32c5f Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Thu, 12 Dec 2024 22:16:07 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- .../implementation/include/authentication/dm_auth_manager.h | 2 +- .../src/dependency/hichain/hichain_auth_connector.cpp | 2 +- .../implementation/src/dependency/hichain/hichain_connector.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index a76f33771..ee3d12ba8 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -158,7 +158,7 @@ typedef struct DmAuthResponseContext { std::string authToken; int32_t pageId; int64_t requestId; - int32_t code; + int32_t code = -1; int32_t state; std::vector syncGroupList; std::string accountGroupIdHash; diff --git a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp index af17a8237..f0614dcf2 100644 --- a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp @@ -102,7 +102,7 @@ char *HiChainAuthConnector::onRequest(int64_t requestId, int operationCode, cons } nlohmann::json jsonObj; int32_t pinCode = -1; - if (dmDeviceAuthCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == -1 || pinCode = 0) { + if (dmDeviceAuthCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == -1) { jsonObj[FIELD_CONFIRMATION] = RequestResponse::REQUEST_REJECTED; } else { jsonObj[FIELD_CONFIRMATION] = RequestResponse::REQUEST_ACCEPTED; diff --git a/services/implementation/src/dependency/hichain/hichain_connector.cpp b/services/implementation/src/dependency/hichain/hichain_connector.cpp index 99d8554dd..c1b4f837b 100644 --- a/services/implementation/src/dependency/hichain/hichain_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_connector.cpp @@ -476,7 +476,7 @@ char *HiChainConnector::onRequest(int64_t requestId, int operationCode, const ch } nlohmann::json jsonObj; int32_t pinCode = -1; - if (hiChainConnectorCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == -1 || pinCode == 0) { + if (hiChainConnectorCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == -1) { jsonObj[FIELD_CONFIRMATION] = REQUEST_REJECTED; } else { jsonObj[FIELD_CONFIRMATION] = REQUEST_ACCEPTED; -- Gitee From 617f425714ab27f7e6024a09f50d85162ec7f90f Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Thu, 12 Dec 2024 23:09:10 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- common/include/dm_constants.h | 1 + .../implementation/include/authentication/dm_auth_manager.h | 2 +- .../src/dependency/hichain/hichain_auth_connector.cpp | 4 ++-- .../src/dependency/hichain/hichain_connector.cpp | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 09bfd45bd..db934c5b1 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -166,6 +166,7 @@ constexpr int32_t CHECK_AUTH_ALWAYS_POS = 0; constexpr const char AUTH_ALWAYS = '1'; constexpr const char AUTH_ONCE = '0'; constexpr const char* TAG_TARGET_DEVICE_NAME = "targetDeviceName"; +constexpr int32_t INVALIED_PINCODE = -1; // HiChain constexpr int32_t SERVICE_INIT_TRY_MAX_NUM = 200; diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index ee3d12ba8..d07198741 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -158,7 +158,7 @@ typedef struct DmAuthResponseContext { std::string authToken; int32_t pageId; int64_t requestId; - int32_t code = -1; + int32_t code = INVALIED_PINCODE; int32_t state; std::vector syncGroupList; std::string accountGroupIdHash; diff --git a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp index f0614dcf2..c339027a2 100644 --- a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp @@ -101,8 +101,8 @@ char *HiChainAuthConnector::onRequest(int64_t requestId, int operationCode, cons return nullptr; } nlohmann::json jsonObj; - int32_t pinCode = -1; - if (dmDeviceAuthCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == -1) { + int32_t pinCode = INVALIED_PINCODE; + if (dmDeviceAuthCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == INVALIED_PINCODE) { jsonObj[FIELD_CONFIRMATION] = RequestResponse::REQUEST_REJECTED; } else { jsonObj[FIELD_CONFIRMATION] = RequestResponse::REQUEST_ACCEPTED; diff --git a/services/implementation/src/dependency/hichain/hichain_connector.cpp b/services/implementation/src/dependency/hichain/hichain_connector.cpp index c1b4f837b..3458f228b 100644 --- a/services/implementation/src/dependency/hichain/hichain_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_connector.cpp @@ -475,8 +475,8 @@ char *HiChainConnector::onRequest(int64_t requestId, int operationCode, const ch return nullptr; } nlohmann::json jsonObj; - int32_t pinCode = -1; - if (hiChainConnectorCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == -1) { + int32_t pinCode = INVALIED_PINCODE; + if (hiChainConnectorCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == INVALIED_PINCODE) { jsonObj[FIELD_CONFIRMATION] = REQUEST_REJECTED; } else { jsonObj[FIELD_CONFIRMATION] = REQUEST_ACCEPTED; -- Gitee From 95d0d7ebd2a76bc7d8ee4e23da9e2c1177da1c1c Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Thu, 12 Dec 2024 23:29:10 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- common/include/dm_constants.h | 2 +- .../implementation/include/authentication/dm_auth_manager.h | 2 +- .../src/dependency/hichain/hichain_auth_connector.cpp | 4 ++-- .../src/dependency/hichain/hichain_connector.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index db934c5b1..50b550689 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -166,7 +166,7 @@ constexpr int32_t CHECK_AUTH_ALWAYS_POS = 0; constexpr const char AUTH_ALWAYS = '1'; constexpr const char AUTH_ONCE = '0'; constexpr const char* TAG_TARGET_DEVICE_NAME = "targetDeviceName"; -constexpr int32_t INVALIED_PINCODE = -1; +constexpr int32_t INVALID_PINCODE = -1; // HiChain constexpr int32_t SERVICE_INIT_TRY_MAX_NUM = 200; diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index d07198741..70c6dd645 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -158,7 +158,7 @@ typedef struct DmAuthResponseContext { std::string authToken; int32_t pageId; int64_t requestId; - int32_t code = INVALIED_PINCODE; + int32_t code = INVALID_PINCODE; int32_t state; std::vector syncGroupList; std::string accountGroupIdHash; diff --git a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp index c339027a2..ddedb35df 100644 --- a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp @@ -101,8 +101,8 @@ char *HiChainAuthConnector::onRequest(int64_t requestId, int operationCode, cons return nullptr; } nlohmann::json jsonObj; - int32_t pinCode = INVALIED_PINCODE; - if (dmDeviceAuthCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == INVALIED_PINCODE) { + int32_t pinCode = INVALID_PINCODE; + if (dmDeviceAuthCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == INVALID_PINCODE) { jsonObj[FIELD_CONFIRMATION] = RequestResponse::REQUEST_REJECTED; } else { jsonObj[FIELD_CONFIRMATION] = RequestResponse::REQUEST_ACCEPTED; diff --git a/services/implementation/src/dependency/hichain/hichain_connector.cpp b/services/implementation/src/dependency/hichain/hichain_connector.cpp index 3458f228b..2dc7efda6 100644 --- a/services/implementation/src/dependency/hichain/hichain_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_connector.cpp @@ -475,8 +475,8 @@ char *HiChainConnector::onRequest(int64_t requestId, int operationCode, const ch return nullptr; } nlohmann::json jsonObj; - int32_t pinCode = INVALIED_PINCODE; - if (hiChainConnectorCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == INVALIED_PINCODE) { + int32_t pinCode = INVALID_PINCODE; + if (hiChainConnectorCallback_->GetPinCode(pinCode) == ERR_DM_FAILED || pinCode == INVALID_PINCODE) { jsonObj[FIELD_CONFIRMATION] = REQUEST_REJECTED; } else { jsonObj[FIELD_CONFIRMATION] = REQUEST_ACCEPTED; -- Gitee