]> git.stg.codes - stg.git/commitdiff
Added XML RPC method for getting user's authorizers.
authorMaxim Mamontov <faust.madf@gmail.com>
Fri, 26 Jul 2013 18:22:09 +0000 (21:22 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Fri, 26 Jul 2013 18:22:09 +0000 (21:22 +0300)
projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp
projects/stargazer/plugins/configuration/rpcconfig/users_methods.cpp
projects/stargazer/plugins/configuration/rpcconfig/users_methods.h

index e84e9a0e1af96c8e9a23acbcef97716e977bbe27..dca87fbee34ce8a65eb0bc85997c6e57b54ec6cc 100644 (file)
@@ -473,5 +473,11 @@ xmlrpc_c::methodPtr const methodGetOnlinIPsPtr(new METHOD_GET_ONLINE_IPS(
             users
             ));
 rpcRegistry.addMethod("stargazer.get_online_ips", methodGetOnlinIPsPtr);
             users
             ));
 rpcRegistry.addMethod("stargazer.get_online_ips", methodGetOnlinIPsPtr);
+
+xmlrpc_c::methodPtr const methodGetUserAuthByPtr(new METHOD_GET_USER_AUTH_BY(
+            this,
+            users
+            ));
+rpcRegistry.addMethod("stargazer.get_user_auth_by", methodGetUserAuthByPtr);
 }
 
 }
 
index 9eabced670e8f111fd1089d27877d6b5d4c6ef23..5adbf44131905750cfa52fefbf1398b0842b2dd0 100644 (file)
@@ -509,3 +509,36 @@ ipm.mask = htonl(0xffFFffFF << (32 - ipm.mask));
 
 return false;
 }
 
 return false;
 }
+
+void METHOD_GET_USER_AUTH_BY::execute(xmlrpc_c::paramList const & paramList,
+                                      xmlrpc_c::value *   const   retvalPtr)
+{
+std::string cookie = paramList.getString(0);
+std::string login = paramList.getString(1);
+paramList.verifyEnd(2);
+
+std::map<std::string, xmlrpc_c::value> structVal;
+ADMIN_INFO adminInfo;
+
+if (config->GetAdminInfo(cookie, &adminInfo))
+    {
+    structVal["result"] = xmlrpc_c::value_boolean(false);
+    *retvalPtr = xmlrpc_c::value_struct(structVal);
+    return;
+    }
+
+USER_PTR u;
+
+if (users->FindByName(login, &u))
+    {
+    structVal["result"] = xmlrpc_c::value_boolean(false);
+    *retvalPtr = xmlrpc_c::value_struct(structVal);
+    return;
+    }
+
+std::vector<std::string> list(u->GetAuthorizers());
+std::vector<xmlrpc_c::value> authList;
+for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it)
+    authList.push_back(xmlrpc_c::value_string(*it));
+*retvalPtr = xmlrpc_c::value_array(authList);
+}
index 413e9aaf8b418578f374a056383207489dcdc4a1..d1ec33a4ade340f07e1612e1b9641de38417db8d 100644 (file)
@@ -229,4 +229,24 @@ private:
     bool ParseNet(const std::string & net, IP_MASK & ipm) const;
 };
 
     bool ParseNet(const std::string & net, IP_MASK & ipm) const;
 };
 
+class METHOD_GET_USER_AUTH_BY : public xmlrpc_c::method {
+public:
+    METHOD_GET_USER_AUTH_BY(RPC_CONFIG * c,
+                            USERS * u)
+        : config(c),
+          users(u)
+    {
+    }
+
+    void execute(xmlrpc_c::paramList const & paramList,
+                 xmlrpc_c::value *   const   retvalP);
+
+private:
+    METHOD_GET_USER_AUTH_BY(const METHOD_GET_ONLINE_IPS & rvalue);
+    METHOD_GET_USER_AUTH_BY & operator=(const METHOD_GET_ONLINE_IPS & rvalue);
+
+    RPC_CONFIG * config;
+    USERS * users;
+};
+
 #endif
 #endif