• 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 CO_AUTH_H
17 #define CO_AUTH_H
18 
19 #include <iremote_object.h>
20 #include <singleton.h>
21 #include "coauth_callback.h"
22 #include "set_prop_callback.h"
23 #include "coauth_info_define.h"
24 #include "i_coauth.h"
25 #include "auth_attributes.h"
26 
27 namespace OHOS {
28 namespace UserIAM {
29 namespace CoAuth {
30 class CoAuth : public DelayedRefSingleton<CoAuth> {
31     DECLARE_DELAYED_REF_SINGLETON(CoAuth);
32 
33 public:
34     DISALLOW_COPY_AND_MOVE(CoAuth);
35     void BeginSchedule(uint64_t scheduleId, AuthInfo &authInfo, std::shared_ptr<CoAuthCallback> callback);
36     int32_t Cancel(uint64_t scheduleId);
37     int32_t GetExecutorProp(AuthResPool::AuthAttributes &conditions,
38                             std::shared_ptr<AuthResPool::AuthAttributes> values);
39     void SetExecutorProp(AuthResPool::AuthAttributes &conditions, std::shared_ptr<SetPropCallback> callback);
40 
41 private:
42     class CoAuthDeathRecipient : public IRemoteObject::DeathRecipient {
43     public:
44         CoAuthDeathRecipient() = default;
45         ~CoAuthDeathRecipient() = default;
46         void OnRemoteDied(const wptr<IRemoteObject>& remote) override;
47 
48     private:
49         DISALLOW_COPY_AND_MOVE(CoAuthDeathRecipient);
50     };
51     void ResetProxy(const wptr<IRemoteObject>& remote);
52     sptr<ICoAuth> GetProxy();
53     std::mutex mutex_;
54     sptr<ICoAuth> proxy_ {nullptr};
55     sptr<IRemoteObject::DeathRecipient> deathRecipient_ {nullptr};
56 };
57 } // namespace CoAuth
58 } // namespace UserIAM
59 } // namespace OHOS
60 #endif // CO_AUTH_H