Add ClientBase::hasPrivileges() to check multiple privileges at once 79/118679/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 13 Mar 2017 13:41:39 +0000 (22:41 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 13 Mar 2017 13:41:39 +0000 (22:41 +0900)
Change-Id: Ib3566b86f491c389285eaffd9e8f863a95e28b90
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
include/ClientBase.h
src/server/ClientBase.cpp

index d6997d3..b7796bb 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef __CONTEXT_CLIENT_BASE_H__
 #define __CONTEXT_CLIENT_BASE_H__
 
+#include <vector>
 #include <string>
 #include <ContextTypes.h>
 
@@ -46,6 +47,8 @@ namespace ctx {
 
                bool hasPrivilege(const char* privil) const;
 
+               bool hasPrivileges(const std::vector<std::string>& privil) const;
+
                uid_t getUid() const;
 
                std::string getClientId() const;
index 3b2d8a3..240f6ae 100644 (file)
@@ -70,6 +70,15 @@ bool ClientBase::hasPrivilege(const char* privil) const
        return __credential->hasPrivilege(privil);
 }
 
+bool ClientBase::hasPrivileges(const std::vector<std::string>& privil) const
+{
+       for (auto& item : privil) {
+               if (!hasPrivilege(item.c_str()))
+                       return false;
+       }
+       return true;
+}
+
 uid_t ClientBase::getUid() const
 {
        return __credential->getUid();