1 /* 2 // Copyright (c) 2018 Intel Corporation 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 */ 16 #pragma once 17 #include <experimental/filesystem> 18 #include <sdbusplus/bus.hpp> 19 #include <sdbusplus/server/object.hpp> 20 #include <xyz/openbmc_project/User/Attributes/server.hpp> 21 #include <xyz/openbmc_project/Object/Delete/server.hpp> 22 23 namespace phosphor 24 { 25 namespace user 26 { 27 28 namespace Base = sdbusplus::xyz::openbmc_project; 29 using UsersIface = Base::User::server::Attributes; 30 using DeleteIface = Base::Object::server::Delete; 31 using Interfaces = sdbusplus::server::object::object<UsersIface, DeleteIface>; 32 // Place where all user objects has to be created 33 constexpr auto usersObjPath = "/xyz/openbmc_project/user"; 34 35 class UserMgr; // Forward declaration for UserMgr. 36 37 /** @class Users 38 * @brief Lists User objects and it's properties 39 */ 40 class Users : public Interfaces 41 { 42 public: 43 Users() = delete; 44 ~Users() = default; 45 Users(const Users &) = delete; 46 Users &operator=(const Users &) = delete; 47 Users(Users &&) = delete; 48 Users &operator=(Users &&) = delete; 49 50 /** @brief Constructs UserMgr object. 51 * 52 * @param[in] bus - sdbusplus handler 53 * @param[in] path - D-Bus path 54 * @param[in] groups - users group list 55 * @param[in] priv - users privilege 56 * @param[in] enabled - user enabled state 57 * @param[in] parent - user manager - parent object 58 */ 59 Users(sdbusplus::bus::bus &bus, const char *path, 60 std::vector<std::string> groups, std::string priv, bool enabled, 61 UserMgr &parent); 62 63 /** @brief delete user method. 64 * This method deletes the user as requested 65 * 66 */ 67 void delete_(void) override; 68 69 /** @brief update user privilege 70 * 71 * @param[in] value - User privilege 72 */ 73 std::string userPrivilege(std::string value) override; 74 75 /** @brief lists user privilege 76 * 77 */ 78 std::string userPrivilege(void) const override; 79 80 /** @brief update user groups 81 * 82 * @param[in] value - User groups 83 */ 84 std::vector<std::string> 85 userGroups(std::vector<std::string> value) override; 86 87 /** @brief list user groups 88 * 89 */ 90 std::vector<std::string> userGroups(void) const override; 91 92 /** @brief lists user enabled state 93 * 94 */ 95 bool userEnabled(void) const override; 96 97 /** @brief update user enabled state 98 * 99 * @param[in] value - bool value 100 */ 101 bool userEnabled(bool value) override; 102 103 /** @brief lists user locked state for failed attempt 104 * 105 **/ 106 bool userLockedForFailedAttempt(void) const override; 107 108 /** @brief unlock user locked state for failed attempt 109 * 110 * @param[in]: value - false - unlock user account, true - no action taken 111 **/ 112 bool userLockedForFailedAttempt(bool value) override; 113 114 private: 115 std::string userName; 116 UserMgr &manager; 117 }; 118 119 } // namespace user 120 } // namespace phosphor 121