• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SERVICES_ACCOUNTMGR_INCLUDE_IAM_STUB_H
17 #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_IAM_STUB_H
18 
19 #include "iaccount_iam.h"
20 
21 #include <map>
22 #include "account_error_no.h"
23 #include "account_permission_manager.h"
24 #include "iremote_stub.h"
25 
26 namespace OHOS {
27 namespace AccountSA {
28 class AccountIAMMgrStub : public IRemoteStub<IAccountIAM> {
29 public:
30     using MessageProcFunction = ErrCode (*)(AccountIAMMgrStub *ptr, MessageParcel &data, MessageParcel &reply);
31     typedef struct AccountIAMMessageProc {
32         MessageProcFunction messageProcFunction;
33         bool isSyetemApi = false;
34     } AccountIAMMessageProc;
35     AccountIAMMgrStub();
36     ~AccountIAMMgrStub() override;
37     int OnRemoteRequest(
38         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
39 
40 public:
41     ErrCode ProcOpenSession(MessageParcel &data, MessageParcel &reply);
42     ErrCode ProcCloseSession(MessageParcel &data, MessageParcel &reply);
43     ErrCode ProcAddCredential(MessageParcel &data, MessageParcel &reply);
44     ErrCode ProcUpdateCredential(MessageParcel &data, MessageParcel &reply);
45     ErrCode ProcDelCred(MessageParcel &data, MessageParcel &reply);
46     ErrCode ProcDelUser(MessageParcel &data, MessageParcel &reply);
47     ErrCode ProcCancel(MessageParcel &data, MessageParcel &reply);
48     ErrCode ProcGetCredentialInfo(MessageParcel &data, MessageParcel &reply);
49     ErrCode ProcPrepareRemoteAuth(MessageParcel &data, MessageParcel &reply);
50     ErrCode ProcAuthUser(MessageParcel &data, MessageParcel &reply);
51     ErrCode ProcCancelAuth(MessageParcel &data, MessageParcel &reply);
52     ErrCode ProcGetAvailableStatus(MessageParcel &data, MessageParcel &reply);
53     ErrCode ProcGetProperty(MessageParcel &data, MessageParcel &reply);
54     ErrCode ProcSetProperty(MessageParcel &data, MessageParcel &reply);
55     ErrCode ProcGetEnrolledId(MessageParcel &data, MessageParcel &reply);
56     ErrCode ProcGetAccountState(MessageParcel &data, MessageParcel &reply);
57     ErrCode ReadUserIdAndAuthType(MessageParcel &data, int32_t &userId, int32_t &authType);
58     ErrCode ReadAuthParam(MessageParcel &data, AuthParam &authParam);
59     ErrCode ReadRemoteAuthParam(MessageParcel &data, std::optional<RemoteAuthParam> &remoteAuthParam);
60     ErrCode AddOrUpdateCredential(MessageParcel &data, MessageParcel &reply, bool isAdd = true);
61     bool CheckPermission(const std::string &permission);
62 
63 private:
64     std::map<uint32_t, AccountIAMMessageProc> messageProcMap_;
65     DISALLOW_COPY_AND_MOVE(AccountIAMMgrStub);
66 };
67 }  // namespace AccountSA
68 }  // namespace OHOS
69 #endif  // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_IAM_STUB_H