Add datacontrol.consumer privilege to DataControl
[platform/framework/native/appfw.git] / src / app / FAppMapDataControl.cpp
index 0a6e942..82035d5 100644 (file)
 #include <FBase_NativeError.h>
 
 #include "FApp_MapDataControlImpl.h"
+#include <FSec_AccessController.h>
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::App;
+using namespace Tizen::Security;
 
 namespace Tizen { namespace App {
 
@@ -47,6 +49,9 @@ result
 MapDataControl::GetValue(const String& dataId, const String& key,
                RequestId& reqId, int pageNo, int countPerPage)
 {
+       result r = _AccessController::CheckUserPrivilege(_PRV_DATACONTROL_CONSUMER);
+       SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
        SysTryReturnResult(NID_APP, __pMapDataControlImpl, E_INVALID_STATE,
                        "This instance has not been properly constructed yet.");
 
@@ -57,6 +62,9 @@ result
 MapDataControl::AddValue(const String& dataId, const String& key,
                const String& value, RequestId& reqId)
 {
+       result r = _AccessController::CheckUserPrivilege(_PRV_DATACONTROL_CONSUMER);
+       SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
        SysTryReturnResult(NID_APP, __pMapDataControlImpl, E_INVALID_STATE,
                        "This instance has not been properly constructed yet.");
 
@@ -67,6 +75,9 @@ result
 MapDataControl::SetValue(const String& dataId, const String& key,
                const String& oldValue, const String& newValue, RequestId& reqId)
 {
+       result r = _AccessController::CheckUserPrivilege(_PRV_DATACONTROL_CONSUMER);
+       SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
        SysTryReturnResult(NID_APP, __pMapDataControlImpl, E_INVALID_STATE,
                        "This instance has not been properly constructed yet.");
 
@@ -77,6 +88,9 @@ result
 MapDataControl::RemoveValue(const String& dataId, const String& key,
                const String& value, RequestId& reqId)
 {
+       result r = _AccessController::CheckUserPrivilege(_PRV_DATACONTROL_CONSUMER);
+       SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
        SysTryReturnResult(NID_APP, __pMapDataControlImpl, E_INVALID_STATE,
                        "This instance has not been properly constructed yet.");