From f8f86d89a437034fcdb26aad928230b7773ab821 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Thu, 9 Jul 2015 15:25:51 +0200 Subject: [PATCH] Add ApiUser::GetByClientCN() refs #9471 refs #9086 --- lib/remote/apiuser.cpp | 11 +++++++++++ lib/remote/apiuser.hpp | 2 ++ lib/remote/apiuser.ti | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/remote/apiuser.cpp b/lib/remote/apiuser.cpp index a9c2957c8..742710012 100644 --- a/lib/remote/apiuser.cpp +++ b/lib/remote/apiuser.cpp @@ -19,6 +19,7 @@ #include "remote/apiuser.hpp" #include "remote/apiuser.tcpp" +#include "base/dynamictype.hpp" using namespace icinga; @@ -38,3 +39,13 @@ bool ApiUser::CheckPassword(const String& password) const { return password == GetPasswordRaw(); } + +ApiUser::Ptr ApiUser::GetByClientCN(const String& cn) +{ + BOOST_FOREACH(const ApiUser::Ptr& user, DynamicType::GetObjectsByType()) { + if (user->GetClientCN() == cn) + return user; + } + + return ApiUser::Ptr(); +} diff --git a/lib/remote/apiuser.hpp b/lib/remote/apiuser.hpp index 41f8a3a0c..2fa2dd6c2 100644 --- a/lib/remote/apiuser.hpp +++ b/lib/remote/apiuser.hpp @@ -38,6 +38,8 @@ public: String GetPassword(void) const; void SetPassword(const String& password); bool CheckPassword(const String& password) const; + + static ApiUser::Ptr GetByClientCN(const String& cn); }; } diff --git a/lib/remote/apiuser.ti b/lib/remote/apiuser.ti index 05471ad29..b7180f5e1 100644 --- a/lib/remote/apiuser.ti +++ b/lib/remote/apiuser.ti @@ -25,7 +25,7 @@ namespace icinga class ApiUser : DynamicObject { [config, protected] String password (PasswordRaw); - [config] String client_cn; + [config] String client_cn (ClientCN); }; } -- 2.40.0