0f7aca12c9c3961702ec41cecf59b05f0948f02c
[platform/core/security/askuser.git] / src / common / policy / Policy.h
1 /*
2  *  Copyright (c) 2016-2017 Samsung Electronics Co.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  */
16 /**
17  * @file        src/agent/main/Policy.h
18  * @author      Zofia Abramowska <z.abramowska@samsung.com>
19  * @brief       Definition of Policy wrappers
20  */
21
22 #pragma once
23
24 #include <string>
25 #include <vector>
26
27 struct policy_entry;
28 struct policy_update_req;
29
30 namespace AskUser {
31
32 void identifyApp(const std::string &client, std::string &appId, std::string &pkgLabel);
33 std::string getOwnAppId();
34
35 class PolicyEntry {
36 public:
37     PolicyEntry();
38     PolicyEntry(PolicyEntry &&other);
39     PolicyEntry(policy_entry *entry) { m_entry = entry; }
40     ~PolicyEntry();
41     void setApp(const std::string &appId);
42     std::string getAppId();
43     void setUser(const std::string &user);
44     std::string getUser();
45     void setPrivilege(const std::string &privilege);
46     std::string getPrivilege();
47     void setLevel(const std::string &level);
48     std::string getLevel();
49
50     policy_entry *get() const { return m_entry; }
51
52 private:
53     policy_entry *m_entry;
54 };
55
56 class PolicyRequest {
57 public:
58     PolicyRequest();
59     ~PolicyRequest();
60     void addEntry(PolicyEntry &&entry);
61     void updatePolicy();
62
63 private:
64     policy_update_req *m_req;
65     std::vector<PolicyEntry> m_entries;
66 };
67
68 class PolicyFetchRequest {
69 public:
70     PolicyFetchRequest(PolicyEntry &&filter) : m_filter(std::move(filter)) {}
71     ~PolicyFetchRequest() {}
72     std::vector<PolicyEntry> fetchPolicy();
73 private:
74     PolicyEntry m_filter;
75 };
76
77 } /* namespace AskUser */