• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 AUTH_RES_MANAGER_H
17 #define AUTH_RES_MANAGER_H
18 
19 #include <iremote_object.h>
20 #include "auth_res_pool.h"
21 #include "auth_executor.h"
22 #include "iexecutor_callback.h"
23 #include "iquery_callback.h"
24 #include "coauth_interface.h"
25 
26 namespace OHOS {
27 namespace UserIAM {
28 namespace CoAuth {
29 class AuthResManager {
30 public:
31     uint64_t Register(std::shared_ptr<ResAuthExecutor> executorInfo, sptr<ResIExecutorCallback> callback);
32     void QueryStatus(ResAuthExecutor &executorInfo, sptr<ResIQueryCallback> callback);
33     int32_t FindExecutorCallback(uint64_t executorID, sptr<ResIExecutorCallback> &callback);
34     int32_t FindExecutorCallback(uint32_t authType, sptr<ResIExecutorCallback> &callback);
35     int32_t DeleteExecutorCallback(uint64_t executorID);
36     int32_t SaveScheduleCallback(uint64_t scheduleId, uint64_t executorNum, sptr<ICoAuthCallback> callback);
37     int32_t FindScheduleCallback(uint64_t scheduleId, sptr<ICoAuthCallback> &callback);
38     int32_t DeleteScheduleCallback(uint64_t scheduleId);
39 private:
40     class ResIExecutorCallbackDeathRecipient : public IRemoteObject::DeathRecipient {
41     public:
42         ResIExecutorCallbackDeathRecipient(uint64_t executorID, AuthResManager* parent);
43         ~ResIExecutorCallbackDeathRecipient() = default;
44         void OnRemoteDied(const wptr<IRemoteObject>& remote) override;
45 
46     private:
47         uint64_t executorID_;
48         AuthResManager* parent_;
49         DISALLOW_COPY_AND_MOVE(ResIExecutorCallbackDeathRecipient);
50     };
51     AuthResPool coAuthResPool_;
52 };
53 } // namespace CoAuth
54 } // namespace UserIAM
55 } // namespace OHOS
56 #endif // AUTH_RES_MANAGER_H
57