blob: 6ff4dfb1ccb2c5eb495f1d360085d4b8e300f447 [file] [log] [blame]
Richard Marian Thomaiyar9f630d92018-05-24 10:49:10 +05301/*
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 Thomaiyar9f630d92018-05-24 10:49:10 +053017#include <sdbusplus/bus.hpp>
18#include <sdbusplus/server/object.hpp>
Richard Marian Thomaiyar9f630d92018-05-24 10:49:10 +053019#include <xyz/openbmc_project/Object/Delete/server.hpp>
Patrick Williams9638afb2021-02-22 17:16:24 -060020#include <xyz/openbmc_project/User/Attributes/server.hpp>
Richard Marian Thomaiyar9f630d92018-05-24 10:49:10 +053021
22namespace phosphor
23{
24namespace user
25{
26
27namespace Base = sdbusplus::xyz::openbmc_project;
Ratan Gupta1af12232018-11-03 00:35:38 +053028using UsersIface = Base::User::server::Attributes;
29using DeleteIface = Base::Object::server::Delete;
30using Interfaces = sdbusplus::server::object::object<UsersIface, DeleteIface>;
Richard Marian Thomaiyar9f630d92018-05-24 10:49:10 +053031// Place where all user objects has to be created
32constexpr auto usersObjPath = "/xyz/openbmc_project/user";
33
34class UserMgr; // Forward declaration for UserMgr.
35
36/** @class Users
37 * @brief Lists User objects and it's properties
38 */
Ratan Gupta1af12232018-11-03 00:35:38 +053039class Users : public Interfaces
Richard Marian Thomaiyar9f630d92018-05-24 10:49:10 +053040{
41 public:
42 Users() = delete;
43 ~Users() = default;
Patrick Williams9638afb2021-02-22 17:16:24 -060044 Users(const Users&) = delete;
45 Users& operator=(const Users&) = delete;
46 Users(Users&&) = delete;
47 Users& operator=(Users&&) = delete;
Richard Marian Thomaiyar9f630d92018-05-24 10:49:10 +053048
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 Williams9638afb2021-02-22 17:16:24 -060058 Users(sdbusplus::bus::bus& bus, const char* path,
Richard Marian Thomaiyar9f630d92018-05-24 10:49:10 +053059 std::vector<std::string> groups, std::string priv, bool enabled,
Patrick Williams9638afb2021-02-22 17:16:24 -060060 UserMgr& parent);
Richard Marian Thomaiyar9f630d92018-05-24 10:49:10 +053061
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
Richard Marian Thomaiyarc7045192018-06-13 16:51:00 +0530102 /** @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
Joseph Reynolds3ab6cc22020-03-03 14:09:03 -0600113 /** @brief indicates if the user's password is expired
114 *
115 **/
116 bool userPasswordExpired(void) const;
117
Richard Marian Thomaiyar9f630d92018-05-24 10:49:10 +0530118 private:
119 std::string userName;
Patrick Williams9638afb2021-02-22 17:16:24 -0600120 UserMgr& manager;
Richard Marian Thomaiyar9f630d92018-05-24 10:49:10 +0530121};
122
123} // namespace user
124} // namespace phosphor