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