blob: a7aaa508801e5245d3dc84bf4e4328b9aeefecc9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/* -------------------------------------------
Copyright ZKA Technologies
------------------------------------------- */
#ifndef _INC_PERMISSION_SEL_HXX_
#define _INC_PERMISSION_SEL_HXX_
#include <CompilerKit/CompilerKit.hxx>
#include <KernelKit/LPC.hxx>
#include <NewKit/String.hxx>
#include <NewKit/Defines.hxx>
// user mode users.
#define kSuperUser "\\Local\\Super"
#define kGuestUser "\\Local\\Guest"
#define kUsersFile "\\Users\\$UserMTF"
#define kMaxUserNameLen (255)
#define kMaxUserTokenLen (4096)
// hash 'password' -> base64+md5 encoded data
// use this data to then fetch specific data of the user..
namespace Kernel
{
class UserManager;
class User;
enum class RingKind
{
kRingStdUser = 1,
kRingSuperUser = 2,
kRingGuestUser = 5,
kRingCount = 5,
};
class User final
{
public:
explicit User() = delete;
User(const Int32& sel, const Char* userName);
User(const RingKind& kind, const Char* userName);
~User();
public:
NEWOS_COPY_DEFAULT(User)
public:
bool operator==(const User& lhs);
bool operator!=(const User& lhs);
public:
/// @brief Get software ring
const RingKind& Ring() noexcept;
/// @brief Get user name
StringView& Name() noexcept;
/// @brief Is he a standard user?
Bool IsStdUser() noexcept;
/// @brief Is she a super user?
Bool IsSuperUser() noexcept;
private:
RingKind fRing{RingKind::kRingStdUser};
StringView fUserName;
VoidPtr fUserToken{nullptr};
friend UserManager;
};
class UserManager final
{
UserManager() = default;
~UserManager() = default;
User* fCurrentUser = nullptr;
User* fLastLoggedOffUser = nullptr;
public:
User* fRootUser = nullptr;
public:
NEWOS_COPY_DELETE(UserManager);
STATIC UserManager* The() noexcept;
Bool TryLogIn(User* user, const Char* password) noexcept;
User* GetCurrent() noexcept;
Void TryLogOff() noexcept;
};
} // namespace Kernel
#endif /* ifndef _INC_PERMISSION_SEL_HXX_ */
|