From: Mu-Woong Lee Date: Mon, 13 Mar 2017 13:41:39 +0000 (+0900) Subject: Add ClientBase::hasPrivileges() to check multiple privileges at once X-Git-Tag: accepted/tizen/unified/20170414.163458^2~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3303a65906069a42c6562e6b0df2e4e675bce7f2;p=platform%2Fcore%2Fcontext%2Fcontext-common.git Add ClientBase::hasPrivileges() to check multiple privileges at once Change-Id: Ib3566b86f491c389285eaffd9e8f863a95e28b90 Signed-off-by: Mu-Woong Lee --- diff --git a/include/ClientBase.h b/include/ClientBase.h index d6997d3..b7796bb 100644 --- a/include/ClientBase.h +++ b/include/ClientBase.h @@ -17,6 +17,7 @@ #ifndef __CONTEXT_CLIENT_BASE_H__ #define __CONTEXT_CLIENT_BASE_H__ +#include #include #include @@ -46,6 +47,8 @@ namespace ctx { bool hasPrivilege(const char* privil) const; + bool hasPrivileges(const std::vector& privil) const; + uid_t getUid() const; std::string getClientId() const; diff --git a/src/server/ClientBase.cpp b/src/server/ClientBase.cpp index 3b2d8a3..240f6ae 100644 --- a/src/server/ClientBase.cpp +++ b/src/server/ClientBase.cpp @@ -70,6 +70,15 @@ bool ClientBase::hasPrivilege(const char* privil) const return __credential->hasPrivilege(privil); } +bool ClientBase::hasPrivileges(const std::vector& privil) const +{ + for (auto& item : privil) { + if (!hasPrivilege(item.c_str())) + return false; + } + return true; +} + uid_t ClientBase::getUid() const { return __credential->getUid();