• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2025 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 "parcel.h"
25 #include "user_access_ctrl_client_callback.h"
26 #include "user_auth_client_callback.h"
27 #include "user_auth_client_defines.h"
28 #include "user_idm_client.h"
29 #include "user_idm_client_callback.h"
30 #include "user_idm_client_defines.h"
31 
32 namespace OHOS {
33 namespace AccountSA {
34 #ifdef HAS_PIN_AUTH_PART
35 typedef UserIam::PinAuth::IInputer IInputer;
36 typedef UserIam::PinAuth::IInputerData IInputerData;
37 #endif
38 
39 typedef UserIam::UserAuth::ResultCode ResultCode;
40 typedef UserIam::UserAuth::AuthType AuthType;
41 typedef UserIam::UserAuth::Attributes Attributes;
42 typedef UserIam::UserAuth::SecUserInfo SecUserInfo;
43 typedef UserIam::UserAuth::AuthTrustLevel AuthTrustLevel;
44 typedef UserIam::UserAuth::AuthenticationCallback AuthenticationCallback;
45 typedef UserIam::UserAuth::GetPropCallback GetPropCallback;
46 typedef UserIam::UserAuth::SetPropCallback SetPropCallback;
47 typedef UserIam::UserAuth::GetPropertyRequest GetPropertyRequest;
48 typedef UserIam::UserAuth::SetPropertyRequest SetPropertyRequest;
49 typedef UserIam::UserAuth::PropertyMode PropertyMode;
50 typedef UserIam::UserAuth::PinSubType PinSubType;
51 typedef UserIam::UserAuth::UserIdmClientCallback UserIdmClientCallback;
52 typedef UserIam::UserAuth::VerifyTokenCallback VerifyTokenCallback;
53 typedef UserIam::UserAuth::CredentialParameters CredentialParameters;
54 typedef UserIam::UserAuth::CredentialInfo CredentialInfo;
55 typedef UserIam::UserAuth::GetSecUserInfoCallback GetSecUserInfoCallback;
56 typedef UserIam::UserAuth::GetCredentialInfoCallback GetCredentialInfoCallback;
57 typedef UserIam::UserAuth::PrepareRemoteAuthCallback PrepareRemoteAuthCallback;
58 typedef UserIam::UserAuth::GetSecUserInfoCallback GetSecUserInfoCallback;
59 
60 enum IAMAuthType {
61     DOMAIN = 1024,
62     TYPE_END,
63 };
64 
65 enum IAMAuthSubType {
66     DOMAIN_MIXED = 10240001
67 };
68 
69 enum IAMState {
70     IDLE = 0,
71     AFTER_OPEN_SESSION,
72     DURING_AUTHENTICATE,
73     DURING_ADD_CRED,
74     DURING_UPDATE_CRED,
75     DURING_DEL_CRED,
76     AFTER_ADD_CRED,
77     AFTER_UPDATE_CRED,
78     AFTER_DEL_CRED,
79     ROLL_BACK_DEL_CRED,
80     DURING_DEL_USER,
81 };
82 
83 struct CredentialItem {
84     int32_t type = 0;
85     std::vector<uint8_t> oldCredential;
86     std::vector<uint8_t> credential;
87 };
88 
89 enum AuthIntent : int32_t {
90     DEFAULT = 0,
91     UNLOCK = 1,
92     SILENT_AUTH = 2,
93     QUESTION_AUTH = 3,
94     ABANDONED_PIN_AUTH = 4,
95 };
96 
97 struct RemoteAuthParam {
98     std::optional<std::string> verifierNetworkId;
99     std::optional<std::string> collectorNetworkId;
100     std::optional<uint32_t> collectorTokenId;
101 };
102 
103 struct AuthParam : public Parcelable {
104     int32_t userId = 0;
105     std::vector<uint8_t> challenge;
106     AuthType authType;
107     AuthTrustLevel authTrustLevel;
108     AuthIntent authIntent = AuthIntent::DEFAULT;
109     std::optional<RemoteAuthParam> remoteAuthParam;
110     bool Marshalling(Parcel& parcel) const override;
111     static AuthParam* Unmarshalling(Parcel& parcel);
112 
113 private:
114     bool WriteRemoteAuthParam(Parcel& parcel) const;
115     bool ReadRemoteAuthParam(Parcel& parcel);
116     bool ReadFromParcel(Parcel& parcel);
117 };
118 
119 struct RemoteAuthOptions {
120     std::string verifierNetworkId;
121     std::string collectorNetworkId;
122     uint32_t collectorTokenId;
123     bool hasVerifierNetworkId = false;
124     bool hasCollectorNetworkId = false;
125     bool hasCollectorTokenId = false;
126 };
127 
128 struct AuthOptions {
129     int32_t accountId = -1;
130     AuthIntent authIntent = AuthIntent::DEFAULT;
131     RemoteAuthOptions remoteAuthOptions;
132     bool hasRemoteAuthOptions = false;
133     bool hasAccountId = false;
134 };
135 
136 struct CredentialInfoIam : public Parcelable {
137     CredentialInfo credentialInfo;
138     bool ReadFromParcel(Parcel &parcel);
139     bool Marshalling(Parcel &parcel) const override;
140     static CredentialInfoIam *Unmarshalling(Parcel &parcel);
141 };
142 
143 std::vector<CredentialInfoIam> ConvertToCredentialInfoIamList(const std::vector<CredentialInfo> &infoList);
144 std::vector<CredentialInfo> ConvertToCredentialInfoList(const std::vector<CredentialInfoIam> &infoList);
145 
146 struct CredentialParametersIam : public Parcelable {
147     CredentialParameters credentialParameters;
148     bool ReadFromParcel(Parcel &parcel);
149     bool Marshalling(Parcel &parcel) const override;
150     static CredentialParametersIam *Unmarshalling(Parcel &parcel);
151 };
152 
153 struct GetPropertyRequestIam : public Parcelable {
154     GetPropertyRequest getPropertyRequest;
155     bool ReadFromParcel(Parcel &parcel);
156     bool Marshalling(Parcel &parcel) const override;
157     static GetPropertyRequestIam *Unmarshalling(Parcel &parcel);
158 };
159 
160 struct SetPropertyRequestIam : public Parcelable {
161     SetPropertyRequest setPropertyRequest;
162     bool ReadFromParcel(Parcel &parcel);
163     bool Marshalling(Parcel &parcel) const override;
164     static SetPropertyRequestIam *Unmarshalling(Parcel &parcel);
165 };
166 }  // namespace AccountSA
167 }  // namespace OHOS
168 #endif  // OS_ACCOUNT_INTERFACES_INNERKITS_ACCOUNT_IAM_NATIVE_INCLUDE_ACCOUNT_IAM_INFO_H
169