summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/KernelKit/User.h
blob: b74b08c1bb720649ac844ada989bf9bd6d3939d5 (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
/* -------------------------------------------

 Copyright (C) 2024, Theater Quality Inc, all rights reserved.

------------------------------------------- */

#ifndef INC_USER_H
#define INC_USER_H

#include <CompilerKit/CompilerKit.h>
#include <KernelKit/LPC.h>
#include <NewKit/KString.h>
#include <NewKit/Defines.h>

///! We got the Super and guest user, both used to make authorization operations on the OS.
#define kSuperUser "OS AUTHORITY/SUPER"
#define kGuestUser "OS AUTHORITY/GUEST"

#define kUsersDir "/Users/"

#define kMaxUserNameLen	 (255U)
#define kMaxUserTokenLen (255U)

namespace Kernel
{
	class User;

	enum class UserRingKind
	{
		kRingInvalid   = 0,
		kRingStdUser   = 1,
		kRingSuperUser = 2,
		kRingGuestUser = 5,
		kRingCount	   = 3,
	};

	typedef Char* usr_public_key_kind;

	class User final
	{
	public:
		explicit User() = delete;

		User(const Int32& sel, const Char* userName);
		User(const UserRingKind& kind, const Char* userName);

		~User();

	public:
		ZKA_COPY_DEFAULT(User)

	public:
		bool operator==(const User& lhs);
		bool operator!=(const User& lhs);

	public:
		/// @brief Get software ring
		const UserRingKind& Ring() noexcept;

		/// @brief Get user name
		Char* Name() noexcept;

		/// @brief Is he a standard user?
		Bool IsStdUser() noexcept;

		/// @brief Is she a super user?
		Bool IsSuperUser() noexcept;

		/// @brief Saves a password from the public key.
		Bool Save(const usr_public_key_kind password) noexcept;

		/// @brief Checks if a password matches the **password**.
		/// @param password the password to check.
		Bool Matches(const usr_public_key_kind password) noexcept;

	private:
		UserRingKind mUserRing{UserRingKind::kRingStdUser};
		Char		 mUserName[kMaxUserNameLen]	  = {0};
		Char		 mUserToken[kMaxUserTokenLen] = {0};
	};
} // namespace Kernel

#endif /* ifndef INC_USER_H */