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 OS_ACCOUNT_INTERFACES_INNERKITS_ACCOUNT_IAM_NATIVE_INCLUDE_ACCOUNT_IAM_INFO_H 17 #define OS_ACCOUNT_INTERFACES_INNERKITS_ACCOUNT_IAM_NATIVE_INCLUDE_ACCOUNT_IAM_INFO_H 18 19 #include "attributes.h" 20 #include "iam_common_defines.h" 21 #ifdef HAS_PIN_AUTH_PART 22 #include "i_inputer.h" 23 #endif 24 #include "user_auth_client_callback.h" 25 #include "user_auth_client_defines.h" 26 #include "user_idm_client.h" 27 #include "user_idm_client_callback.h" 28 #include "user_idm_client_defines.h" 29 30 namespace OHOS { 31 namespace AccountSA { 32 #ifdef HAS_PIN_AUTH_PART 33 typedef UserIam::PinAuth::IInputer IInputer; 34 typedef UserIam::PinAuth::IInputerData IInputerData; 35 #endif 36 37 typedef UserIam::UserAuth::ResultCode ResultCode; 38 typedef UserIam::UserAuth::AuthType AuthType; 39 typedef UserIam::UserAuth::Attributes Attributes; 40 typedef UserIam::UserAuth::SecUserInfo SecUserInfo; 41 typedef UserIam::UserAuth::AuthTrustLevel AuthTrustLevel; 42 typedef UserIam::UserAuth::AuthenticationCallback AuthenticationCallback; 43 typedef UserIam::UserAuth::GetPropCallback GetPropCallback; 44 typedef UserIam::UserAuth::SetPropCallback SetPropCallback; 45 typedef UserIam::UserAuth::GetPropertyRequest GetPropertyRequest; 46 typedef UserIam::UserAuth::SetPropertyRequest SetPropertyRequest; 47 typedef UserIam::UserAuth::PropertyMode PropertyMode; 48 typedef UserIam::UserAuth::PinSubType PinSubType; 49 typedef UserIam::UserAuth::UserIdmClientCallback UserIdmClientCallback; 50 typedef UserIam::UserAuth::CredentialParameters CredentialParameters; 51 typedef UserIam::UserAuth::CredentialInfo CredentialInfo; 52 typedef UserIam::UserAuth::GetSecUserInfoCallback GetSecUserInfoCallback; 53 typedef UserIam::UserAuth::GetCredentialInfoCallback GetCredentialInfoCallback; 54 typedef UserIam::UserAuth::PrepareRemoteAuthCallback PrepareRemoteAuthCallback; 55 typedef UserIam::UserAuth::GetSecUserInfoCallback GetSecUserInfoCallback; 56 57 enum IAMAuthType { 58 DOMAIN = 1024, 59 TYPE_END, 60 }; 61 62 enum IAMAuthSubType { 63 DOMAIN_MIXED = 10240001 64 }; 65 66 enum IAMState { 67 IDLE = 0, 68 AFTER_OPEN_SESSION, 69 DURING_AUTHENTICATE, 70 DURING_ADD_CRED, 71 DURING_UPDATE_CRED, 72 DURING_DEL_CRED, 73 AFTER_ADD_CRED, 74 AFTER_UPDATE_CRED, 75 AFTER_DEL_CRED, 76 ROLL_BACK_DEL_CRED, 77 DURING_DEL_USER, 78 }; 79 80 struct CredentialItem { 81 int32_t type = 0; 82 std::vector<uint8_t> oldCredential; 83 std::vector<uint8_t> credential; 84 }; 85 86 enum AuthIntent : int32_t { 87 DEFAULT = 0, 88 UNLOCK = 1, 89 INIT = 2, 90 }; 91 92 struct RemoteAuthParam { 93 std::optional<std::string> verifierNetworkId; 94 std::optional<std::string> collectorNetworkId; 95 std::optional<uint32_t> collectorTokenId; 96 }; 97 98 struct AuthParam { 99 int32_t userId = 0; 100 std::vector<uint8_t> challenge; 101 AuthType authType; 102 AuthTrustLevel authTrustLevel; 103 AuthIntent authIntent = AuthIntent::DEFAULT; 104 std::optional<RemoteAuthParam> remoteAuthParam; 105 }; 106 107 struct RemoteAuthOptions { 108 std::string verifierNetworkId; 109 std::string collectorNetworkId; 110 uint32_t collectorTokenId; 111 bool hasVerifierNetworkId = false; 112 bool hasCollectorNetworkId = false; 113 bool hasCollectorTokenId = false; 114 }; 115 116 struct AuthOptions { 117 int32_t accountId = 0; 118 AuthIntent authIntent = AuthIntent::DEFAULT; 119 RemoteAuthOptions remoteAuthOptions; 120 bool hasRemoteAuthOptions = false; 121 bool hasAccountId = false; 122 }; 123 } // namespace AccountSA 124 } // namespace OHOS 125 #endif // OS_ACCOUNT_INTERFACES_INNERKITS_ACCOUNT_IAM_NATIVE_INCLUDE_ACCOUNT_IAM_INFO_H 126