1 /* 2 * Copyright (c) 2022-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_DM_AUTH_MANAGER_H 17 #define OHOS_DM_AUTH_MANAGER_H 18 #define TYPE_TV_ID 0x9C 19 20 #include <map> 21 #include <mutex> 22 #include <string> 23 24 #include "auth_request_state.h" 25 #include "auth_response_state.h" 26 #include "auth_ui_state_manager.h" 27 #include "authentication.h" 28 #include "idevice_manager_service_listener.h" 29 #include "deviceprofile_connector.h" 30 #include "dm_ability_manager.h" 31 #include "dm_adapter_manager.h" 32 #include "dm_auth_manager_base.h" 33 #include "dm_constants.h" 34 #include "dm_device_info.h" 35 #include "dm_timer.h" 36 #include "hichain_auth_connector.h" 37 #include "hichain_connector.h" 38 #include "service_info_unique_key.h" 39 #include "softbus_connector.h" 40 #include "softbus_session.h" 41 42 namespace OHOS { 43 namespace DistributedHardware { 44 typedef enum AuthState { 45 AUTH_REQUEST_INIT = 1, 46 AUTH_REQUEST_NEGOTIATE, 47 AUTH_REQUEST_NEGOTIATE_DONE, 48 AUTH_REQUEST_REPLY, 49 AUTH_REQUEST_JOIN, 50 AUTH_REQUEST_NETWORK, 51 AUTH_REQUEST_FINISH, 52 AUTH_REQUEST_CREDENTIAL, 53 AUTH_REQUEST_CREDENTIAL_DONE, 54 AUTH_REQUEST_AUTH_FINISH, 55 AUTH_REQUEST_RECHECK_MSG, 56 AUTH_REQUEST_RECHECK_MSG_DONE, 57 58 AUTH_RESPONSE_INIT = 20, 59 AUTH_RESPONSE_NEGOTIATE, 60 AUTH_RESPONSE_CONFIRM, 61 AUTH_RESPONSE_GROUP, 62 AUTH_RESPONSE_SHOW, 63 AUTH_RESPONSE_FINISH, 64 AUTH_RESPONSE_CREDENTIAL, 65 AUTH_RESPONSE_AUTH_FINISH, 66 AUTH_RESPONSE_RECHECK_MSG, 67 } AuthState; 68 69 enum DmMsgType : int32_t { 70 MSG_TYPE_UNKNOWN = 0, 71 MSG_TYPE_NEGOTIATE = 80, 72 MSG_TYPE_RESP_NEGOTIATE = 90, 73 MSG_TYPE_REQ_AUTH = 100, 74 MSG_TYPE_INVITE_AUTH_INFO = 102, 75 MSG_TYPE_REQ_AUTH_TERMINATE = 104, 76 MSG_TYPE_RESP_AUTH = 200, 77 MSG_TYPE_JOIN_AUTH_INFO = 201, 78 MSG_TYPE_RESP_AUTH_TERMINATE = 205, 79 MSG_TYPE_CHANNEL_CLOSED = 300, 80 MSG_TYPE_SYNC_GROUP = 400, 81 MSG_TYPE_AUTH_BY_PIN = 500, 82 83 MSG_TYPE_RESP_AUTH_EXT, 84 MSG_TYPE_REQ_PUBLICKEY, 85 MSG_TYPE_RESP_PUBLICKEY, 86 MSG_TYPE_REQ_RECHECK_MSG, 87 MSG_TYPE_RESP_RECHECK_MSG, 88 MSG_TYPE_REQ_AUTH_DEVICE_NEGOTIATE = 600, 89 MSG_TYPE_RESP_AUTH_DEVICE_NEGOTIATE = 700, 90 }; 91 92 enum DmAuthType : int32_t { 93 AUTH_TYPE_CRE = 0, 94 AUTH_TYPE_PIN, 95 AUTH_TYPE_QR_CODE, 96 AUTH_TYPE_NFC, 97 AUTH_TYPE_NO_INTER_ACTION, 98 AUTH_TYPE_IMPORT_AUTH_CODE, 99 AUTH_TYPE_UNKNOW, 100 }; 101 102 typedef struct DmAuthRequestContext { 103 int32_t authType; 104 std::string localDeviceId; 105 std::string localDeviceName; 106 int32_t localDeviceTypeId; 107 std::string deviceId; 108 std::string deviceName; 109 std::string deviceTypeId; 110 int32_t sessionId; 111 int32_t groupVisibility; 112 bool cryptoSupport; 113 std::string cryptoName; 114 std::string cryptoVer; 115 std::string hostPkgName; 116 std::string targetPkgName; 117 std::string bundleName; 118 std::string peerBundleName; 119 std::string appOperation; 120 std::string appDesc; 121 std::string appName; 122 std::string customDesc; 123 std::string appThumbnail; 124 std::string token; 125 int32_t reason; 126 std::vector<std::string> syncGroupList; 127 std::string dmVersion; 128 int32_t localUserId; 129 std::string localAccountId; 130 std::vector<int32_t> bindType; 131 bool isOnline; 132 bool authed; 133 int32_t bindLevel; 134 int64_t tokenId; 135 std::string remoteAccountId; 136 int32_t remoteUserId; 137 std::string addr; 138 std::string hostPkgLabel; 139 int32_t closeSessionDelaySeconds = 0; 140 std::string remoteDeviceName; 141 std::string connSessionType; 142 int32_t hmlActionId = 0; 143 bool hmlEnable160M = false; 144 } DmAuthRequestContext; 145 146 typedef struct DmAuthResponseContext { 147 int32_t authType; 148 std::string deviceId; 149 std::string localDeviceId; 150 std::string deviceName; 151 int32_t deviceTypeId; 152 int32_t msgType; 153 int32_t sessionId; 154 bool cryptoSupport; 155 bool isIdenticalAccount; 156 bool isAuthCodeReady; 157 bool isShowDialog; 158 std::string cryptoName; 159 std::string cryptoVer; 160 int32_t reply; 161 std::string networkId; 162 std::string groupId; 163 std::string groupName; 164 std::string hostPkgName; 165 std::string targetPkgName; 166 std::string bundleName; 167 std::string peerBundleName; 168 std::string appOperation; 169 std::string appDesc; 170 std::string customDesc; 171 std::string appIcon; 172 std::string appThumbnail; 173 std::string token; 174 std::string authToken; 175 int32_t pageId; 176 int64_t requestId; 177 std::string code = ""; 178 int32_t state; 179 std::vector<std::string> syncGroupList; 180 std::string accountGroupIdHash; 181 std::string publicKey; 182 bool isOnline; 183 int32_t bindLevel; 184 bool haveCredential; 185 int32_t confirmOperation; 186 std::string localAccountId; 187 int32_t localUserId; 188 int64_t tokenId; 189 int64_t remoteTokenId; 190 bool authed; 191 std::string dmVersion; 192 std::vector<int32_t> bindType; 193 std::string remoteAccountId; 194 int32_t remoteUserId; 195 std::string targetDeviceName; 196 std::string importAuthCode; 197 std::string hostPkgLabel; 198 bool isFinish = false; 199 std::string edition; 200 int32_t localBindLevel; 201 std::string remoteDeviceName; 202 int32_t localSessionKeyId = 0; 203 int32_t remoteSessionKeyId = 0; 204 } DmAuthResponseContext; 205 206 class AuthMessageProcessor; 207 208 class DmAuthManager final : public AuthManagerBase, 209 public std::enable_shared_from_this<DmAuthManager> { 210 public: 211 DmAuthManager(std::shared_ptr<SoftbusConnector> softbusConnector, 212 std::shared_ptr<HiChainConnector> hiChainConnector, 213 std::shared_ptr<IDeviceManagerServiceListener> listener, 214 std::shared_ptr<HiChainAuthConnector> hiChainAuthConnector); 215 ~DmAuthManager(); 216 217 /** 218 * @tc.name: DmAuthManager::AuthenticateDevice 219 * @tc.desc: Authenticate Device of the DeviceManager Authenticate Manager 220 * @tc.type: FUNC 221 */ 222 int32_t AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId, 223 const std::string &extra); 224 225 /** 226 * @tc.name: DmAuthManager::UnAuthenticateDevice 227 * @tc.desc: UnAuthenticate Device of the DeviceManager Authenticate Manager 228 * @tc.type: FUNC 229 */ 230 int32_t UnAuthenticateDevice(const std::string &pkgName, const std::string &udid, int32_t bindLevel); 231 232 /** 233 * @brief UnBind device. 234 * @param pkgName package name. 235 * @param deviceId device id. 236 * @return Return 0 if success. 237 */ 238 int32_t UnBindDevice(const std::string &pkgName, const std::string &udid, 239 int32_t bindLevel, const std::string &extra); 240 241 /** 242 * @tc.name: DmAuthManager::OnSessionOpened 243 * @tc.desc: Opened Session of the DeviceManager Authenticate Manager 244 * @tc.type: FUNC 245 */ 246 void OnSessionOpened(int32_t sessionId, int32_t sessionSide, int32_t result); 247 248 /** 249 * @tc.name: DmAuthManager::OnSessionClosed 250 * @tc.desc: Closed Session of the DeviceManager Authenticate Manager 251 * @tc.type: FUNC 252 */ 253 void OnSessionClosed(const int32_t sessionId); 254 255 /** 256 * @tc.name: DmAuthManager::OnDataReceived 257 * @tc.desc: Received Data of the DeviceManager Authenticate Manager 258 * @tc.type: FUNC 259 */ 260 void OnDataReceived(const int32_t sessionId, const std::string message); 261 262 /** 263 * @tc.name: DmAuthManager::OnSoftbusJoinLNNResult 264 * @tc.desc: OnSoftbus JoinLNN Result of the SoftbusConnector 265 * @tc.type: FUNC 266 */ 267 void OnSoftbusJoinLNNResult(const int32_t sessionId, const char *networkId, int32_t result); 268 269 /** 270 * @tc.name: DmAuthManager::OnGroupCreated 271 * @tc.desc: Created Group of the DeviceManager Authenticate Manager 272 * @tc.type: FUNC 273 */ 274 void OnGroupCreated(int64_t requestId, const std::string &groupId); 275 276 /** 277 * @tc.name: DmAuthManager::OnMemberJoin 278 * @tc.desc: Join Member of the DeviceManager Authenticate Manager 279 * @tc.type: FUNC 280 */ 281 void OnMemberJoin(int64_t requestId, int32_t status, int32_t operationCode); 282 283 /** 284 * @tc.name: DmAuthManager::EstablishAuthChannel 285 * @tc.desc: Establish Auth Channel of the DeviceManager Authenticate Manager, auth state machine 286 * @tc.type: FUNC 287 */ 288 int32_t EstablishAuthChannel(const std::string &deviceId); 289 290 /** 291 * @tc.name: DmAuthManager::StartNegotiate 292 * @tc.desc: Start Negotiate of the DeviceManager Authenticate Manager 293 * @tc.type: FUNC 294 */ 295 void StartNegotiate(const int32_t &sessionId); 296 297 /** 298 * @tc.name: DmAuthManager::RespNegotiate 299 * @tc.desc: Resp Negotiate of the DeviceManager Authenticate Manager 300 * @tc.type: FUNC 301 */ 302 void RespNegotiate(const int32_t &sessionId); 303 304 /** 305 * @tc.name: DmAuthManager::SendAuthRequest 306 * @tc.desc: Send Auth Request of the DeviceManager Authenticate Manager 307 * @tc.type: FUNC 308 */ 309 void SendAuthRequest(const int32_t &sessionId); 310 311 /** 312 * @tc.name: DmAuthManager::StartAuthProcess 313 * @tc.desc: Start Auth Process of the DeviceManager Authenticate Manager 314 * @tc.type: FUNC 315 */ 316 int32_t StartAuthProcess(const int32_t &action); 317 318 /** 319 * @tc.name: DmAuthManager::StartRespAuthProcess 320 * @tc.desc: Start Resp Auth Process of the DeviceManager Authenticate Manager 321 * @tc.type: FUNC 322 */ 323 void StartRespAuthProcess(); 324 325 /** 326 * @tc.name: DmAuthManager::CreateGroup 327 * @tc.desc: Create Group of the DeviceManager Authenticate Manager 328 * @tc.type: FUNC 329 */ 330 int32_t CreateGroup(); 331 332 /** 333 * @tc.name: DmAuthManager::ProcessPincode 334 * @tc.desc: Process pin code of the DeviceManager Authenticate Manager 335 * @tc.type: FUNC 336 */ 337 int32_t ProcessPincode(const std::string &pinCode); 338 339 /** 340 * @tc.name: DmAuthManager::GetConnectAddr 341 * @tc.desc: Get Connect Addr of the DeviceManager Authenticate Manager 342 * @tc.type: FUNC 343 */ 344 std::string GetConnectAddr(std::string deviceId); 345 346 /** 347 * @tc.name: DmAuthManager::JoinNetwork 348 * @tc.desc: Join Net work of the DeviceManager Authenticate Manager 349 * @tc.type: FUNC 350 */ 351 int32_t JoinNetwork(); 352 353 /** 354 * @tc.name: DmAuthManager::AuthenticateFinish 355 * @tc.desc: Finish Authenticate of the DeviceManager Authenticate Manager 356 * @tc.type: FUNC 357 */ 358 void AuthenticateFinish(); 359 360 /** 361 * @tc.name: DmAuthManager::GetIsCryptoSupport 362 * @tc.desc: Get Cryp to Support of the DeviceManager Authenticate Manager 363 * @tc.type: FUNC 364 */ 365 bool GetIsCryptoSupport(); 366 367 /** 368 * @tc.name: DmAuthManager::SetAuthRequestState 369 * @tc.desc: Set Auth Request State of the DeviceManager Authenticate Manager 370 * @tc.type: FUNC 371 */ 372 int32_t SetAuthRequestState(std::shared_ptr<AuthRequestState> authRequestState); 373 374 /** 375 * @tc.name: DmAuthManager::SetAuthResponseState 376 * @tc.desc: Set Auth Response State of the DeviceManager Authenticate Manager 377 * @tc.type: FUNC 378 */ 379 int32_t SetAuthResponseState(std::shared_ptr<AuthResponseState> authResponseState); 380 381 /** 382 * @tc.name: DmAuthManager::GetPinCode 383 * @tc.desc: Get Pin Code of the DeviceManager Authenticate Manager 384 * @tc.type: FUNC 385 */ 386 int32_t GetPinCode(std::string &code); 387 388 /** 389 * @tc.name: DmAuthManager::GenerateGroupName 390 * @tc.desc: Generate Group Name of the DeviceManager Authenticate Manager 391 * @tc.type: FUNC 392 */ 393 std::string GenerateGroupName(); 394 395 /** 396 * @tc.name: DmAuthManager::HandleAuthenticateTimeout 397 * @tc.desc: Handle Authenticate Timeout of the DeviceManager Authenticate Manager 398 * @tc.type: FUNC 399 */ 400 void HandleAuthenticateTimeout(std::string name); 401 402 /** 403 * @tc.name: DmAuthManager::GeneratePincode 404 * @tc.desc: Generate Pincode of the DeviceManager Authenticate Manager 405 * @tc.type: FUNC 406 */ 407 std::string GeneratePincode(); 408 409 /** 410 * @tc.name: DmAuthManager::ShowConfigDialog 411 * @tc.desc: Show Config Dialog of the DeviceManager Authenticate Manager 412 * @tc.type: FUNC 413 */ 414 void ShowConfigDialog(); 415 416 /** 417 * @tc.name: DmAuthManager::ShowAuthInfoDialog 418 * @tc.desc: Show AuthInfo Dialog of the DeviceManager Authenticate Manager 419 * @tc.type: FUNC 420 */ 421 void ShowAuthInfoDialog(bool authDeviceError = false); 422 423 /** 424 * @tc.name: DmAuthManager::ShowStartAuthDialog 425 * @tc.desc: Show Start Auth Dialog of the DeviceManager Authenticate Manager 426 * @tc.type: FUNC 427 */ 428 void ShowStartAuthDialog(); 429 430 /** 431 * @tc.name: DmAuthManager::OnUserOperation 432 * @tc.desc: User Operation of the DeviceManager Authenticate Manager 433 * @tc.type: FUNC 434 */ 435 int32_t OnUserOperation(int32_t action, const std::string ¶ms); 436 437 /** 438 * @tc.name: DmAuthManager::SetPageId 439 * @tc.desc: Set PageId of the DeviceManager Authenticate Manager 440 * @tc.type: FUNC 441 */ 442 int32_t SetPageId(int32_t pageId); 443 444 /** 445 * @tc.name: DmAuthManager::SetReasonAndFinish 446 * @tc.desc: Set Reason of the DeviceManager Authenticate Manager 447 * @tc.type: FUNC 448 */ 449 int32_t SetReasonAndFinish(int32_t reason, int32_t state); 450 451 /** 452 * @tc.name: DmAuthManager::IsIdenticalAccount 453 * @tc.desc: judge IdenticalAccount or not 454 * @tc.type: FUNC 455 */ 456 bool IsIdenticalAccount(); 457 458 /** 459 * @tc.name: DmAuthManager::RegisterUiStateCallback 460 * @tc.desc: Register ui state callback 461 * @tc.type: FUNC 462 */ 463 int32_t RegisterUiStateCallback(const std::string pkgName); 464 465 /** 466 * @tc.name: DmAuthManager::UnRegisterUiStateCallback 467 * @tc.desc: Unregister ui state callback 468 * @tc.type: FUNC 469 */ 470 int32_t UnRegisterUiStateCallback(const std::string pkgName); 471 472 /** 473 * @tc.name: DmAuthManager::ImportAuthCode 474 * @tc.desc: Import auth code 475 * @tc.type: FUNC 476 */ 477 int32_t ImportAuthCode(const std::string &pkgName, const std::string &authCode); 478 479 /** 480 * @tc.name: DmAuthManager::BindTarget 481 * @tc.desc: Bind Target 482 * @tc.type: FUNC 483 */ 484 int32_t BindTarget(const std::string &pkgName, const PeerTargetId &targetId, 485 const std::map<std::string, std::string> &bindParam, int sessionId, uint64_t logicalSessionId); 486 487 void ClearSoftbusSessionCallback(); 488 void PrepareSoftbusSessionCallback(); 489 490 void HandleSessionHeartbeat(std::string name); 491 492 int32_t RegisterAuthenticationType(int32_t authenticationType); 493 static bool IsPinCodeValid(const std::string strpin); 494 static bool IsPinCodeValid(int32_t numpin); 495 bool IsImportedAuthCodeValid(); 496 bool IsSrc(); 497 498 private: 499 bool IsHmlSessionType(); 500 bool CanUsePincodeFromDp(); 501 bool IsServiceInfoAuthTypeValid(int32_t authType); 502 bool IsServiceInfoAuthBoxTypeValid(int32_t authBoxType); 503 bool IsServiceInfoPinExchangeTypeValid(int32_t pinExchangeType); 504 bool IsLocalServiceInfoValid(const DistributedDeviceProfile::LocalServiceInfo &localServiceInfo); 505 void GetLocalServiceInfoInDp(); 506 bool CheckNeedShowAuthInfoDialog(int32_t errorCode); 507 void UpdateInputPincodeDialog(int32_t errorCode); 508 void JoinLnn(const std::string &deviceId, bool isForceJoin = false); 509 int32_t CheckAuthParamVaild(const std::string &pkgName, int32_t authType, const std::string &deviceId, 510 const std::string &extra); 511 int32_t CheckAuthParamVaildExtra(const std::string &extra, const std::string &deviceId); 512 bool CheckHmlParamValid(JsonObject &jsonObject); 513 void ProcessSourceMsg(); 514 void ProcessSinkMsg(); 515 std::string GetAccountGroupIdHash(); 516 void AbilityNegotiate(); 517 void HandleMemberJoinImportAuthCode(const int64_t requestId, const int32_t status); 518 int32_t DeleteAuthCode(); 519 int32_t GetAuthCode(const std::string &pkgName, std::string &pinCode); 520 bool IsAuthTypeSupported(const int32_t &authType); 521 bool IsAuthCodeReady(const std::string &pkgName); 522 int32_t ParseConnectAddr(const PeerTargetId &targetId, std::string &deviceId, std::string &addrType); 523 std::string ParseExtraFromMap(const std::map<std::string, std::string> &bindParam); 524 std::string GenerateBindResultContent(); 525 void InitAuthState(const std::string &pkgName, int32_t authType, const std::string &deviceId, 526 const std::string &extra); 527 void CompatiblePutAcl(); 528 void ProcRespNegotiateExt(const int32_t &sessionId); 529 void ProcRespNegotiate(const int32_t &sessionId); 530 void GetAuthRequestContext(); 531 void SinkAuthDeviceFinish(); 532 void SrcAuthDeviceFinish(); 533 int32_t CheckTrustState(); 534 void ProcIncompatible(const int32_t &sessionId); 535 void MemberJoinAuthRequest(int64_t requestId, int32_t status); 536 void PutSrcAccessControlList(DmAccesser &accesser, DmAccessee &accessee, const std::string &localUdid); 537 void PutSinkAccessControlList(DmAccesser &accesser, DmAccessee &accessee, const std::string &localUdid); 538 539 public: 540 void RequestCredential(); 541 void GenerateCredential(std::string &publicKey); 542 void RequestCredentialDone(); 543 void ResponseCredential(); 544 bool AuthDeviceTransmit(int64_t requestId, const uint8_t *data, uint32_t dataLen); 545 void AuthDeviceFinish(int64_t requestId); 546 void AuthDeviceError(int64_t requestId, int32_t errorCode); 547 int32_t GetOutputState(int32_t state); 548 void GetRemoteDeviceId(std::string &deviceId); 549 void AuthDeviceSessionKey(int64_t requestId, const uint8_t *sessionKey, uint32_t sessionKeyLen); 550 char *AuthDeviceRequest(int64_t requestId, int operationCode, const char *reqParams); 551 int32_t GetSessionKeyIdSync(int64_t requestId); 552 void OnAuthDeviceDataReceived(const int32_t sessionId, const std::string message); 553 void OnScreenLocked(); 554 void HandleDeviceNotTrust(const std::string &udid); 555 int32_t DeleteGroup(const std::string &pkgName, const std::string &deviceId); 556 int32_t DeleteGroup(const std::string &pkgName, int32_t userId, const std::string &deviceId); 557 int32_t StopAuthenticateDevice(const std::string &pkgName); 558 void RequestReCheckMsg(); 559 void ResponseReCheckMsg(); 560 void RequestReCheckMsgDone(); 561 void CloseAuthSession(const int32_t sessionId); 562 private: 563 int32_t ImportCredential(std::string &deviceId, std::string &publicKey); 564 void GetAuthParam(const std::string &pkgName, int32_t authType, const std::string &deviceId, 565 const std::string &extra); 566 void ParseJsonObject(JsonObject &jsonObject); 567 void ParseHmlInfoInJsonObject(JsonObject &jsonObject); 568 void PutSessionKeyAsync(int64_t requestId, std::vector<unsigned char> hash); 569 int32_t DeleteAcl(const std::string &pkgName, const std::string &localUdid, const std::string &remoteUdid, 570 int32_t bindLevel, const std::string &extra); 571 void ProcessAuthRequestExt(const int32_t &sessionId); 572 bool IsAuthFinish(); 573 void ProcessAuthRequest(const int32_t &sessionId); 574 int32_t ConfirmProcess(const int32_t &action); 575 int32_t ConfirmProcessExt(const int32_t &action); 576 int32_t AddMember(const std::string &pinCode); 577 int32_t AuthDevice(const std::string &pinCode); 578 void PutAccessControlList(); 579 void SinkAuthenticateFinish(); 580 void SrcAuthenticateFinish(); 581 bool IsScreenLocked(); 582 void CheckAndEndTvDream(); 583 std::string ConvertSinkVersion(const std::string &version); 584 void NegotiateRespMsg(const std::string &version); 585 void SetAuthType(int32_t authType); 586 int32_t GetTaskTimeout(const char* taskName, int32_t taskTimeOut); 587 void GetPeerUdidHash(int32_t sessionId, std::string &peerUdidHash); 588 void DeleteOffLineTimer(int32_t sessionId); 589 int32_t GetBinderInfo(); 590 void SetProcessInfo(); 591 int32_t GetCloseSessionDelaySeconds(std::string &delaySecondsStr); 592 void ConverToFinish(); 593 bool IsSinkMsgValid(); 594 bool IsSourceMsgValid(); 595 void ProcessReqPublicKey(); 596 void RegisterCleanNotifyCallback(CleanNotifyCallback cleanNotifyCallback); 597 void GetBindCallerInfo(); 598 void ProcessReqAuthTerminate(); 599 void ResetParams(); 600 601 private: 602 std::shared_ptr<SoftbusConnector> softbusConnector_; 603 std::shared_ptr<HiChainConnector> hiChainConnector_; 604 std::shared_ptr<AuthUiStateManager> authUiStateMgr_; 605 std::shared_ptr<IDeviceManagerServiceListener> listener_; 606 std::shared_ptr<DmAdapterManager> adapterMgr_; 607 std::map<int32_t, std::shared_ptr<IAuthentication>> authenticationMap_; 608 std::shared_ptr<AuthRequestState> authRequestState_ = nullptr; 609 std::shared_ptr<AuthRequestState> authRequestStateTemp_ = nullptr; 610 std::shared_ptr<AuthResponseState> authResponseState_ = nullptr; 611 std::shared_ptr<DmAuthRequestContext> authRequestContext_; 612 std::shared_ptr<DmAuthResponseContext> authResponseContext_; 613 std::shared_ptr<AuthMessageProcessor> authMessageProcessor_; 614 std::shared_ptr<DmTimer> timer_; 615 std::shared_ptr<DmAbilityManager> dmAbilityMgr_; 616 std::shared_ptr<HiChainAuthConnector> hiChainAuthConnector_; 617 bool isCryptoSupport_ = false; 618 bool isFinishOfLocal_ = true; 619 int32_t authTimes_ = 0; 620 int32_t action_ = USER_OPERATION_TYPE_CANCEL_AUTH; 621 std::shared_ptr<IAuthentication> authPtr_; 622 bool isAddingMember_ = false; 623 std::string importPkgName_ = ""; 624 std::string importAuthCode_ = ""; 625 PeerTargetId peerTargetId_; 626 std::string remoteDeviceId_ = ""; 627 std::string dmVersion_ = ""; 628 bool isAuthDevice_ = false; 629 bool isAuthenticateDevice_ = false; 630 bool isNeedJoinLnn_ = true; 631 int32_t authForm_ = DmAuthForm::ACROSS_ACCOUNT; 632 std::string remoteVersion_ = ""; 633 std::atomic<int32_t> authType_ = AUTH_TYPE_UNKNOW; 634 std::string remoteUdidHash_ = ""; 635 ProcessInfo processInfo_; 636 std::mutex srcReqMsgLock_; 637 bool isNeedProcCachedSrcReqMsg_ = false; 638 std::string srcReqMsg_ = ""; 639 int32_t authenticationType_ = USER_OPERATION_TYPE_ALLOW_AUTH; 640 DistributedDeviceProfile::LocalServiceInfo serviceInfoProfile_; 641 bool pincodeDialogEverShown_ = false; 642 std::string bundleName_ = ""; 643 std::mutex sessionKeyIdMutex_; 644 std::condition_variable sessionKeyIdCondition_; 645 std::map<int64_t, std::optional<int32_t>> sessionKeyIdAsyncResult_; 646 bool isWaitingJoinLnnCallback_ = false; 647 CleanNotifyCallback cleanNotifyCallback_{nullptr}; 648 std::mutex bindParamMutex_; 649 std::map<std::string, std::string> bindParam_; 650 std::mutex groupMutex_; 651 bool isAddMember_ = false; 652 bool isCreateGroup_ = false; 653 bool transitToFinishState_ = false; 654 }; 655 } // namespace DistributedHardware 656 } // namespace OHOS 657 #endif // OHOS_DM_AUTH_MANAGER_H 658