From: Krzysztof Sasiak Date: Fri, 19 Dec 2014 14:37:33 +0000 (+0100) Subject: Add EmptyBucket convenience method to CynaraAdmin class. X-Git-Tag: submit/tizen_tv/20150216.113520~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f427df45b7516b659248f7148867f6ec842f641d;p=platform%2Fcore%2Fsecurity%2Fsecurity-manager.git Add EmptyBucket convenience method to CynaraAdmin class. Change-Id: Ia050336fb69d669488601a18211775b9136d8070 Signed-off-by: Krzysztof Sasiak --- diff --git a/src/common/cynara.cpp b/src/common/cynara.cpp index c29f426b..4d4ec750 100644 --- a/src/common/cynara.cpp +++ b/src/common/cynara.cpp @@ -198,6 +198,8 @@ static bool checkCynaraError(int result, const std::string &msg) ThrowMsg(CynaraException::InvalidParam, msg); case CYNARA_API_SERVICE_NOT_AVAILABLE: ThrowMsg(CynaraException::ServiceNotAvailable, msg); + case CYNARA_API_BUCKET_NOT_FOUND: + ThrowMsg(CynaraException::BucketNotFound, msg); default: ThrowMsg(CynaraException::UnknownError, msg); } @@ -359,6 +361,16 @@ void CynaraAdmin::ListPolicies( } +void CynaraAdmin::EmptyBucket(const std::string &bucketName, bool recursive, const std::string &client, + const std::string &user, const std::string &privilege) +{ + checkCynaraError( + cynara_admin_erase(m_CynaraAdmin, bucketName.c_str(), static_cast(recursive), + client.c_str(), user.c_str(), privilege.c_str()), + "Error while emptying bucket: " + bucketName + ", filter (C, U, P): " + + client + ", " + user + ", " + privilege); +} + Cynara::Cynara() { checkCynaraError( diff --git a/src/common/include/cynara.h b/src/common/include/cynara.h index 7713f42d..98ce805f 100644 --- a/src/common/include/cynara.h +++ b/src/common/include/cynara.h @@ -55,6 +55,7 @@ public: DECLARE_EXCEPTION_TYPE(Base, InvalidParam) DECLARE_EXCEPTION_TYPE(Base, ServiceNotAvailable) DECLARE_EXCEPTION_TYPE(Base, UnknownError) + DECLARE_EXCEPTION_TYPE(Base, BucketNotFound) }; struct CynaraAdminPolicy : cynara_admin_policy @@ -153,6 +154,19 @@ public: private: CynaraAdmin(); + + /** + * Empty bucket using filter - matching rules will be removed + * + * @param bucketName name of the bucket to be emptied + * @param recursive flag to remove privileges recursively + * @param client client name + * @param user user name + * @param privilege privilege name + */ + void EmptyBucket(const std::string &bucketName, bool recursive, + const std::string &client, const std::string &user, const std::string &privilege); + struct cynara_admin *m_CynaraAdmin; };