2 * Copyright (c) 2016-2018 Samsung Electronics Co.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
17 * @file src/agent/main/Policy.h
18 * @author Zofia Grzelewska <z.abramowska@samsung.com>
19 * @brief Definition of Policy wrappers
28 #include <policy/PkgInfo.h>
29 #include <types/PolicyTypes.h>
32 struct policy_update_req;
36 class PolicyEntryCopy;
38 std::string getOwnAppId(PkgInfo &pkgInfo);
39 void identifyApp(PkgInfo &pkgInfo, const std::string &client, std::string &appId, std::string &pkgLabel);
41 std::set<Privilege> getManifestPrivs(const std::string &appId);
43 Policy getPrivilegePolicy(const std::string &appId, const Privilege &corePrivilege);
45 std::vector<PolicyEntryCopy> getAppPolicy(const std::string &appId);
50 PolicyEntry(PolicyEntry &&other);
51 PolicyEntry(policy_entry *entry) { m_entry = entry; }
53 void setApp(const std::string &appId);
54 std::string getAppId();
55 void setUser(const std::string &user);
56 std::string getUser();
57 void setPrivilege(const std::string &privilege);
58 std::string getPrivilege();
59 void setLevel(const std::string &level);
60 std::string getLevel();
62 policy_entry *get() const { return m_entry; }
65 policy_entry *m_entry;
68 class PolicyEntryCopy {
70 PolicyEntryCopy() = default;
71 PolicyEntryCopy(PolicyEntryCopy &&other) = default;
72 PolicyEntryCopy(policy_entry *entry);
73 ~PolicyEntryCopy() = default;
74 std::string getAppId() { return m_appId; }
75 std::string getUser() { return m_user; }
76 std::string getPrivilege() { return m_privilege; }
77 std::string getLevel() { return m_level; }
82 std::string m_privilege;
90 void addEntry(PolicyEntry &&entry);
94 policy_update_req *m_req;
95 std::vector<PolicyEntry> m_entries;
98 class PolicyFetchRequest {
100 PolicyFetchRequest(PolicyEntry &&filter) : m_filter(std::move(filter)) {}
101 ~PolicyFetchRequest() {}
102 std::vector<PolicyEntryCopy> fetchPolicy();
104 PolicyEntry m_filter;
107 } /* namespace AskUser */