Move policy to commons library 91/136891/2
authorZofia Abramowska <z.abramowska@samsung.com>
Mon, 3 Jul 2017 09:09:34 +0000 (11:09 +0200)
committerZofia Abramowska <z.abramowska@samsung.com>
Mon, 3 Jul 2017 09:51:06 +0000 (11:51 +0200)
* bring back commons library and rpm
* move Policy and PkgInfo to commons

Change-Id: Ic5e5c1f4ffc642e09100ac3f7a3cb6dc2d7db0d4

12 files changed:
CMakeLists.txt
packaging/askuser-notification.spec
packaging/libaskuser-common.manifest [deleted file]
packaging/libaskuser-notification-common.manifest [new file with mode: 0644]
src/common/CMakeLists.txt
src/common/policy/PkgInfo.h [new file with mode: 0644]
src/common/policy/Policy.cpp [new file with mode: 0644]
src/common/policy/Policy.h [new file with mode: 0644]
src/notification-daemon/CMakeLists.txt
src/notification-daemon/policy/PkgInfo.h [deleted file]
src/notification-daemon/policy/Policy.cpp [deleted file]
src/notification-daemon/policy/Policy.h [deleted file]

index 2211db488ef701d4f13bb700f861f773d69d8b0d..76ba1e042dfa524a368676ab10f9c8a09c912eef 100644 (file)
@@ -79,11 +79,13 @@ SET(ASKUSER_PATH ${PROJECT_SOURCE_DIR}/src)
 
 
 SET(TARGET_ASKUSER_NOTIFICATION "askuser-notification")
+SET(TARGET_ASKUSER_COMMON "askuser-notification-common")
 SET(TARGET_ASKUSER_NOTIFICATION_LIB "askuser-notification-ipc")
 SET(TARGET_ASKUSER_NOTIFICATION_TEST "askuser-notification-test")
 SET(TARGET_PLUGIN_SERVICE "askuser-plugin-service")
 ADD_SUBDIRECTORY(src/plugin)
 ADD_SUBDIRECTORY(src/notification-daemon)
+ADD_SUBDIRECTORY(src/common)
 ADD_SUBDIRECTORY(src/common/protocol)
 
 IF (BUILD_WITH_SYSTEMD_DAEMON)
index 6c0e6be4b1bb0d0d9bb188914cad84facae0572b..e7dd07e58a8d3b93751fe8232322772c1be1a24c 100644 (file)
@@ -10,6 +10,7 @@ Group:      Security/Access Control
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1001:    default.manifest
+Source1002:    libaskuser-notification-common.manifest
 BuildRequires: cmake
 BuildRequires: libwayland-egl
 BuildRequires: gettext-tools
@@ -36,6 +37,12 @@ BuildRequires: edje-bin
 %description
 Daemon allowing user to grant or deny access for given application and privilege
 
+%package -n libaskuser-notification-common
+Summary:    Askuser common library
+
+%description -n libaskuser-notification-common
+Askuser common library with common functionalities
+
 %package libs
 Summary: Askuser notification protocol library
 
@@ -63,6 +70,7 @@ Tool for testing askuser-notification
 %prep
 %setup -q
 cp -a %{SOURCE1001} .
+cp -a %{SOURCE1002} .
 
 %build
 %if 0%{?sec_build_binary_debug_enable}
@@ -101,6 +109,10 @@ systemctl daemon-reload
 
 %postun
 
+%post -n libaskuser-notification-common -p /sbin/ldconfig
+
+%postun -n libaskuser-notification-common -p /sbin/ldconfig
+
 %post plugin
 systemctl restart cynara.service
 
@@ -122,6 +134,11 @@ systemctl restart cynara.service
 %endif
 %{_datadir}/askuser-notification/res/*
 
+%files -n libaskuser-notification-common
+%manifest libaskuser-notification-common.manifest
+%license LICENSE
+%{_libdir}/libaskuser-notification-common.so*
+
 %files libs
 %manifest default.manifest
 %license LICENSE
diff --git a/packaging/libaskuser-common.manifest b/packaging/libaskuser-common.manifest
deleted file mode 100644 (file)
index a76fdba..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
-       <request>
-               <domain name="_" />
-       </request>
-</manifest>
diff --git a/packaging/libaskuser-notification-common.manifest b/packaging/libaskuser-notification-common.manifest
new file mode 100644 (file)
index 0000000..a76fdba
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
index bce110ed90fd32a7c037a0d7bf06c4a9d3600a3e..6e3e8e66f26a4ef081e29802ac85c2edcea3a26c 100644 (file)
 
 PKG_CHECK_MODULES(COMMON_DEP
     REQUIRED
-    cynara-plugin
-    cynara-agent
-    glib-2.0
-    libsystemd
-    security-privilege-manager
+    security-manager
+    pkgmgr-info
     )
 
 SET(ASKUSER_COMMON_VERSION_MAJOR 0)
@@ -40,15 +37,10 @@ INCLUDE_DIRECTORIES(
 
 SET(COMMON_SOURCES
     ${COMMON_PATH}/log/alog.cpp
-    ${COMMON_PATH}/policy/PrivilegeInfo.cpp
-    ${COMMON_PATH}/socket/Socket.cpp
-    ${COMMON_PATH}/socket/Poll.cpp
-    ${COMMON_PATH}/translator/Translator.cpp
-    ${COMMON_PATH}/translator/GuiTranslator.cpp
+    ${COMMON_PATH}/policy/Policy.cpp
     ${COMMON_PATH}/types/AgentErrorMsg.cpp
     ${COMMON_PATH}/util/SafeFunction.cpp
     ${COMMON_PATH}/config/Limits.cpp
-    ${COMMON_PATH}/config/Path.cpp
     )
 
 ADD_DEFINITIONS("-fvisibility=default")
diff --git a/src/common/policy/PkgInfo.h b/src/common/policy/PkgInfo.h
new file mode 100644 (file)
index 0000000..e2f9e59
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ *  Copyright (c) 2017 Samsung Electronics Co.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+/**
+ * @file        src/common/policy/PkgInfo.h
+ * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @brief       Definition of pkgmgr-info wrappers
+ */
+
+#pragma once
+
+#include <string>
+#include <sys/types.h>
+#include <pkgmgr-info.h>
+
+#include <log/alog.h>
+
+struct PkgInfo {
+    PkgInfo(const std::string &pkgId, uid_t uid) : m_handle(nullptr) {
+        int ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgId.c_str(), uid, &m_handle);
+        if (ret != PMINFO_R_OK) {
+            ALOGE("pkgmgrinfo_pkginfo_get_usr_pkginfo failed for " << pkgId  << " with " << ret);
+            m_handle = nullptr;
+        }
+    }
+    ~PkgInfo() {
+        if (m_handle)
+            pkgmgrinfo_pkginfo_destroy_pkginfo(m_handle);
+    }
+    const std::string mainAppId(){
+        if (!m_handle) {
+            return "";
+        }
+        char *mainAppId;
+        int ret = pkgmgrinfo_pkginfo_get_mainappid(m_handle, &mainAppId);
+        if (ret != PMINFO_R_OK) {
+            ALOGE("pkgmgrinfo_pkginfo_get_mainappid failed  with " << ret);
+            return "";
+        }
+        return mainAppId ? mainAppId : "";
+    }
+    const std::string pkgLabel() {
+        if (!m_handle) {
+            return "";
+        }
+        char *pkgLabel;
+        int ret = pkgmgrinfo_pkginfo_get_label(m_handle, &pkgLabel);
+        if (ret != PMINFO_R_OK) {
+            ALOGE("pkgmgrinfo_pkginfo_get_label failed  with " << ret);
+            return "";
+        }
+        return pkgLabel ? pkgLabel : "";
+    }
+    pkgmgrinfo_pkginfo_h m_handle;
+};
diff --git a/src/common/policy/Policy.cpp b/src/common/policy/Policy.cpp
new file mode 100644 (file)
index 0000000..61acd51
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ *  Copyright (c) 2016-2017 Samsung Electronics Co.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+/**
+ * @file        src/agent/main/Policy.cpp
+ * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @brief       Implementation of Policy wrappers
+ */
+
+#include <memory>
+
+#include <security-manager.h>
+
+#include <exception/Exception.h>
+#include <log/alog.h>
+
+#include "PkgInfo.h"
+#include "Policy.h"
+
+namespace {
+inline void throwOnSMError(std::string err, int ret)
+{
+    if (ret != SECURITY_MANAGER_SUCCESS)
+        throw AskUser::Exception("SM error : " + err + " : " + std::to_string(ret));
+}
+
+inline void throwOnSMNullptr(std::string err, const char *ret)
+{
+    if (ret == nullptr)
+        throw AskUser::Exception("SM error : " + err + " : " + ret);
+}
+}
+
+namespace AskUser {
+
+void identifyApp(const std::string &client, std::string &appId, std::string &pkgLabel)
+{
+    char *pkgName = nullptr;
+    char *appName = nullptr;
+
+    int ret = security_manager_identify_app_from_cynara_client(client.c_str(), &pkgName, &appName);
+    std::unique_ptr<char, decltype(free)*> pkg_name_p(pkgName, free);
+    std::unique_ptr<char, decltype(free)*> app_name_p(appName, free);
+    throwOnSMError("security_manager_identify_app_from_cynara_client", ret);
+
+    if (!pkgName) {
+        ALOGE("Couldn't identify clients package id");
+        return;
+    }
+
+    PkgInfo pkgInfo(pkgName, geteuid());
+    if (!appName)
+        appId = pkgInfo.mainAppId();
+
+    pkgLabel = pkgInfo.pkgLabel();
+}
+
+PolicyEntry::PolicyEntry() {
+    throwOnSMError("security_manager_policy_entry_new",
+                                  security_manager_policy_entry_new(&m_entry));
+}
+
+PolicyEntry::PolicyEntry(PolicyEntry &&other) : m_entry(std::move(other.m_entry)) {
+    other.m_entry = nullptr;
+}
+
+PolicyEntry::~PolicyEntry() {
+    security_manager_policy_entry_free(m_entry);
+}
+
+void PolicyEntry::setApp(const std::string &appId) {
+    throwOnSMError("security_manager_policy_entry_set_application",
+                   security_manager_policy_entry_set_application(m_entry, appId.c_str()));
+}
+
+std::string PolicyEntry::getAppId() {
+    const char *app;
+    throwOnSMNullptr("security_manager_policy_entry_get_application",
+                     app = security_manager_policy_entry_get_application(m_entry));
+    return app;
+}
+
+void PolicyEntry::setUser(const std::string &user) {
+    throwOnSMError("security_manager_policy_entry_set_user",
+                   security_manager_policy_entry_set_user(m_entry, user.c_str()));
+}
+
+std::string PolicyEntry::getUser() {
+    const char *user;
+    throwOnSMNullptr("security_manager_policy_entry_get_user",
+                     user = security_manager_policy_entry_get_user(m_entry));
+    return user;
+}
+
+void PolicyEntry::setPrivilege(const std::string &privilege) {
+    throwOnSMError("security_manager_policy_entry_set_privilege",
+                   security_manager_policy_entry_set_privilege(m_entry, privilege.c_str()));
+}
+
+std::string PolicyEntry::getPrivilege() {
+    const char *privilege;
+    throwOnSMNullptr("security_manager_policy_entry_get_privilege",
+                     privilege = security_manager_policy_entry_get_privilege(m_entry));
+    return privilege;
+}
+
+void PolicyEntry::setLevel(const std::string &level) {
+    throwOnSMError("security_manager_policy_entry_admin_set_level",
+                   security_manager_policy_entry_set_level(m_entry, level.c_str()));
+}
+
+std::string PolicyEntry::getLevel() {
+    const char *level;
+    throwOnSMNullptr("security_manager_policy_entry_get_level",
+            level = security_manager_policy_entry_get_level(m_entry));
+    return level;
+}
+
+
+PolicyRequest::PolicyRequest() {
+    throwOnSMError("security_manager_policy_update_req_new",
+                   security_manager_policy_update_req_new(&m_req));
+}
+
+PolicyRequest::~PolicyRequest() {
+    m_entries.clear();
+    security_manager_policy_update_req_free(m_req);
+}
+
+void PolicyRequest::addEntry(PolicyEntry &&entry) {
+    throwOnSMError("security_manager_policy_update_req_add_entry",
+                   security_manager_policy_update_req_add_entry(m_req, entry.get()));
+    m_entries.emplace_back(std::move(entry));
+}
+
+void PolicyRequest::updatePolicy() {
+    throwOnSMError("security_manager_policy_update_send",
+                   security_manager_policy_update_send(m_req));
+}
+
+
+std::vector<PolicyEntry> PolicyFetchRequest::fetchPolicy() {
+    policy_entry **pp_entries;
+    size_t p_size;
+    throwOnSMError("security_manager_get_configured_policy_for_self",
+                   security_manager_get_configured_policy_for_self(m_filter.get(), &pp_entries, &p_size));
+    std::unique_ptr<policy_entry *, std::function<void(policy_entry **)>> ppPtr(pp_entries,
+            [p_size](policy_entry **p) {
+                security_manager_policy_entries_free(*p, p_size);
+            }
+    );
+    std::vector<PolicyEntry> entries;
+    for(size_t i = 0; i < p_size; i++) {
+        entries.emplace_back(PolicyEntry(pp_entries[i]));
+    }
+    ppPtr.release();
+    return entries;
+}
+
+} /* namespace AskUser */
diff --git a/src/common/policy/Policy.h b/src/common/policy/Policy.h
new file mode 100644 (file)
index 0000000..f3abb93
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ *  Copyright (c) 2016-2017 Samsung Electronics Co.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+/**
+ * @file        src/agent/main/Policy.h
+ * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @brief       Definition of Policy wrappers
+ */
+
+#pragma once
+
+#include <string>
+#include <vector>
+
+struct policy_entry;
+struct policy_update_req;
+
+namespace AskUser {
+
+void identifyApp(const std::string &client, std::string &appId, std::string &pkgLabel);
+
+class PolicyEntry {
+public:
+    PolicyEntry();
+    PolicyEntry(PolicyEntry &&other);
+    PolicyEntry(policy_entry *entry) { m_entry = entry; }
+    ~PolicyEntry();
+    void setApp(const std::string &appId);
+    std::string getAppId();
+    void setUser(const std::string &user);
+    std::string getUser();
+    void setPrivilege(const std::string &privilege);
+    std::string getPrivilege();
+    void setLevel(const std::string &level);
+    std::string getLevel();
+
+    policy_entry *get() const { return m_entry; }
+
+private:
+    policy_entry *m_entry;
+};
+
+class PolicyRequest {
+public:
+    PolicyRequest();
+    ~PolicyRequest();
+    void addEntry(PolicyEntry &&entry);
+    void updatePolicy();
+
+private:
+    policy_update_req *m_req;
+    std::vector<PolicyEntry> m_entries;
+};
+
+class PolicyFetchRequest {
+public:
+    PolicyFetchRequest(PolicyEntry &&filter) : m_filter(std::move(filter)) {}
+    ~PolicyFetchRequest() {}
+    std::vector<PolicyEntry> fetchPolicy();
+private:
+    PolicyEntry m_filter;
+};
+
+} /* namespace AskUser */
index 80e724cb6de294ac29a696af7766dbf250b315c5..db964202d5775147b777c78408bc6f2e5fc896f5 100644 (file)
@@ -10,12 +10,10 @@ PKG_CHECK_MODULES(ASKUSER_NOTIFICATION_DEP
     libsystemd
     notification
     vconf
-    pkgmgr-info
     glib-2.0
     capi-ui-efl-util
     capi-system-info
     security-privilege-manager
-    security-manager
 )
 
 INCLUDE_DIRECTORIES(SYSTEM
@@ -33,10 +31,8 @@ SET(ASKUSER_NOTIFICATION_SOURCES
     ${NOTIF_PATH}/Logic.cpp
     ${NOTIF_PATH}/PolicyUpdater.cpp
     ${NOTIF_PATH}/ServerCallbacks.cpp
-    ${NOTIF_PATH}/policy/Policy.cpp
     ${NOTIF_PATH}/policy/PrivilegeInfo.cpp
     ${NOTIF_PATH}/ui/Po.cpp
-    ${ASKUSER_PATH}/common/log/alog.cpp
     ${NOTIF_PATH}/ui/Popupper.cpp
    )
 
diff --git a/src/notification-daemon/policy/PkgInfo.h b/src/notification-daemon/policy/PkgInfo.h
deleted file mode 100644 (file)
index e2f9e59..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- *  Copyright (c) 2017 Samsung Electronics Co.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-/**
- * @file        src/common/policy/PkgInfo.h
- * @author      Zofia Abramowska <z.abramowska@samsung.com>
- * @brief       Definition of pkgmgr-info wrappers
- */
-
-#pragma once
-
-#include <string>
-#include <sys/types.h>
-#include <pkgmgr-info.h>
-
-#include <log/alog.h>
-
-struct PkgInfo {
-    PkgInfo(const std::string &pkgId, uid_t uid) : m_handle(nullptr) {
-        int ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgId.c_str(), uid, &m_handle);
-        if (ret != PMINFO_R_OK) {
-            ALOGE("pkgmgrinfo_pkginfo_get_usr_pkginfo failed for " << pkgId  << " with " << ret);
-            m_handle = nullptr;
-        }
-    }
-    ~PkgInfo() {
-        if (m_handle)
-            pkgmgrinfo_pkginfo_destroy_pkginfo(m_handle);
-    }
-    const std::string mainAppId(){
-        if (!m_handle) {
-            return "";
-        }
-        char *mainAppId;
-        int ret = pkgmgrinfo_pkginfo_get_mainappid(m_handle, &mainAppId);
-        if (ret != PMINFO_R_OK) {
-            ALOGE("pkgmgrinfo_pkginfo_get_mainappid failed  with " << ret);
-            return "";
-        }
-        return mainAppId ? mainAppId : "";
-    }
-    const std::string pkgLabel() {
-        if (!m_handle) {
-            return "";
-        }
-        char *pkgLabel;
-        int ret = pkgmgrinfo_pkginfo_get_label(m_handle, &pkgLabel);
-        if (ret != PMINFO_R_OK) {
-            ALOGE("pkgmgrinfo_pkginfo_get_label failed  with " << ret);
-            return "";
-        }
-        return pkgLabel ? pkgLabel : "";
-    }
-    pkgmgrinfo_pkginfo_h m_handle;
-};
diff --git a/src/notification-daemon/policy/Policy.cpp b/src/notification-daemon/policy/Policy.cpp
deleted file mode 100644 (file)
index 61acd51..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- *  Copyright (c) 2016-2017 Samsung Electronics Co.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-/**
- * @file        src/agent/main/Policy.cpp
- * @author      Zofia Abramowska <z.abramowska@samsung.com>
- * @brief       Implementation of Policy wrappers
- */
-
-#include <memory>
-
-#include <security-manager.h>
-
-#include <exception/Exception.h>
-#include <log/alog.h>
-
-#include "PkgInfo.h"
-#include "Policy.h"
-
-namespace {
-inline void throwOnSMError(std::string err, int ret)
-{
-    if (ret != SECURITY_MANAGER_SUCCESS)
-        throw AskUser::Exception("SM error : " + err + " : " + std::to_string(ret));
-}
-
-inline void throwOnSMNullptr(std::string err, const char *ret)
-{
-    if (ret == nullptr)
-        throw AskUser::Exception("SM error : " + err + " : " + ret);
-}
-}
-
-namespace AskUser {
-
-void identifyApp(const std::string &client, std::string &appId, std::string &pkgLabel)
-{
-    char *pkgName = nullptr;
-    char *appName = nullptr;
-
-    int ret = security_manager_identify_app_from_cynara_client(client.c_str(), &pkgName, &appName);
-    std::unique_ptr<char, decltype(free)*> pkg_name_p(pkgName, free);
-    std::unique_ptr<char, decltype(free)*> app_name_p(appName, free);
-    throwOnSMError("security_manager_identify_app_from_cynara_client", ret);
-
-    if (!pkgName) {
-        ALOGE("Couldn't identify clients package id");
-        return;
-    }
-
-    PkgInfo pkgInfo(pkgName, geteuid());
-    if (!appName)
-        appId = pkgInfo.mainAppId();
-
-    pkgLabel = pkgInfo.pkgLabel();
-}
-
-PolicyEntry::PolicyEntry() {
-    throwOnSMError("security_manager_policy_entry_new",
-                                  security_manager_policy_entry_new(&m_entry));
-}
-
-PolicyEntry::PolicyEntry(PolicyEntry &&other) : m_entry(std::move(other.m_entry)) {
-    other.m_entry = nullptr;
-}
-
-PolicyEntry::~PolicyEntry() {
-    security_manager_policy_entry_free(m_entry);
-}
-
-void PolicyEntry::setApp(const std::string &appId) {
-    throwOnSMError("security_manager_policy_entry_set_application",
-                   security_manager_policy_entry_set_application(m_entry, appId.c_str()));
-}
-
-std::string PolicyEntry::getAppId() {
-    const char *app;
-    throwOnSMNullptr("security_manager_policy_entry_get_application",
-                     app = security_manager_policy_entry_get_application(m_entry));
-    return app;
-}
-
-void PolicyEntry::setUser(const std::string &user) {
-    throwOnSMError("security_manager_policy_entry_set_user",
-                   security_manager_policy_entry_set_user(m_entry, user.c_str()));
-}
-
-std::string PolicyEntry::getUser() {
-    const char *user;
-    throwOnSMNullptr("security_manager_policy_entry_get_user",
-                     user = security_manager_policy_entry_get_user(m_entry));
-    return user;
-}
-
-void PolicyEntry::setPrivilege(const std::string &privilege) {
-    throwOnSMError("security_manager_policy_entry_set_privilege",
-                   security_manager_policy_entry_set_privilege(m_entry, privilege.c_str()));
-}
-
-std::string PolicyEntry::getPrivilege() {
-    const char *privilege;
-    throwOnSMNullptr("security_manager_policy_entry_get_privilege",
-                     privilege = security_manager_policy_entry_get_privilege(m_entry));
-    return privilege;
-}
-
-void PolicyEntry::setLevel(const std::string &level) {
-    throwOnSMError("security_manager_policy_entry_admin_set_level",
-                   security_manager_policy_entry_set_level(m_entry, level.c_str()));
-}
-
-std::string PolicyEntry::getLevel() {
-    const char *level;
-    throwOnSMNullptr("security_manager_policy_entry_get_level",
-            level = security_manager_policy_entry_get_level(m_entry));
-    return level;
-}
-
-
-PolicyRequest::PolicyRequest() {
-    throwOnSMError("security_manager_policy_update_req_new",
-                   security_manager_policy_update_req_new(&m_req));
-}
-
-PolicyRequest::~PolicyRequest() {
-    m_entries.clear();
-    security_manager_policy_update_req_free(m_req);
-}
-
-void PolicyRequest::addEntry(PolicyEntry &&entry) {
-    throwOnSMError("security_manager_policy_update_req_add_entry",
-                   security_manager_policy_update_req_add_entry(m_req, entry.get()));
-    m_entries.emplace_back(std::move(entry));
-}
-
-void PolicyRequest::updatePolicy() {
-    throwOnSMError("security_manager_policy_update_send",
-                   security_manager_policy_update_send(m_req));
-}
-
-
-std::vector<PolicyEntry> PolicyFetchRequest::fetchPolicy() {
-    policy_entry **pp_entries;
-    size_t p_size;
-    throwOnSMError("security_manager_get_configured_policy_for_self",
-                   security_manager_get_configured_policy_for_self(m_filter.get(), &pp_entries, &p_size));
-    std::unique_ptr<policy_entry *, std::function<void(policy_entry **)>> ppPtr(pp_entries,
-            [p_size](policy_entry **p) {
-                security_manager_policy_entries_free(*p, p_size);
-            }
-    );
-    std::vector<PolicyEntry> entries;
-    for(size_t i = 0; i < p_size; i++) {
-        entries.emplace_back(PolicyEntry(pp_entries[i]));
-    }
-    ppPtr.release();
-    return entries;
-}
-
-} /* namespace AskUser */
diff --git a/src/notification-daemon/policy/Policy.h b/src/notification-daemon/policy/Policy.h
deleted file mode 100644 (file)
index f3abb93..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *  Copyright (c) 2016-2017 Samsung Electronics Co.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-/**
- * @file        src/agent/main/Policy.h
- * @author      Zofia Abramowska <z.abramowska@samsung.com>
- * @brief       Definition of Policy wrappers
- */
-
-#pragma once
-
-#include <string>
-#include <vector>
-
-struct policy_entry;
-struct policy_update_req;
-
-namespace AskUser {
-
-void identifyApp(const std::string &client, std::string &appId, std::string &pkgLabel);
-
-class PolicyEntry {
-public:
-    PolicyEntry();
-    PolicyEntry(PolicyEntry &&other);
-    PolicyEntry(policy_entry *entry) { m_entry = entry; }
-    ~PolicyEntry();
-    void setApp(const std::string &appId);
-    std::string getAppId();
-    void setUser(const std::string &user);
-    std::string getUser();
-    void setPrivilege(const std::string &privilege);
-    std::string getPrivilege();
-    void setLevel(const std::string &level);
-    std::string getLevel();
-
-    policy_entry *get() const { return m_entry; }
-
-private:
-    policy_entry *m_entry;
-};
-
-class PolicyRequest {
-public:
-    PolicyRequest();
-    ~PolicyRequest();
-    void addEntry(PolicyEntry &&entry);
-    void updatePolicy();
-
-private:
-    policy_update_req *m_req;
-    std::vector<PolicyEntry> m_entries;
-};
-
-class PolicyFetchRequest {
-public:
-    PolicyFetchRequest(PolicyEntry &&filter) : m_filter(std::move(filter)) {}
-    ~PolicyFetchRequest() {}
-    std::vector<PolicyEntry> fetchPolicy();
-private:
-    PolicyEntry m_filter;
-};
-
-} /* namespace AskUser */