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 <sdbusplus/bus.hpp> 18 #include <sdbusplus/server/object.hpp> 19 #include <xyz/openbmc_project/Object/Delete/server.hpp> 20 #include <xyz/openbmc_project/User/Attributes/server.hpp> 21 22 namespace phosphor 23 { 24 namespace user 25 { 26 27 namespace Base = sdbusplus::xyz::openbmc_project; 28 using UsersIface = Base::User::server::Attributes; 29 using DeleteIface = Base::Object::server::Delete; 30 using Interfaces = sdbusplus::server::object_t<UsersIface, DeleteIface>; 31 // Place where all user objects has to be created 32 constexpr auto usersObjPath = "/xyz/openbmc_project/user"; 33 34 class UserMgr; // Forward declaration for UserMgr. 35 36 /** @class Users 37 * @brief Lists User objects and it's properties 38 */ 39 class Users : public Interfaces 40 { 41 public: 42 Users() = delete; 43 ~Users() = default; 44 Users(const Users&) = delete; 45 Users& operator=(const Users&) = delete; 46 Users(Users&&) = delete; 47 Users& operator=(Users&&) = delete; 48 49 /** @brief Constructs UserMgr object. 50 * 51 * @param[in] bus - sdbusplus handler 52 * @param[in] path - D-Bus path 53 * @param[in] groups - users group list 54 * @param[in] priv - users privilege 55 * @param[in] enabled - user enabled state 56 * @param[in] parent - user manager - parent object 57 */ 58 Users(sdbusplus::bus_t& bus, const char* path, 59 std::vector<std::string> groups, std::string priv, bool enabled, 60 UserMgr& parent); 61 62 /** @brief delete user method. 63 * This method deletes the user as requested 64 * 65 */ 66 void delete_(void) override; 67 68 /** @brief update user privilege 69 * 70 * @param[in] value - User privilege 71 */ 72 std::string userPrivilege(std::string value) override; 73 74 void setUserPrivilege(const std::string& value); 75 76 void setUserGroups(const std::vector<std::string>& groups); 77 78 /** @brief lists user privilege 79 * 80 */ 81 std::string userPrivilege(void) const override; 82 83 /** @brief update user groups 84 * 85 * @param[in] value - User groups 86 */ 87 std::vector<std::string> 88 userGroups(std::vector<std::string> value) override; 89 90 /** @brief list user groups 91 * 92 */ 93 std::vector<std::string> userGroups(void) const override; 94 95 /** @brief lists user enabled state 96 * 97 */ 98 bool userEnabled(void) const override; 99 100 void setUserEnabled(bool value); 101 102 /** @brief update user enabled state 103 * 104 * @param[in] value - bool value 105 */ 106 bool userEnabled(bool value) override; 107 108 /** @brief lists user locked state for failed attempt 109 * 110 **/ 111 bool userLockedForFailedAttempt(void) const override; 112 113 /** @brief unlock user locked state for failed attempt 114 * 115 * @param[in]: value - false - unlock user account, true - no action taken 116 **/ 117 bool userLockedForFailedAttempt(bool value) override; 118 119 /** @brief indicates if the user's password is expired 120 * 121 **/ 122 bool userPasswordExpired(void) const override; 123 124 private: 125 std::string userName; 126 UserMgr& manager; 127 }; 128 129 } // namespace user 130 } // namespace phosphor 131