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 OHOS_DM_AUTH_RESPONSE_STATE_H
17 #define OHOS_DM_AUTH_RESPONSE_STATE_H
18 
19 #include <memory>
20 
21 namespace OHOS {
22 namespace DistributedHardware {
23 class DmAuthManager;
24 struct DmAuthResponseContext;
25 class AuthResponseState : public std::enable_shared_from_this<AuthResponseState> {
26 public:
~AuthResponseState()27     virtual ~AuthResponseState()
28     {
29         authManager_.reset();
30     };
31     virtual int32_t GetStateType() = 0;
32     virtual int32_t Enter() = 0;
33 
34     /**
35      * @tc.name: AuthResponseState::Leave
36      * @tc.desc: Leave of the Auth Response State
37      * @tc.type: FUNC
38      */
39     int32_t Leave();
40 
41     /**
42      * @tc.name: AuthResponseState::TransitionTo
43      * @tc.desc: Transition of the Auth Response State
44      * @tc.type: FUNC
45      */
46     int32_t TransitionTo(std::shared_ptr<AuthResponseState> state);
47 
48     /**
49      * @tc.name: AuthResponseState::SetAuthManager
50      * @tc.desc: Set Auth Manager of the Auth Response State
51      * @tc.type: FUNC
52      */
53     int32_t SetAuthManager(std::shared_ptr<DmAuthManager> authManager);
54 
55     /**
56      * @tc.name: AuthResponseState::SetAuthContext
57      * @tc.desc: Set Auth Context of the Auth Response State
58      * @tc.type: FUNC
59      */
60     int32_t SetAuthContext(std::shared_ptr<DmAuthResponseContext> context);
61 
62     /**
63      * @tc.name: AuthResponseState::GetAuthContext
64      * @tc.desc: Get Auth Context of the Auth Response State
65      * @tc.type: FUNC
66      */
67     std::shared_ptr<DmAuthResponseContext> GetAuthContext();
68 
69 protected:
70     std::weak_ptr<DmAuthManager> authManager_;
71     std::shared_ptr<DmAuthResponseContext> context_;
72 };
73 
74 class AuthResponseInitState : public AuthResponseState {
75 public:
76     int32_t GetStateType() override;
77     int32_t Enter() override;
78 };
79 
80 class AuthResponseNegotiateState : public AuthResponseState {
81 public:
82     int32_t GetStateType() override;
83     int32_t Enter() override;
84 };
85 
86 class AuthResponseConfirmState : public AuthResponseState {
87 public:
88     int32_t GetStateType() override;
89     int32_t Enter() override;
90 };
91 
92 class AuthResponseGroupState : public AuthResponseState {
93 public:
94     int32_t GetStateType() override;
95     int32_t Enter() override;
96 };
97 
98 class AuthResponseShowState : public AuthResponseState {
99 public:
100     int32_t GetStateType() override;
101     int32_t Enter() override;
102 };
103 
104 class AuthResponseFinishState : public AuthResponseState {
105 public:
106     int32_t GetStateType() override;
107     int32_t Enter() override;
108 };
109 
110 class AuthResponseCredential : public AuthResponseState {
111 public:
112     int32_t GetStateType() override;
113     int32_t Enter() override;
114 };
115 
116 class AuthResponseSyncDeleteAcl : public AuthResponseState {
117 public:
118     int32_t GetStateType() override;
119     int32_t Enter() override;
120 };
121 
122 class AuthResponseSyncDeleteAclNone : public AuthResponseState {
123 public:
124     int32_t GetStateType() override;
125     int32_t Enter() override;
126 };
127 } // namespace DistributedHardware
128 } // namespace OHOS
129 #endif // OHOS_DM_AUTH_RESPONSE_STATE_H
130