diff --git a/common/include/dm_error_type.h b/common/include/dm_error_type.h index 753c754f23597329907bfd04f835913e3d8dc16c..0bca1de1bbf53d8f18f418ade87cc96e8c8fb410 100644 --- a/common/include/dm_error_type.h +++ b/common/include/dm_error_type.h @@ -144,6 +144,7 @@ enum { ERR_DM_DEVICE_FROZEN = 969298355, ERR_DM_SOCKET_IN_USED = 969298356, ERR_DM_ANTI_DISTURB_MODE = 969298357, + ERR_DM_SKIP_AUTHENTICATE = 969298358, }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/implementation/include/authentication_v2/dm_auth_context.h b/services/implementation/include/authentication_v2/dm_auth_context.h index e60adda5c2876c443aa42a3f23cb2ea0034c5cdb..4bb875565c97ec79afae064737bdb30235449cd7 100644 --- a/services/implementation/include/authentication_v2/dm_auth_context.h +++ b/services/implementation/include/authentication_v2/dm_auth_context.h @@ -278,7 +278,7 @@ struct DmAuthContext { bool IsProxyBind{false}; bool IsCallingProxyAsSubject{true}; bool IsNeedSetProxy{false}; - bool isNeedAuthorize{false}; + bool isNeedAuthenticate{true}; // apply for skip authenticate std::vector subjectProxyOnes; std::string reUseCreId; std::string title; diff --git a/services/implementation/include/authentication_v2/dm_auth_manager_base.h b/services/implementation/include/authentication_v2/dm_auth_manager_base.h index c680323a42aa2443360017c9edf8a8c3c738c270..0713e8d2e408e0f665de7ef661c606b38a43db9e 100644 --- a/services/implementation/include/authentication_v2/dm_auth_manager_base.h +++ b/services/implementation/include/authentication_v2/dm_auth_manager_base.h @@ -57,7 +57,7 @@ extern const char* TAG_HOST_PKGLABEL; extern const char* TAG_REMOTE_DEVICE_NAME; extern const char* TAG_HOST; extern const char* TAG_PROXY_CONTEXT_ID; - +extern const char* TAG_IS_NEED_AUTHENTICATE; extern const char* APP_OPERATION_KEY; extern const char* TARGET_PKG_NAME_KEY; extern const char* CUSTOM_DESCRIPTION_KEY; diff --git a/services/implementation/src/authentication_v2/auth_manager.cpp b/services/implementation/src/authentication_v2/auth_manager.cpp index ad9835e7c3ebe9ee8168563c6e0316ada515f56e..57cf57f50f064af497c6d9ee1945770f50b2ab98 100644 --- a/services/implementation/src/authentication_v2/auth_manager.cpp +++ b/services/implementation/src/authentication_v2/auth_manager.cpp @@ -448,7 +448,6 @@ void AuthManager::ParseJsonObject(const JsonObject &jsonObject) std::string delaySecondsStr = jsonObject[PARAM_CLOSE_SESSION_DELAY_SECONDS].Get(); context_->connDelayCloseTime = GetCloseSessionDelaySeconds(delaySecondsStr); } - context_->accessee.bundleName = context_->accesser.bundleName; if (jsonObject[TAG_PEER_BUNDLE_NAME].IsString() && !jsonObject[TAG_PEER_BUNDLE_NAME].Get().empty()) { context_->accessee.bundleName = jsonObject[TAG_PEER_BUNDLE_NAME].Get(); @@ -456,14 +455,11 @@ void AuthManager::ParseJsonObject(const JsonObject &jsonObject) } else { context_->accessee.oldBundleName = context_->pkgName; } - context_->accesser.pkgName = context_->pkgName; context_->accessee.pkgName = context_->accesser.pkgName; - if (jsonObject[TAG_PEER_PKG_NAME].IsString()) { context_->accessee.pkgName = jsonObject[TAG_PEER_PKG_NAME].Get(); } - if (jsonObject[TAG_PEER_DISPLAY_ID].IsNumberInteger()) { context_->accessee.displayId = jsonObject[TAG_PEER_DISPLAY_ID].Get(); } @@ -472,11 +468,13 @@ void AuthManager::ParseJsonObject(const JsonObject &jsonObject) } else { context_->accesser.userId = MultipleUserConnector::GetFirstForegroundUserId(); } - + if (jsonObject[TAG_IS_NEED_AUTHENTICATE].IsString()) { + context_->isNeedAuthenticate = std::atoi(jsonObject[TAG_IS_NEED_AUTHENTICATE].Get()); + LOGI("isNeedAuthenticate: %{public}d.", context_->isNeedAuthenticate); + } if (context_->authType == AUTH_TYPE_PIN_ULTRASONIC) { ParseUltrasonicSide(jsonObject); } - ParseHmlInfoInJsonObject(jsonObject); ParseProxyJsonObject(jsonObject); return; @@ -972,8 +970,14 @@ void AuthSrcManager::AuthDeviceFinish(int64_t requestId) DmAuthStateType curState = context_->authStateMachine->GetCurState(); switch (curState) { case DmAuthStateType::AUTH_SRC_PIN_AUTH_DONE_STATE: - // ON_FINISH event occurs, start credential exchange - context_->authStateMachine->TransitionTo(std::make_shared()); + if (!context_->isNeedAuthenticate) { + LOGI("skip authenticate."); + context_->reason = ERR_DM_SKIP_AUTHENTICATE; + context_->authStateMachine->TransitionTo(std::make_shared()); + } else { + // ON_FINISH event occurs, start credential exchange + context_->authStateMachine->TransitionTo(std::make_shared()); + } break; default: break; diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_acl.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_acl.cpp index d6d13bfc97b5c14cbd15aa17988e683cba51a894..10f7cacfdc9f28d6f35763b035d602ec1648b557 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_acl.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_acl.cpp @@ -231,7 +231,10 @@ DmAuthStateType AuthSinkFinishState::GetStateType() int32_t AuthSrcFinishState::Action(std::shared_ptr context) { LOGI("AuthSrcFinishState::Action start"); - if (context->reason != DM_OK && context->reason != DM_BIND_TRUST_TARGET) { + if (context->reason == ERR_DM_SKIP_AUTHENTICATE && !context->isNeedAuthenticate) { + context->authMessageProcessor->CreateAndSendMsg(MSG_TYPE_AUTH_REQ_FINISH, context); + context->state = static_cast(GetStateType()); + } else if (context->reason != DM_OK && context->reason != DM_BIND_TRUST_TARGET) { context->authMessageProcessor->CreateAndSendMsg(MSG_TYPE_AUTH_REQ_FINISH, context); } else { context->state = static_cast(GetStateType()); diff --git a/services/implementation/src/authentication_v2/dm_auth_manager_base.cpp b/services/implementation/src/authentication_v2/dm_auth_manager_base.cpp index 3c9fb29de51fa0b2b83b89d63e1db4e3bbe2f57a..26e7781d5233e706b1cc947481f06977734f07f8 100644 --- a/services/implementation/src/authentication_v2/dm_auth_manager_base.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_manager_base.cpp @@ -58,7 +58,7 @@ const char* TAG_HOST_PKGLABEL = "hostPkgLabel"; const char* TAG_REMOTE_DEVICE_NAME = "REMOTE_DEVICE_NAME"; const char* TAG_HOST = "HOST"; const char* TAG_PROXY_CONTEXT_ID = "proxyContextId"; - +const char* TAG_IS_NEED_AUTHENTICATE = "isNeedAuthenticate"; const char* APP_OPERATION_KEY = "appOperation"; const char* TARGET_PKG_NAME_KEY = "targetPkgName"; const char* CUSTOM_DESCRIPTION_KEY = "customDescription"; diff --git a/services/implementation/src/authentication_v2/dm_auth_state.cpp b/services/implementation/src/authentication_v2/dm_auth_state.cpp index a8da668324b9563fbbd500f756a8933fbf9f05ef..200483586313cea6b5010e396a149f3d09c35f71 100644 --- a/services/implementation/src/authentication_v2/dm_auth_state.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_state.cpp @@ -76,7 +76,8 @@ const std::map NEW_AND_OLD_STATE_MAPPING = { const std::map NEW_AND_OLD_REPLAY_MAPPING = { { DM_ALREADY_AUTHED, SOFTBUS_OK }, { SOFTBUS_OK, SOFTBUS_OK }, - { DM_BIND_TRUST_TARGET, DM_OK } + { DM_BIND_TRUST_TARGET, DM_OK }, + { ERR_DM_SKIP_AUTHENTICATE, DM_OK }, }; int32_t DmAuthState::GetTaskTimeout(std::shared_ptr context, const char* taskName, int32_t taskTimeOut)