SET(ASKUSER_PATH ${PROJECT_SOURCE_DIR}/src)
IF (BUILD_ASKUSER)
- SET(TARGET_ASKUSER "askuser")
- SET(TARGET_ASKUSER_COMMON "askuser-common")
SET(TARGET_PLUGIN_SERVICE "askuser-plugin-service")
- SET(TARGET_PLUGIN_CLIENT "askuser-plugin-client")
- SET(TARGET_PRIVACYDENIED_PLUGIN_CLIENT "privacy-denied-plugin-client")
- SET(TARGET_PRIVACYDENIED_PLUGIN_SERVICE "privacy-denied-plugin-service")
- SET(TARGET_TEST "askuser-test")
- SET(TARGET_TESTS "askuser-tests")
- ADD_SUBDIRECTORY(src/agent)
- ADD_SUBDIRECTORY(src/common)
ADD_SUBDIRECTORY(src/plugin)
- ADD_SUBDIRECTORY(test)
ENDIF (BUILD_ASKUSER)
IF (BUILD_ASKUSER_NOTIFICATION)
-%if !%{defined with_systemd_daemon}
-%define with_systemd_daemon 1
-%endif
-
Name: askuser
-Summary: Agent service for Cynara 'ask user' policy
+Summary: Agent plugin for Cynara 'ask user' policy
Version: 0.1.13
Release: 1
Group: Security/Access Control
Source0: %{name}-%{version}.tar.gz
Source1001: default.manifest
BuildRequires: cmake
-BuildRequires: pkgconfig(cynara-agent)
-%if %{with_systemd_daemon}
-BuildRequires: pkgconfig(libsystemd)
-%endif
-BuildRequires: pkgconfig(security-manager)
-BuildRequires: pkgconfig(security-privilege-manager)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(pkgmgr-info)
-BuildRequires: askuser-notification-devel
+BuildRequires: pkgconfig(cynara-plugin)
%if !%{defined build_type}
%define build_type RELEASE
%endif
%description
-Daemon allowing user to grant or deny acces for given application and privilege
-
-%package -n libaskuser-common
-Summary: Askuser common library
-
-%description -n libaskuser-common
-Askuser common library with common functionalities
-
-%package plugins
-BuildRequires: pkgconfig(cynara-plugin)
-Requires: cynara
-Requires: libcynara-client
-Summary: Askuser cynara plugins
-
-%description plugins
-Askuser plugin library with cynara service and client side plugins
-
-%package test
-BuildRequires: pkgconfig(cynara-agent)
-BuildRequires: pkgconfig(cynara-client)
-BuildRequires: pkgconfig(cynara-admin)
-BuildRequires: pkgconfig(gmock)
-Summary: Tool for testing askuser packages and unit tests for askuser
-
-%description test
-Tool for testing askuser packages and unit tests for askuser
+Plugin for supporting custom policy type "Ask user"
%prep
%setup -q
%cmake . \
-DBUILD_ASKUSER=ON \
-DCMAKE_BUILD_TYPE=%{?build_type} \
- -DBUILD_WITH_SYSTEMD_DAEMON=%{?with_systemd_daemon} \
-DCMAKE_VERBOSE_MAKEFILE=ON
make %{?jobs:-j%jobs}
%install
rm -rf %{buildroot}
%make_install
-rm -f %{buildroot}/%{_libdir}/libaskuser-common.so
-
-%if %{with_systemd_daemon}
-mkdir -p %{buildroot}/%{_unitdir}/multi-user.target.wants
-mkdir -p %{buildroot}/%{_unitdir}/cynara.service.wants
-ln -s ../askuser.service %{buildroot}/%{_unitdir}/multi-user.target.wants/askuser.service
-ln -s ../askuser.service %{buildroot}/%{_unitdir}/cynara.service.wants/askuser.service
-%endif
%post
-%if %{with_systemd_daemon}
-systemctl daemon-reload
-
-systemctl restart askuser.service
systemctl restart cynara.service
-%endif
%preun
-%if %{with_systemd_daemon}
-if [ $1 = 0 ]; then
- systemctl stop askuser.service
-fi
-%endif
%postun
-%if %{with_systemd_daemon}
-if [ $1 = 0 ]; then
- systemctl daemon-reload
-fi
-
systemctl restart cynara.service
-%endif
-
-%post -n libaskuser-common -p /sbin/ldconfig
-
-%postun -n libaskuser-common -p /sbin/ldconfig
%files
%manifest default.manifest
%license LICENSE
-%attr(755, root, root) %{_bindir}/askuser
-%if %{with_systemd_daemon}
-%{_unitdir}/askuser.service
-%{_unitdir}/multi-user.target.wants/*
-%{_unitdir}/cynara.service.wants/*
-%endif
-
-%files -n libaskuser-common
-%manifest default.manifest
-%license LICENSE
-%{_libdir}/libaskuser-common.so.*
-
-%files plugins
-%manifest default.manifest
-%license LICENSE
-%{_libdir}/cynara/plugin/client/*
%{_libdir}/cynara/plugin/service/*
-
-%files test
-%manifest default.manifest
-%license LICENSE
-%attr(755,root,root) %{_bindir}/askuser-test
-%attr(755,root,root) %{_bindir}/askuser-tests
m_popupper.setLocale();
m_popupper.initialize();
m_popupper.registerPopupResponseHandler([&](int popupId, NResponseType response) { popupResponse(popupId, response);});
- m_popupper.registerToastFinishedHandler([&](int toastId) {toastFinished(toastId);});
registerSignalFd();
processEvents();
}
-void Logic::toastFinished(int toastId) {
- if (toastId != m_currentEventId) {
- ALOGD("Got different toast id than is being processed");
- return;
- }
- finishCurrentEvent();
- processEvents();
-}
-
} // namespace Notification
} // namepsace AskUser
bool isEventProcessed();
void finishCurrentEvent();
void popupResponse(int popupId, NResponseType response);
- void toastFinished(int toastId);
AskUser::Protocol::ChannelPtr m_clientChannel;
Popupper m_popupper;
std::string m_privilege;
};
-class EventPopupLaunch : public IUIEvent {
-public:
- EventPopupLaunch(Popupper *popupper, int popupId, const std::string &appName,
- const std::string &pkgName, const std::vector<std::string> &privileges)
- : IUIEvent(popupper), m_popupId(popupId), m_appName(appName),
- m_pkgName(pkgName), m_privileges(privileges)
- {
- setId(popupId);
- }
-
- virtual void process() {
- m_popupper->popupLaunch(m_popupId, m_appName, m_pkgName, m_privileges);
- }
-private:
- int m_popupId;
- std::string m_appName;
- std::string m_pkgName;
- std::vector<std::string> m_privileges;
-};
-
-class EventToastDeny : public IUIEvent {
-public:
- EventToastDeny(Popupper *popupper, int toastId, const std::string &appName,
- const std::string &pkgName, const std::string &privilege)
- : IUIEvent(popupper), m_toastId(toastId), m_appName(appName),
- m_pkgName(pkgName), m_privilege(privilege)
- {
- setId(toastId);
- }
-
- virtual void process() {
- m_popupper->toastDeny(m_toastId, m_appName, m_pkgName, m_privilege);
- }
-private:
- int m_toastId;
- std::string m_appName;
- std::string m_pkgName;
- std::string m_privilege;
-};
-
-class EventToastFail : public IUIEvent {
-public:
- EventToastFail(Popupper *popupper, int toastId, const std::string &appName,
- const std::string &pkgName)
- : IUIEvent(popupper), m_toastId(toastId), m_appName(appName),
- m_pkgName(pkgName)
- {
- setId(toastId);
- }
-
- virtual void process() {
- m_popupper->toastFail(m_toastId, m_appName, m_pkgName);
- }
-private:
- int m_toastId;
- std::string m_appName;
- std::string m_pkgName;
-};
-
} //namespace AskUser
} //namespace Notification
PopupCheck *m_popup;
};
-class AnswerablePopupLaunch : public IAnswerable {
-public:
- AnswerablePopupLaunch(Popup *popup, AnswerHandler handler)
- : IAnswerable(handler), m_popup(popup) {}
- virtual void process(enum Button button) const {
- NResponseType answer;
- switch (button) {
- case IAnswerable::Button::ALLOW:
- answer = NResponseType::AllowAlways;
- break;
- case IAnswerable::Button::DENY:
- answer = NResponseType::DenyAlways;
- break;
- default:
- answer = NResponseType::Error;
- }
- m_handler(m_popup->getId(), answer);
- }
-private:
- Popup *m_popup;
-};
-
} // namespace AskUser
} // namespace Notification
return pkgInfo.pkgLabel();
}
-std::string getPrivacyList(const std::vector<std::string> &privs) {
- setLocale();
- std::string privacyList = "";
- for (auto &priv : privs) {
- std::string privacyName = PrivilegeInfo::getPrivacyDisplayName(priv);
- if (privacyList.find(privacyName) == std::string::npos) {
- privacyList.append("<br/>");
- privacyList.append(privacyName);
- }
- }
- return privacyList;
-}
} // namespace anonymous
namespace Notification {
return makeFromFormat(getFormat(MsgType::MSG_POPUP_TEXT), getPkgLabel(pkgName).c_str(),
PrivilegeInfo::getPrivacyDisplayName(priv).c_str());
}
-std::string createPopupLaunchMsg(const std::string &, const std::string &pkgName, const std::vector<std::string> &privs) {
- std::string launchTextFormat = makeFromFormat(getFormat(MsgType::MSG_POPUP_LAUNCH_TEXT), getPkgLabel(pkgName).c_str());
- return makeFromFormat("%s%s", launchTextFormat.c_str(), getPrivacyList(privs).c_str());
-}
-
-std::string createToastDenyMsg(const std::string &, const std::string &pkgName, const std::string &priv) {
- return makeFromFormat(getFormat(MsgType::MSG_TOAST_DENY_TEXT), getPkgLabel(pkgName).c_str(),
- PrivilegeInfo::getPrivacyDisplayName(priv).c_str());
-}
-std::string createToastFailMsg(const std::string &, const std::string &pkgName) {
- return makeFromFormat(getFormat(MsgType::MSG_TOAST_FAIL_TEXT), getPkgLabel(pkgName).c_str());
-}
std::string getPopupTitleMsg() {
return makeFromFormat("%s", getFormat(MsgType::MSG_POPUP_TITLE));
namespace Po {
std::string createPopupCheckMsg(const std::string &appName, const std::string &pkgName, const std::string &priv);
-std::string createPopupLaunchMsg(const std::string &appName, const std::string &pkgName, const std::vector<std::string> &privs);
std::string createPrivilegeDescr(const std::string &priv);
-std::string createToastDenyMsg(const std::string &appName, const std::string &pkgName, const std::string &priv);
-std::string createToastFailMsg(const std::string &appName, const std::string &pkgName);
std::string getPopupTitleMsg();
std::string getAllowButtonMsg();
+++ /dev/null
-/*
- * 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/agent/notification-daemon/ui/PopupLaunchMobile.h
- * @author Zofia Abramowska <z.abramowska@samsung.com>
- * @brief Declaration of PopupLaunchMobile class
- */
-
-#pragma once
-
-#include <Elementary.h>
-
-#include <exception/Exception.h>
-#include "Po.h"
-#include "Popup.h"
-
-namespace AskUser {
-namespace Notification {
-
-class PopupLaunchMobile : public Popup {
-public:
- PopupLaunchMobile(Evas_Object *parent, int popupId, const std::string &msg)
- : Popup(parent, msg)
- {
- setId(popupId);
- }
- virtual ~PopupLaunchMobile() {}
-
- virtual void create() {
- // popup
- elm_popup_align_set(m_popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
- elm_object_part_text_set(m_popup, "title,text", Po::getPopupTitleMsg().c_str());
- evas_object_size_hint_weight_set(m_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- // layout
- m_layout = elm_layout_add(m_popup);
- if (m_layout == nullptr) {
- ALOGE("EFL : Failed to add layout");
- throw Exception("Enlightenment failed");
- }
- elm_layout_file_set(m_layout, RES_DIR"/popup_custom.edj", "popup_layout_mobile");
- evas_object_size_hint_weight_set(m_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- // content
- m_content = elm_label_add(m_layout);
- if (!m_content) {
- ALOGE("EFL : Failed to add content");
- throw Exception("Enlightement failed");
- }
- elm_object_text_set(m_content, m_msg.c_str());
- elm_object_style_set(m_content, "popup/default");
- elm_label_line_wrap_set(m_content, ELM_WRAP_MIXED);
- evas_object_size_hint_weight_set(m_content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(m_content, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_part_content_set(m_layout, "elm.swallow.content", m_content);
-
- // buttons
- m_denyButton = elm_button_add(m_popup);
- if (!m_denyButton) {
- ALOGE("EFL : Failed to add deny button");
- throw Exception("Enlightement failed");
- }
- elm_object_part_content_set(m_popup, "button1", m_denyButton);
- elm_object_text_set(m_denyButton, Po::getDenyButtonMsg().c_str());
-
- m_allowButton = elm_button_add(m_popup);
- if (!m_allowButton) {
- ALOGE("EFL : Failed to add allow button");
- throw Exception("Enlightement failed");
- }
- elm_object_part_content_set(m_popup, "button2", m_allowButton);
- elm_object_text_set(m_allowButton, Po::getAllowButtonMsg().c_str());
- elm_object_content_set(m_popup, m_layout);
- evas_object_show(m_popup);
- }
-private:
- Evas_Object *m_content = nullptr;
- Evas_Object *m_layout = nullptr;
- Evas_Object *m_layoutInner = nullptr;
-};
-
-} /* namespace Notification */
-} /* namespace Askuser */
-
+++ /dev/null
-/*
- * 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/agent/notification-daemon/ui/PopupLaunchWearable.h
- * @author Zofia Abramowska <z.abramowska@samsung.com>
- * @brief Declaration of PopupLaunchWearableper class
- */
-
-#pragma once
-
-#include <Elementary.h>
-
-#include <exception/Exception.h>
-#include "Po.h"
-#include "Popup.h"
-
-namespace AskUser {
-namespace Notification {
-
-class PopupLaunchWearable : public Popup {
-public:
- PopupLaunchWearable(Evas_Object *parent, int popupId, const std::string msg)
- : Popup(parent, msg)
- {
- setId(popupId);
- }
- virtual ~PopupLaunchWearable() {}
-
- virtual void create() {
- Evas_Object *icon;
- elm_object_style_set(m_popup, "circle");
-
- m_layout = elm_layout_add(m_popup);
- if (m_layout == nullptr) {
- ALOGE("EFL : Failed to add layout");
- throw Exception("Enlightenment failed");
- }
- elm_layout_theme_set(m_layout, "layout", "popup", "content/circle/buttons2");
- elm_object_part_text_set(m_layout, "elm.text.title", Po::getPopupTitleMsg().c_str());
- elm_object_content_set(m_popup, m_layout);
-
- m_layoutInner = elm_layout_add(m_layout);
- if (m_layoutInner == nullptr) {
- ALOGE("EFL : Failed to add layout");
- throw Exception("Enlightenment failed");
- }
- elm_layout_file_set(m_layoutInner, RES_DIR"/popup_custom.edj", "popup_checkview_internal");
- evas_object_size_hint_weight_set(m_layoutInner, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_part_content_set(m_layout, "elm.swallow.content", m_layoutInner);
-
- m_content = elm_label_add(m_layoutInner);
- if (m_content == nullptr) {
- ALOGE("EFL : Failed to add content");
- throw Exception("Enlightenment failed");
- }
- elm_object_text_set(m_content, m_msg.c_str());
- elm_object_style_set(m_content, "popup/default");
- elm_label_line_wrap_set(m_content, ELM_WRAP_MIXED);
- evas_object_size_hint_weight_set(m_content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(m_content, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_part_content_set(m_layoutInner, "label", m_content);
-
- m_allowButton = elm_button_add(m_popup);
- if (m_allowButton == nullptr) {
- ALOGE("EFL : Failed to add allow button");
- throw Exception("Enlightenment failed");
- }
- elm_object_style_set(m_allowButton, "popup/circle/right");
- elm_object_part_content_set(m_popup, "button2", m_allowButton);
-
- icon = elm_image_add(m_allowButton);
- if (icon == nullptr) {
- ALOGE("EFL : Failed to add allow button icon");
- throw Exception("Enlightenment failed");
- }
- elm_image_file_set(icon, RES_DIR"/tw_ic_popup_btn_check.png", NULL);
- evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_part_content_set(m_allowButton, "elm.swallow.content", icon);
- evas_object_show(icon);
-
- m_denyButton = elm_button_add(m_popup);
- if (m_denyButton == nullptr) {
- ALOGE("EFL : Failed to add deny button");
- throw Exception("Enlightenment failed");
- }
- elm_object_style_set(m_denyButton, "popup/circle/left");
- elm_object_part_content_set(m_popup, "button1", m_denyButton);
-
- icon = elm_image_add(m_denyButton);
- if (icon == nullptr) {
- ALOGE("EFL : Failed to add deny button icon");
- throw Exception("Enlightenment failed");
- }
- elm_image_file_set(icon, RES_DIR"/tw_ic_popup_btn_delete.png", NULL);
- elm_object_part_content_set(m_denyButton, "elm.swallow.content", icon);
- evas_object_show(icon);
-
- evas_object_show(m_popup);
- }
-private:
- std::vector<std::string> m_privs;
- Evas_Object *m_content = nullptr;
- Evas_Object *m_layout = nullptr;
- Evas_Object *m_layoutInner = nullptr;
-};
-
-} /* namespace Notification */
-} /* namespace Askuser */
-
#include "Answerable.h"
#include "Po.h"
-#include "PopupLaunchMobile.h"
-#include "PopupLaunchWearable.h"
#include "PopupCheckMobile.h"
#include "PopupCheckWearable.h"
-#include "Toast.h"
#include <exception/ErrnoException.h>
#include <exception/Exception.h>
m_popupResponseHandler = handler;
}
-void Popupper::registerToastFinishedHandler(ToastHandler handler) {
- m_toastFinishedHandler = handler;
-}
-
void Popupper::unfocusedCb(void *data, Evas_Object *, void *)
{
ALOGD("Unfocused");
return EINA_TRUE;
}
-void Popupper::timeoutToastCb(void *data, Evas_Object *, void *) {
- Popupper *popupper = static_cast<Popupper*>(data);
- popupper->m_toastFinishedHandler(popupper->m_elementPtr->getId());
-}
-
Popupper::~Popupper()
{}
show();
}
-void Popupper::popupLaunch(int popupId, const std::string &appId, const std::string &pkgId, const std::vector<std::string> &privs) {
- std::string profileName = getProfileName();
- Popup *popup;
- try {
- if (profileName[0] != 'w' && profileName[0] != 'W') {
- // Not wearable
- popup = new PopupLaunchMobile(m_win, popupId, Po::createPopupLaunchMsg(appId, pkgId, privs));
- } else {
- // Wearable
- popup = new PopupLaunchWearable(m_win, popupId, Po::createPopupLaunchMsg(appId, pkgId, privs));
- }
- popup->create();
- } catch (const std::exception &e) {
- ALOGE("Failed to create popup launch : " << e.what());
- m_popupResponseHandler(popupId, NResponseType::Error);
- return;
- }
-
- m_answerablePtr.reset(new AnswerablePopupLaunch(popup, m_popupResponseHandler));
- evas_object_smart_callback_add(popup->getAllowButton(), "clicked", &Popupper::allowPressedCb,
- m_answerablePtr.get());
- evas_object_smart_callback_add(popup->getDenyButton(), "clicked", &Popupper::denyPressedCb,
- m_answerablePtr.get());
-
- m_elementPtr.reset(popup);
- show();
-}
-void Popupper::toastDeny(int toastId, const std::string &appId, const std::string &pkgId, const std::string &priv) {
- try {
- Toast *toast = new Toast(m_win, toastId, Po::createToastDenyMsg(appId, pkgId, priv));
- toast->create();
- m_elementPtr.reset(toast);
- } catch (const std::exception &e) {
- ALOGE("Failed to create toast deny : " << e.what());
- return;
- }
- m_toastFinishedHandler(toastId);
-}
-void Popupper::toastFail(int toastId, const std::string &appId, const std::string &pkgId) {
- try {
- Toast *toast = new Toast(m_win, toastId, Po::createToastFailMsg(appId, pkgId));
- toast->create();
- m_elementPtr.reset(toast);
- } catch (const std::exception &e) {
- ALOGE("Failed to create toast fail : " << e.what());
- return;
- }
- m_toastFinishedHandler(toastId);
-}
void Popupper::start()
{
#include "Answerable.h"
#include "Popup.h"
-#include "Toast.h"
#include <types/NotificationResponse.h>
#include <log/alog.h>
class Popupper {
public:
typedef std::function<void(int, NResponseType)> PopupHandler;
- typedef std::function<void(int)> ToastHandler;
Popupper() = default;
void initialize();
void setLocale();
void registerPopupResponseHandler(PopupHandler handler);
- void registerToastFinishedHandler(ToastHandler handler);
void start();
void popupCheck(int popupId, const std::string &appId, const std::string &pkgId, const std::string &priv);
- void popupLaunch(int popupId, const std::string &appId, const std::string &pkgId, const std::vector<std::string> &privs);
- void toastDeny(int toastId, const std::string &appId, const std::string &pkgId, const std::string &priv);
- void toastFail(int toastId, const std::string &appId, const std::string &pkgId);
void popupClose(int popupId);
void stop();
static void unfocusedCb(void *data, Evas_Object *, void *);
static void allowPressedCb(void *data, Evas_Object *, void *);
static void denyPressedCb(void *data, Evas_Object *, void *);
- static void timeoutToastCb(void *data, Evas_Object *, void *);
static Eina_Bool hwKeyClickedCb(void *data, int type, void *event);
void show();
PopupHandler m_popupResponseHandler;
- ToastHandler m_toastFinishedHandler;
Evas_Object *m_win = nullptr;
std::unique_ptr<UIElement> m_elementPtr;
+++ /dev/null
-/*
- * 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/agent/notification-daemon/ui/Toast.h
- * @author Zofia Abramowska <z.abramowska@samsung.com>
- * @brief Declaration of Toast class
- */
-
-#pragma once
-
-#include <exception>
-#include <string>
-
-#include <notification_status.h>
-#include <notification_error.h>
-
-#include <log/alog.h>
-#include "UIElement.h"
-
-namespace AskUser {
-namespace Notification {
-
-class Toast : public UIElement {
-public:
- Toast(Evas_Object *m_parentWindow, int toastId, const std::string msg) : UIElement(m_parentWindow), m_msg(msg)
- {
- setId(toastId);
- }
- virtual void create() {
- int ret = notification_status_message_post(m_msg.c_str());
- if (ret != NOTIFICATION_ERROR_NONE) {
- ALOGE("notification_status_message_post failed with " << ret);
- throw std::runtime_error("notification_status_message_post failed with " + std::to_string(ret));
- }
- }
-private:
- std::string m_msg;
-};
-
-} /* namespace Notification */
-} /* namespace Askuser */
-
${PLUGIN_PATH}/service/ServicePlugin.cpp
)
-SET(CLIENT_PLUGIN_SOURCES
- ${PLUGIN_PATH}/client/ClientPlugin.cpp
- )
-
ADD_DEFINITIONS("-fvisibility=default")
ADD_LIBRARY(${TARGET_PLUGIN_SERVICE} SHARED ${SERVICE_PLUGIN_SOURCES})
-ADD_LIBRARY(${TARGET_PLUGIN_CLIENT} SHARED ${CLIENT_PLUGIN_SOURCES})
TARGET_LINK_LIBRARIES(${TARGET_PLUGIN_SERVICE}
${TARGET_ASKUSER_COMMON}
${TARGET_ASKUSER_COMMON_DEPS}
)
-TARGET_LINK_LIBRARIES(${TARGET_PLUGIN_CLIENT}
- ${TARGET_ASKUSER_COMMON}
- ${TARGET_ASKUSER_COMMON_DEPS}
- )
INSTALL(TARGETS ${TARGET_PLUGIN_SERVICE}
DESTINATION ${LIB_INSTALL_DIR}/cynara/plugin/service/)
-INSTALL(TARGETS ${TARGET_PLUGIN_CLIENT}
- DESTINATION ${LIB_INSTALL_DIR}/cynara/plugin/client/)
-
-########################## PRIVACY DENIED PLUGINS ##############################
-
-PKG_CHECK_MODULES(PDP_DEP
- REQUIRED
- cynara-plugin
- security-manager
- askuser-notification
- )
-
-INCLUDE_DIRECTORIES(
- ${ASKUSER_PATH}/common/config
- SYSTEM
- ${PDP_DEP_INCLUDE_DIRS}
- )
-
-SET(PDP_CLIENT_SOURCES
- ${PLUGIN_PATH}/client/PrivacyPlugin.cpp
- )
-
-SET(PDP_SERVICE_SOURCES
- ${PLUGIN_PATH}/service/PrivacyPlugin.cpp
- )
-
-LINK_DIRECTORIES(${PDP_DEP_LIBRARY_DIRS})
-
-ADD_LIBRARY(${TARGET_PRIVACYDENIED_PLUGIN_SERVICE} SHARED ${PDP_SERVICE_SOURCES})
-ADD_LIBRARY(${TARGET_PRIVACYDENIED_PLUGIN_CLIENT} SHARED ${PDP_CLIENT_SOURCES})
-
-TARGET_LINK_LIBRARIES(${TARGET_PRIVACYDENIED_PLUGIN_SERVICE} ${PDP_DEP_LIBRARIES})
-TARGET_LINK_LIBRARIES(${TARGET_PRIVACYDENIED_PLUGIN_CLIENT} ${PDP_DEP_LIBRARIES})
-
-INSTALL(TARGETS ${TARGET_PRIVACYDENIED_PLUGIN_SERVICE}
- DESTINATION ${LIB_INSTALL_DIR}/cynara/plugin/service/)
-INSTALL(TARGETS ${TARGET_PRIVACYDENIED_PLUGIN_CLIENT}
- DESTINATION ${LIB_INSTALL_DIR}/cynara/plugin/client/)
+++ /dev/null
-/*
- * Copyright (c) 2014-2015 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 ClientPlugin.cpp
- * @author Zofia Abramowska <z.abramowska@samsung.com>
- * @brief Implementation of cynara client side AskUser plugin.
- */
-
-#include <cynara-client-plugin.h>
-#include <cynara-error.h>
-#include <vector>
-
-#include <attributes/attributes.h>
-#include <log/log.h>
-#include <types/PolicyDescription.h>
-#include <types/SupportedTypes.h>
-
-using namespace Cynara;
-
-namespace AskUser {
-const std::vector<PolicyDescription> clientDescriptions = {
- { SupportedTypes::Client::ALLOW_ONCE, "Allow once" },
- { SupportedTypes::Client::ALLOW_PER_SESSION, "Allow per session" },
-
- { SupportedTypes::Client::DENY_ONCE, "Deny once" },
- { SupportedTypes::Client::DENY_PER_SESSION, "Deny per session" }
-};
-
-class ClientPlugin : public ClientPluginInterface {
-public:
- const std::vector<PolicyDescription> &getSupportedPolicyDescr() {
- return clientDescriptions;
- }
-
- bool isCacheable(const ClientSession &session UNUSED, const PolicyResult &result) {
- return (result.policyType() == SupportedTypes::Client::ALLOW_PER_SESSION
- || result.policyType() == SupportedTypes::Client::DENY_PER_SESSION);
- }
-
- bool isUsable(const ClientSession &session,
- const ClientSession &prevSession,
- bool &updateSession,
- PolicyResult &result)
- {
- updateSession = false;
-
- switch (result.policyType()) {
- case SupportedTypes::Client::ALLOW_PER_SESSION:
- case SupportedTypes::Client::DENY_PER_SESSION:
- if (session == prevSession) {
- return true;
- }
- LOGD("Previous session <" << prevSession << "> does not match current session <"
- << session << ">");
- return false;
- default:
- return false;
- }
- }
-
- void invalidate() {}
-
- virtual int toResult(const ClientSession &session UNUSED, PolicyResult &result) {
- switch (result.policyType()) {
- case SupportedTypes::Client::ALLOW_ONCE:
- case SupportedTypes::Client::ALLOW_PER_SESSION:
- return CYNARA_API_ACCESS_ALLOWED;
- default:
- return CYNARA_API_ACCESS_DENIED;
- }
- }
-};
-
-} // namespace AskUser
-
-extern "C" {
-ExternalPluginInterface *create(void) {
- return new AskUser::ClientPlugin();
-}
-
-void destroy(ExternalPluginInterface *ptr) {
- delete ptr;
-}
-} // extern "C"
+++ /dev/null
-/*
- * 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 PrivacyPlugin.cpp
- * @author
- * @brief Implementation of cynara client side PrivacyDenied plugin.
- */
-
-#include <vector>
-#include <cynara-client-plugin.h>
-#include <cynara-error.h>
-
-#include <attributes/attributes.h>
-#include <PrivacyConfig.h>
-
-using namespace Cynara;
-
-namespace PrivacyDeniedPlugin {
-const std::vector<PolicyDescription> clientDescriptions = {
- { Config::ASK_USER_LEGACY, "ASK_USER_LEGACY" },
- { Config::PRIVACY_DENY, "PRIVACY_DENY" }
-};
-
-class ClientPlugin : public ClientPluginInterface {
-public:
- const std::vector<PolicyDescription> &getSupportedPolicyDescr() {
- return clientDescriptions;
- }
-
- bool isCacheable(const ClientSession &session UNUSED, const PolicyResult &result UNUSED) {
- return true;
- }
-
- bool isUsable(const ClientSession &session,
- const ClientSession &prevSession,
- bool &updateSession,
- PolicyResult &result UNUSED)
- {
- updateSession = false;
- return (session.compare(prevSession) == 0);
- }
-
- void invalidate() {}
-
- int toResult(const ClientSession &session UNUSED, PolicyResult &result UNUSED) {
- return CYNARA_API_ACCESS_DENIED;
- }
-};
-
-} // namespace PrivacyDeniedPlugin
-
-extern "C" {
-
-ExternalPluginInterface *create(void) {
- return new PrivacyDeniedPlugin::ClientPlugin();
-}
-
-void destroy(ExternalPluginInterface *ptr) {
- delete ptr;
-}
-
-} // extern "C"
+++ /dev/null
-/*
- * 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 PrivacyPlugin.cpp
- * @author
- * @brief Implementation of cynara service side PrivacyDenied plugin.
- */
-
-#include <memory>
-#include <string>
-#include <vector>
-#include <cynara-plugin.h>
-
-#include <app-runtime.h>
-#include <attributes/attributes.h>
-#include <PrivacyConfig.h>
-#include <askuser-notification/ask-user-client.h>
-
-using namespace Cynara;
-
-namespace PrivacyDeniedPlugin {
-
-const std::vector<PolicyDescription> serviceDescriptions = {
- { Config::ASK_USER_LEGACY, "ASK_USER_LEGACY" },
- { Config::PRIVACY_DENY, "PRIVACY_DENY" }
-};
-
-class ServicePlugin : public ServicePluginInterface {
-public:
- ServicePlugin() {}
-
- const std::vector<PolicyDescription> &getSupportedPolicyDescr() {
- return serviceDescriptions;
- }
-
- PluginStatus check(const std::string &client,
- const std::string &user,
- const std::string &privilege,
- PolicyResult &result UNUSED,
- AgentType &requiredAgent UNUSED,
- PluginData &pluginData UNUSED) noexcept
- {
- toast(client, user, privilege);
- return PluginStatus::ANSWER_READY;
- }
-
- PluginStatus update(const std::string &client UNUSED,
- const std::string &user UNUSED,
- const std::string &privilege UNUSED,
- const PluginData &agentData UNUSED,
- PolicyResult &result UNUSED) noexcept
- {
- // This function should be never called
- return PluginStatus::ERROR;
- }
-
- void invalidate() {}
-
-private:
- void toast(const std::string &client, const std::string &user, const std::string &privilege) {
- char *pkgName = nullptr, *appName = nullptr;
- int ret = security_manager_identify_app_from_cynara_client(client.c_str(), &pkgName, &appName);
- if (ret != SECURITY_MANAGER_SUCCESS || pkgName == nullptr)
- return;
-
- std::unique_ptr<char, decltype(free)*> pkgNamePtr(pkgName, free);
- std::unique_ptr<char, decltype(free)*> appNamePtr(appName, free);
- AskUser::Protocol::toast_deny(pkgName, (appName ? appName : ""), std::stoi(user), privilege);
- }
-};
-
-} // namespace PrivacyDeniedPlugin
-
-extern "C" {
-ExternalPluginInterface *create(void) {
- return new PrivacyDeniedPlugin::ServicePlugin();
-}
-
-void destroy(ExternalPluginInterface *ptr) {
- delete ptr;
-}
-} // extern "C"