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::object<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::bus& 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 /** @brief lists user privilege 75 * 76 */ 77 std::string userPrivilege(void) const override; 78 79 /** @brief update user groups 80 * 81 * @param[in] value - User groups 82 */ 83 std::vector<std::string> 84 userGroups(std::vector<std::string> value) override; 85 86 /** @brief list user groups 87 * 88 */ 89 std::vector<std::string> userGroups(void) const override; 90 91 /** @brief lists user enabled state 92 * 93 */ 94 bool userEnabled(void) const override; 95 96 /** @brief update user enabled state 97 * 98 * @param[in] value - bool value 99 */ 100 bool userEnabled(bool value) override; 101 102 /** @brief lists user locked state for failed attempt 103 * 104 **/ 105 bool userLockedForFailedAttempt(void) const override; 106 107 /** @brief unlock user locked state for failed attempt 108 * 109 * @param[in]: value - false - unlock user account, true - no action taken 110 **/ 111 bool userLockedForFailedAttempt(bool value) override; 112 113 /** @brief indicates if the user's password is expired 114 * 115 **/ 116 bool userPasswordExpired(void) const; 117 118 private: 119 std::string userName; 120 UserMgr& manager; 121 }; 122 123 } // namespace user 124 } // namespace phosphor 125