Add datacontrol.consumer privilege to DataControl
[platform/framework/native/appfw.git] / src / app / FAppSqlDataControl.cpp
index a512047..66cb727 100644 (file)
 #include <FBase_NativeError.h>
 
 #include "FApp_SqlDataControlImpl.h"
+#include <FSec_AccessController.h>
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
 
 namespace Tizen { namespace App
 {
@@ -47,6 +49,9 @@ result
 SqlDataControl::Select(const String& dataId, const IList* pColumnList, const String* pWhere,
                const String *pOrder, 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, __pSqlDataControlImpl, E_INVALID_STATE,
                        "This instance has not been properly constructed.");
 
@@ -57,6 +62,9 @@ result
 SqlDataControl::Insert(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& insertMap,
                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, __pSqlDataControlImpl, E_INVALID_STATE,
                        "This instance has not been properly constructed.");
 
@@ -67,6 +75,9 @@ result
 SqlDataControl::Update(const Tizen::Base::String& dataId, const Tizen::Base::Collection::IMap& updateMap,
                        const Tizen::Base::String* pWhere, 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, __pSqlDataControlImpl, E_INVALID_STATE, "This instance has not been properly constructed.");
 
        return __pSqlDataControlImpl->Update(dataId, updateMap, pWhere, reqId);
@@ -75,6 +86,9 @@ SqlDataControl::Update(const Tizen::Base::String& dataId, const Tizen::Base::Col
 result
 SqlDataControl::Delete(const Tizen::Base::String& dataId, const Tizen::Base::String* pWhere, 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, __pSqlDataControlImpl, E_INVALID_STATE,
                        "This instance has not been properly constructed.");