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 19 #include <map> 20 #include <mutex> 21 #include <string> 22 23 #include "auth_request_state.h" 24 #include "auth_response_state.h" 25 #include "auth_ui_state_manager.h" 26 #include "authentication.h" 27 #include "idevice_manager_service_listener.h" 28 #include "deviceprofile_connector.h" 29 #include "dm_ability_manager.h" 30 #include "dm_adapter_manager.h" 31 #include "dm_constants.h" 32 #include "dm_device_info.h" 33 #include "dm_timer.h" 34 #include "hichain_auth_connector.h" 35 #include "hichain_connector.h" 36 #include "service_info_unique_key.h" 37 #include "softbus_connector.h" 38 #include "softbus_session.h" 39 40 namespace OHOS { 41 namespace DistributedHardware { 42 typedef enum AuthState { 43 AUTH_REQUEST_INIT = 1, 44 AUTH_REQUEST_NEGOTIATE, 45 AUTH_REQUEST_NEGOTIATE_DONE, 46 AUTH_REQUEST_REPLY, 47 AUTH_REQUEST_JOIN, 48 AUTH_REQUEST_NETWORK, 49 AUTH_REQUEST_FINISH, 50 AUTH_REQUEST_CREDENTIAL, 51 AUTH_REQUEST_CREDENTIAL_DONE, 52 AUTH_REQUEST_AUTH_FINISH, 53 AUTH_REQUEST_RECHECK_MSG, 54 AUTH_REQUEST_RECHECK_MSG_DONE, 55 56 AUTH_RESPONSE_INIT = 20, 57 AUTH_RESPONSE_NEGOTIATE, 58 AUTH_RESPONSE_CONFIRM, 59 AUTH_RESPONSE_GROUP, 60 AUTH_RESPONSE_SHOW, 61 AUTH_RESPONSE_FINISH, 62 AUTH_RESPONSE_CREDENTIAL, 63 AUTH_RESPONSE_AUTH_FINISH, 64 AUTH_RESPONSE_RECHECK_MSG, 65 } AuthState; 66 67 enum DmMsgType : int32_t { 68 MSG_TYPE_UNKNOWN = 0, 69 MSG_TYPE_NEGOTIATE = 80, 70 MSG_TYPE_RESP_NEGOTIATE = 90, 71 MSG_TYPE_REQ_AUTH = 100, 72 MSG_TYPE_INVITE_AUTH_INFO = 102, 73 MSG_TYPE_REQ_AUTH_TERMINATE = 104, 74 MSG_TYPE_RESP_AUTH = 200, 75 MSG_TYPE_JOIN_AUTH_INFO = 201, 76 MSG_TYPE_RESP_AUTH_TERMINATE = 205, 77 MSG_TYPE_CHANNEL_CLOSED = 300, 78 MSG_TYPE_SYNC_GROUP = 400, 79 MSG_TYPE_AUTH_BY_PIN = 500, 80 81 MSG_TYPE_RESP_AUTH_EXT, 82 MSG_TYPE_REQ_PUBLICKEY, 83 MSG_TYPE_RESP_PUBLICKEY, 84 MSG_TYPE_REQ_RECHECK_MSG, 85 MSG_TYPE_RESP_RECHECK_MSG, 86 MSG_TYPE_REQ_AUTH_DEVICE_NEGOTIATE = 600, 87 MSG_TYPE_RESP_AUTH_DEVICE_NEGOTIATE = 700, 88 }; 89 90 enum DmAuthType : int32_t { 91 AUTH_TYPE_CRE = 0, 92 AUTH_TYPE_PIN, 93 AUTH_TYPE_QR_CODE, 94 AUTH_TYPE_NFC, 95 AUTH_TYPE_NO_INTER_ACTION, 96 AUTH_TYPE_IMPORT_AUTH_CODE, 97 AUTH_TYPE_UNKNOW, 98 }; 99 100 typedef struct DmAuthRequestContext { 101 int32_t authType; 102 std::string localDeviceId; 103 std::string localDeviceName; 104 int32_t localDeviceTypeId; 105 std::string deviceId; 106 std::string deviceName; 107 std::string deviceTypeId; 108 int32_t sessionId; 109 int32_t groupVisibility; 110 bool cryptoSupport; 111 std::string cryptoName; 112 std::string cryptoVer; 113 std::string hostPkgName; 114 std::string targetPkgName; 115 std::string bundleName; 116 std::string peerBundleName; 117 std::string appOperation; 118 std::string appDesc; 119 std::string appName; 120 std::string customDesc; 121 std::string appThumbnail; 122 std::string token; 123 int32_t reason; 124 std::vector<std::string> syncGroupList; 125 std::string dmVersion; 126 int32_t localUserId; 127 std::string localAccountId; 128 std::vector<int32_t> bindType; 129 bool isOnline; 130 bool authed; 131 int32_t bindLevel; 132 int64_t tokenId; 133 std::string remoteAccountId; 134 int32_t remoteUserId; 135 std::string addr; 136 std::string hostPkgLabel; 137 int32_t closeSessionDelaySeconds = 0; 138 std::string remoteDeviceName; 139 std::string connSessionType; 140 int32_t hmlActionId = 0; 141 bool hmlEnable160M = false; 142 } DmAuthRequestContext; 143 144 typedef struct DmAuthResponseContext { 145 int32_t authType; 146 std::string deviceId; 147 std::string localDeviceId; 148 std::string deviceName; 149 int32_t deviceTypeId; 150 int32_t msgType; 151 int32_t sessionId; 152 bool cryptoSupport; 153 bool isIdenticalAccount; 154 bool isAuthCodeReady; 155 bool isShowDialog; 156 std::string cryptoName; 157 std::string cryptoVer; 158 int32_t reply; 159 std::string networkId; 160 std::string groupId; 161 std::string groupName; 162 std::string hostPkgName; 163 std::string targetPkgName; 164 std::string bundleName; 165 std::string peerBundleName; 166 std::string appOperation; 167 std::string appDesc; 168 std::string customDesc; 169 std::string appIcon; 170 std::string appThumbnail; 171 std::string token; 172 std::string authToken; 173 int32_t pageId; 174 int64_t requestId; 175 int32_t code = INVALID_PINCODE; 176 int32_t state; 177 std::vector<std::string> syncGroupList; 178 std::string accountGroupIdHash; 179 std::string publicKey; 180 bool isOnline; 181 int32_t bindLevel; 182 bool haveCredential; 183 int32_t confirmOperation; 184 std::string localAccountId; 185 int32_t localUserId; 186 int64_t tokenId; 187 int64_t remoteTokenId; 188 bool authed; 189 std::string dmVersion; 190 std::vector<int32_t> bindType; 191 std::string remoteAccountId; 192 int32_t remoteUserId; 193 std::string targetDeviceName; 194 std::string importAuthCode; 195 std::string hostPkgLabel; 196 bool isFinish = false; 197 std::string edition; 198 int32_t localBindLevel; 199 std::string remoteDeviceName; 200 int32_t localSessionKeyId = 0; 201 int32_t remoteSessionKeyId = 0; 202 } DmAuthResponseContext; 203 204 class AuthMessageProcessor; 205 206 class DmAuthManager final : public ISoftbusSessionCallback, 207 public ISoftbusConnectorCallback, 208 public IHiChainConnectorCallback, 209 public IDmDeviceAuthCallback, 210 public std::enable_shared_from_this<DmAuthManager> { 211 public: 212 DmAuthManager(std::shared_ptr<SoftbusConnector> softbusConnector, 213 std::shared_ptr<HiChainConnector> hiChainConnector, 214 std::shared_ptr<IDeviceManagerServiceListener> listener, 215 std::shared_ptr<HiChainAuthConnector> hiChainAuthConnector); 216 ~DmAuthManager(); 217 218 /** 219 * @tc.name: DmAuthManager::AuthenticateDevice 220 * @tc.desc: Authenticate Device of the DeviceManager Authenticate Manager 221 * @tc.type: FUNC 222 */ 223 int32_t AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId, 224 const std::string &extra); 225 226 /** 227 * @tc.name: DmAuthManager::UnAuthenticateDevice 228 * @tc.desc: UnAuthenticate Device of the DeviceManager Authenticate Manager 229 * @tc.type: FUNC 230 */ 231 int32_t UnAuthenticateDevice(const std::string &pkgName, const std::string &udid, int32_t bindLevel); 232 233 /** 234 * @brief UnBind device. 235 * @param pkgName package name. 236 * @param deviceId device id. 237 * @return Return 0 if success. 238 */ 239 int32_t UnBindDevice(const std::string &pkgName, const std::string &udid, 240 int32_t bindLevel, const std::string &extra); 241 242 /** 243 * @tc.name: DmAuthManager::OnSessionOpened 244 * @tc.desc: Opened Session of the DeviceManager Authenticate Manager 245 * @tc.type: FUNC 246 */ 247 void OnSessionOpened(int32_t sessionId, int32_t sessionSide, int32_t result); 248 249 /** 250 * @tc.name: DmAuthManager::OnSessionClosed 251 * @tc.desc: Closed Session of the DeviceManager Authenticate Manager 252 * @tc.type: FUNC 253 */ 254 void OnSessionClosed(const int32_t sessionId); 255 256 /** 257 * @tc.name: DmAuthManager::OnDataReceived 258 * @tc.desc: Received Data of the DeviceManager Authenticate Manager 259 * @tc.type: FUNC 260 */ 261 void OnDataReceived(const int32_t sessionId, const std::string message); 262 263 /** 264 * @tc.name: DmAuthManager::OnSoftbusJoinLNNResult 265 * @tc.desc: OnSoftbus JoinLNN Result of the SoftbusConnector 266 * @tc.type: FUNC 267 */ 268 void OnSoftbusJoinLNNResult(const int32_t sessionId, const char *networkId, int32_t result); 269 270 /** 271 * @tc.name: DmAuthManager::OnGroupCreated 272 * @tc.desc: Created Group of the DeviceManager Authenticate Manager 273 * @tc.type: FUNC 274 */ 275 void OnGroupCreated(int64_t requestId, const std::string &groupId); 276 277 /** 278 * @tc.name: DmAuthManager::OnMemberJoin 279 * @tc.desc: Join Member of the DeviceManager Authenticate Manager 280 * @tc.type: FUNC 281 */ 282 void OnMemberJoin(int64_t requestId, int32_t status); 283 284 /** 285 * @tc.name: DmAuthManager::EstablishAuthChannel 286 * @tc.desc: Establish Auth Channel of the DeviceManager Authenticate Manager, auth state machine 287 * @tc.type: FUNC 288 */ 289 int32_t EstablishAuthChannel(const std::string &deviceId); 290 291 /** 292 * @tc.name: DmAuthManager::StartNegotiate 293 * @tc.desc: Start Negotiate of the DeviceManager Authenticate Manager 294 * @tc.type: FUNC 295 */ 296 void StartNegotiate(const int32_t &sessionId); 297 298 /** 299 * @tc.name: DmAuthManager::RespNegotiate 300 * @tc.desc: Resp Negotiate of the DeviceManager Authenticate Manager 301 * @tc.type: FUNC 302 */ 303 void RespNegotiate(const int32_t &sessionId); 304 305 /** 306 * @tc.name: DmAuthManager::SendAuthRequest 307 * @tc.desc: Send Auth Request of the DeviceManager Authenticate Manager 308 * @tc.type: FUNC 309 */ 310 void SendAuthRequest(const int32_t &sessionId); 311 312 /** 313 * @tc.name: DmAuthManager::StartAuthProcess 314 * @tc.desc: Start Auth Process of the DeviceManager Authenticate Manager 315 * @tc.type: FUNC 316 */ 317 int32_t StartAuthProcess(const int32_t &action); 318 319 /** 320 * @tc.name: DmAuthManager::StartRespAuthProcess 321 * @tc.desc: Start Resp Auth Process of the DeviceManager Authenticate Manager 322 * @tc.type: FUNC 323 */ 324 void StartRespAuthProcess(); 325 326 /** 327 * @tc.name: DmAuthManager::CreateGroup 328 * @tc.desc: Create Group of the DeviceManager Authenticate Manager 329 * @tc.type: FUNC 330 */ 331 int32_t CreateGroup(); 332 333 /** 334 * @tc.name: DmAuthManager::ProcessPincode 335 * @tc.desc: Process pin code of the DeviceManager Authenticate Manager 336 * @tc.type: FUNC 337 */ 338 int32_t ProcessPincode(int32_t pinCode); 339 340 /** 341 * @tc.name: DmAuthManager::GetConnectAddr 342 * @tc.desc: Get Connect Addr of the DeviceManager Authenticate Manager 343 * @tc.type: FUNC 344 */ 345 std::string GetConnectAddr(std::string deviceId); 346 347 /** 348 * @tc.name: DmAuthManager::JoinNetwork 349 * @tc.desc: Join Net work of the DeviceManager Authenticate Manager 350 * @tc.type: FUNC 351 */ 352 int32_t JoinNetwork(); 353 354 /** 355 * @tc.name: DmAuthManager::AuthenticateFinish 356 * @tc.desc: Finish Authenticate of the DeviceManager Authenticate Manager 357 * @tc.type: FUNC 358 */ 359 void AuthenticateFinish(); 360 361 /** 362 * @tc.name: DmAuthManager::GetIsCryptoSupport 363 * @tc.desc: Get Cryp to Support of the DeviceManager Authenticate Manager 364 * @tc.type: FUNC 365 */ 366 bool GetIsCryptoSupport(); 367 368 /** 369 * @tc.name: DmAuthManager::SetAuthRequestState 370 * @tc.desc: Set Auth Request State of the DeviceManager Authenticate Manager 371 * @tc.type: FUNC 372 */ 373 int32_t SetAuthRequestState(std::shared_ptr<AuthRequestState> authRequestState); 374 375 /** 376 * @tc.name: DmAuthManager::SetAuthResponseState 377 * @tc.desc: Set Auth Response State of the DeviceManager Authenticate Manager 378 * @tc.type: FUNC 379 */ 380 int32_t SetAuthResponseState(std::shared_ptr<AuthResponseState> authResponseState); 381 382 /** 383 * @tc.name: DmAuthManager::GetPinCode 384 * @tc.desc: Get Pin Code of the DeviceManager Authenticate Manager 385 * @tc.type: FUNC 386 */ 387 int32_t GetPinCode(int32_t &code); 388 389 /** 390 * @tc.name: DmAuthManager::GenerateGroupName 391 * @tc.desc: Generate Group Name of the DeviceManager Authenticate Manager 392 * @tc.type: FUNC 393 */ 394 std::string GenerateGroupName(); 395 396 /** 397 * @tc.name: DmAuthManager::HandleAuthenticateTimeout 398 * @tc.desc: Handle Authenticate Timeout of the DeviceManager Authenticate Manager 399 * @tc.type: FUNC 400 */ 401 void HandleAuthenticateTimeout(std::string name); 402 403 /** 404 * @tc.name: DmAuthManager::GeneratePincode 405 * @tc.desc: Generate Pincode of the DeviceManager Authenticate Manager 406 * @tc.type: FUNC 407 */ 408 int32_t GeneratePincode(); 409 410 /** 411 * @tc.name: DmAuthManager::ShowConfigDialog 412 * @tc.desc: Show Config Dialog of the DeviceManager Authenticate Manager 413 * @tc.type: FUNC 414 */ 415 void ShowConfigDialog(); 416 417 /** 418 * @tc.name: DmAuthManager::ShowAuthInfoDialog 419 * @tc.desc: Show AuthInfo Dialog of the DeviceManager Authenticate Manager 420 * @tc.type: FUNC 421 */ 422 void ShowAuthInfoDialog(bool authDeviceError = false); 423 424 /** 425 * @tc.name: DmAuthManager::ShowStartAuthDialog 426 * @tc.desc: Show Start Auth Dialog of the DeviceManager Authenticate Manager 427 * @tc.type: FUNC 428 */ 429 void ShowStartAuthDialog(); 430 431 /** 432 * @tc.name: DmAuthManager::OnUserOperation 433 * @tc.desc: User Operation of the DeviceManager Authenticate Manager 434 * @tc.type: FUNC 435 */ 436 int32_t OnUserOperation(int32_t action, const std::string ¶ms); 437 438 /** 439 * @tc.name: DmAuthManager::SetPageId 440 * @tc.desc: Set PageId of the DeviceManager Authenticate Manager 441 * @tc.type: FUNC 442 */ 443 int32_t SetPageId(int32_t pageId); 444 445 /** 446 * @tc.name: DmAuthManager::SetReasonAndFinish 447 * @tc.desc: Set Reason of the DeviceManager Authenticate Manager 448 * @tc.type: FUNC 449 */ 450 int32_t SetReasonAndFinish(int32_t reason, int32_t state); 451 452 /** 453 * @tc.name: DmAuthManager::IsIdenticalAccount 454 * @tc.desc: judge IdenticalAccount or not 455 * @tc.type: FUNC 456 */ 457 bool IsIdenticalAccount(); 458 459 /** 460 * @tc.name: DmAuthManager::RegisterUiStateCallback 461 * @tc.desc: Register ui state callback 462 * @tc.type: FUNC 463 */ 464 int32_t RegisterUiStateCallback(const std::string pkgName); 465 466 /** 467 * @tc.name: DmAuthManager::UnRegisterUiStateCallback 468 * @tc.desc: Unregister ui state callback 469 * @tc.type: FUNC 470 */ 471 int32_t UnRegisterUiStateCallback(const std::string pkgName); 472 473 /** 474 * @tc.name: DmAuthManager::ImportAuthCode 475 * @tc.desc: Import auth code 476 * @tc.type: FUNC 477 */ 478 int32_t ImportAuthCode(const std::string &pkgName, const std::string &authCode); 479 480 /** 481 * @tc.name: DmAuthManager::BindTarget 482 * @tc.desc: Bind Target 483 * @tc.type: FUNC 484 */ 485 int32_t BindTarget(const std::string &pkgName, const PeerTargetId &targetId, 486 const std::map<std::string, std::string> &bindParam); 487 488 void HandleSessionHeartbeat(std::string name); 489 490 int32_t RegisterAuthenticationType(int32_t authenticationType); 491 static bool IsPinCodeValid(const std::string strpin); 492 static bool IsPinCodeValid(int32_t numpin); 493 bool IsImportedAuthCodeValid(); 494 bool IsSrc(); 495 496 private: 497 bool IsHmlSessionType(); 498 bool CanUsePincodeFromDp(); 499 bool IsServiceInfoAuthTypeValid(int32_t authType); 500 bool IsServiceInfoAuthBoxTypeValid(int32_t authBoxType); 501 bool IsServiceInfoPinExchangeTypeValid(int32_t pinExchangeType); 502 bool IsLocalServiceInfoValid(const DistributedDeviceProfile::LocalServiceInfo &localServiceInfo); 503 void GetLocalServiceInfoInDp(); 504 bool CheckNeedShowAuthInfoDialog(int32_t errorCode); 505 void UpdateInputPincodeDialog(int32_t errorCode); 506 void JoinLnn(const std::string &deviceId, bool isForceJoin = false); 507 int32_t CheckAuthParamVaild(const std::string &pkgName, int32_t authType, const std::string &deviceId, 508 const std::string &extra); 509 int32_t CheckAuthParamVaildExtra(const std::string &extra, const std::string &deviceId); 510 bool CheckHmlParamValid(JsonObject &jsonObject); 511 bool CheckProcessNameInWhiteList(const std::string &processName); 512 void ProcessSourceMsg(); 513 void ProcessSinkMsg(); 514 std::string GetAccountGroupIdHash(); 515 void AbilityNegotiate(); 516 void HandleMemberJoinImportAuthCode(const int64_t requestId, const int32_t status); 517 int32_t DeleteAuthCode(); 518 int32_t GetAuthCode(const std::string &pkgName, int32_t &pinCode); 519 bool IsAuthTypeSupported(const int32_t &authType); 520 bool IsAuthCodeReady(const std::string &pkgName); 521 int32_t ParseConnectAddr(const PeerTargetId &targetId, std::string &deviceId, std::string &addrType); 522 int32_t ParseAuthType(const std::map<std::string, std::string> &bindParam, int32_t &authType); 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 void GetRemoteDeviceId(std::string &deviceId); 548 void AuthDeviceSessionKey(int64_t requestId, const uint8_t *sessionKey, uint32_t sessionKeyLen); 549 int32_t GetSessionKeyIdSync(int64_t requestId); 550 void OnAuthDeviceDataReceived(const int32_t sessionId, const std::string message); 551 void OnScreenLocked(); 552 void HandleDeviceNotTrust(const std::string &udid); 553 int32_t DeleteGroup(const std::string &pkgName, const std::string &deviceId); 554 int32_t DeleteGroup(const std::string &pkgName, int32_t userId, const std::string &deviceId); 555 int32_t StopAuthenticateDevice(const std::string &pkgName); 556 void RequestReCheckMsg(); 557 void ResponseReCheckMsg(); 558 void RequestReCheckMsgDone(); 559 void CloseAuthSession(const int32_t sessionId); 560 private: 561 int32_t ImportCredential(std::string &deviceId, std::string &publicKey); 562 void GetAuthParam(const std::string &pkgName, int32_t authType, const std::string &deviceId, 563 const std::string &extra); 564 void ParseJsonObject(JsonObject &jsonObject); 565 void ParseHmlInfoInJsonObject(JsonObject &jsonObject); 566 void PutSessionKeyAsync(int64_t requestId, std::vector<unsigned char> hash); 567 int32_t DeleteAcl(const std::string &pkgName, const std::string &localUdid, const std::string &remoteUdid, 568 int32_t bindLevel, const std::string &extra); 569 void ProcessAuthRequestExt(const int32_t &sessionId); 570 bool IsAuthFinish(); 571 void ProcessAuthRequest(const int32_t &sessionId); 572 int32_t ConfirmProcess(const int32_t &action); 573 int32_t ConfirmProcessExt(const int32_t &action); 574 int32_t AddMember(int32_t pinCode); 575 int32_t AuthDevice(int32_t pinCode); 576 void PutAccessControlList(); 577 void SinkAuthenticateFinish(); 578 void SrcAuthenticateFinish(); 579 std::string GetBundleLable(const std::string &bundleName); 580 bool IsScreenLocked(); 581 std::string ConvertSrcVersion(const std::string &version, const std::string &edition); 582 std::string ConvertSinkVersion(const std::string &version); 583 void NegotiateRespMsg(const std::string &version); 584 void SetAuthType(int32_t authType); 585 int32_t GetTaskTimeout(const char* taskName, int32_t taskTimeOut); 586 void GetPeerUdidHash(int32_t sessionId, std::string &peerUdidHash); 587 void DeleteOffLineTimer(int32_t sessionId); 588 bool IsAllowDeviceBind(); 589 int32_t GetBindLevel(int32_t bindLevel); 590 std::string GetBundleName(JsonObject &jsonObject); 591 int32_t GetBinderInfo(); 592 void SetProcessInfo(); 593 int32_t GetCloseSessionDelaySeconds(std::string &delaySecondsStr); 594 void ConverToFinish(); 595 bool IsSinkMsgValid(); 596 bool IsSourceMsgValid(); 597 void ProcessReqPublicKey(); 598 int32_t GetTokenIdByBundleName(int32_t userId, std::string &bundleName, int64_t &tokenId); 599 bool CheckBindLevel(const JsonItemObject &jsonObj, const std::string &key, int32_t &bindLevel); 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 int32_t authForm_ = DmAuthForm::ACROSS_ACCOUNT; 631 std::string remoteVersion_ = ""; 632 std::atomic<int32_t> authType_ = AUTH_TYPE_UNKNOW; 633 std::string remoteUdidHash_ = ""; 634 ProcessInfo processInfo_; 635 std::mutex srcReqMsgLock_; 636 bool isNeedProcCachedSrcReqMsg_ = false; 637 std::string srcReqMsg_ = ""; 638 int32_t authenticationType_ = USER_OPERATION_TYPE_ALLOW_AUTH; 639 DistributedDeviceProfile::LocalServiceInfo serviceInfoProfile_; 640 bool pincodeDialogEverShown_ = false; 641 std::string bundleName_ = ""; 642 std::mutex sessionKeyIdMutex_; 643 std::condition_variable sessionKeyIdCondition_; 644 std::map<int64_t, std::optional<int32_t>> sessionKeyIdAsyncResult_; 645 bool isWaitingJoinLnnCallback_ = false; 646 }; 647 } // namespace DistributedHardware 648 } // namespace OHOS 649 #endif // OHOS_DM_AUTH_MANAGER_H 650