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 |
Richard Marian Thomaiyar | 9f630d9 | 2018-05-24 10:49:10 +0530 | [diff] [blame] | 17 | #include <sdbusplus/bus.hpp> |
| 18 | #include <sdbusplus/server/object.hpp> |
Richard Marian Thomaiyar | 9f630d9 | 2018-05-24 10:49:10 +0530 | [diff] [blame] | 19 | #include <xyz/openbmc_project/Object/Delete/server.hpp> |
Patrick Williams | 9638afb | 2021-02-22 17:16:24 -0600 | [diff] [blame] | 20 | #include <xyz/openbmc_project/User/Attributes/server.hpp> |
Richard Marian Thomaiyar | 9f630d9 | 2018-05-24 10:49:10 +0530 | [diff] [blame] | 21 | |
| 22 | namespace phosphor |
| 23 | { |
| 24 | namespace user |
| 25 | { |
| 26 | |
| 27 | namespace Base = sdbusplus::xyz::openbmc_project; |
Ratan Gupta | 1af1223 | 2018-11-03 00:35:38 +0530 | [diff] [blame] | 28 | using UsersIface = Base::User::server::Attributes; |
| 29 | using DeleteIface = Base::Object::server::Delete; |
Patrick Williams | b3ef4e1 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 30 | using Interfaces = sdbusplus::server::object_t<UsersIface, DeleteIface>; |
Richard Marian Thomaiyar | 9f630d9 | 2018-05-24 10:49:10 +0530 | [diff] [blame] | 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 | */ |
Ratan Gupta | 1af1223 | 2018-11-03 00:35:38 +0530 | [diff] [blame] | 39 | class Users : public Interfaces |
Richard Marian Thomaiyar | 9f630d9 | 2018-05-24 10:49:10 +0530 | [diff] [blame] | 40 | { |
| 41 | public: |
| 42 | Users() = delete; |
| 43 | ~Users() = default; |
Patrick Williams | 9638afb | 2021-02-22 17:16:24 -0600 | [diff] [blame] | 44 | Users(const Users&) = delete; |
| 45 | Users& operator=(const Users&) = delete; |
| 46 | Users(Users&&) = delete; |
| 47 | Users& operator=(Users&&) = delete; |
Richard Marian Thomaiyar | 9f630d9 | 2018-05-24 10:49:10 +0530 | [diff] [blame] | 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 | */ |
Patrick Williams | b3ef4e1 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 58 | Users(sdbusplus::bus_t& bus, const char* path, |
Richard Marian Thomaiyar | 9f630d9 | 2018-05-24 10:49:10 +0530 | [diff] [blame] | 59 | std::vector<std::string> groups, std::string priv, bool enabled, |
Patrick Williams | 9638afb | 2021-02-22 17:16:24 -0600 | [diff] [blame] | 60 | UserMgr& parent); |
Richard Marian Thomaiyar | 9f630d9 | 2018-05-24 10:49:10 +0530 | [diff] [blame] | 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 | |
Nan Zhou | fef6303 | 2022-10-25 00:07:12 +0000 | [diff] [blame] | 74 | void setUserPrivilege(const std::string& value); |
| 75 | |
| 76 | void setUserGroups(const std::vector<std::string>& groups); |
| 77 | |
Richard Marian Thomaiyar | 9f630d9 | 2018-05-24 10:49:10 +0530 | [diff] [blame] | 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 | |
Nan Zhou | 6b6f2d8 | 2022-10-25 00:07:17 +0000 | [diff] [blame] | 100 | void setUserEnabled(bool value); |
| 101 | |
Richard Marian Thomaiyar | 9f630d9 | 2018-05-24 10:49:10 +0530 | [diff] [blame] | 102 | /** @brief update user enabled state |
| 103 | * |
| 104 | * @param[in] value - bool value |
| 105 | */ |
| 106 | bool userEnabled(bool value) override; |
| 107 | |
Richard Marian Thomaiyar | c704519 | 2018-06-13 16:51:00 +0530 | [diff] [blame] | 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 | |
Joseph Reynolds | 3ab6cc2 | 2020-03-03 14:09:03 -0600 | [diff] [blame] | 119 | /** @brief indicates if the user's password is expired |
| 120 | * |
| 121 | **/ |
Nan Zhou | f3fb77c | 2022-08-29 17:51:59 +0000 | [diff] [blame] | 122 | bool userPasswordExpired(void) const override; |
Joseph Reynolds | 3ab6cc2 | 2020-03-03 14:09:03 -0600 | [diff] [blame] | 123 | |
Richard Marian Thomaiyar | 9f630d9 | 2018-05-24 10:49:10 +0530 | [diff] [blame] | 124 | private: |
| 125 | std::string userName; |
Patrick Williams | 9638afb | 2021-02-22 17:16:24 -0600 | [diff] [blame] | 126 | UserMgr& manager; |
Richard Marian Thomaiyar | 9f630d9 | 2018-05-24 10:49:10 +0530 | [diff] [blame] | 127 | }; |
| 128 | |
| 129 | } // namespace user |
| 130 | } // namespace phosphor |