From 610f91d87152cbe48d3054fcf437d8239da6ef35 Mon Sep 17 00:00:00 2001 From: Amlal Date: Sat, 21 Dec 2024 21:59:13 +0100 Subject: IMP: :boom: Breaking changes some checks are needed to be done. Signed-off-by: Amlal --- dev/Kernel/KernelKit/User.h | 83 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 dev/Kernel/KernelKit/User.h (limited to 'dev/Kernel/KernelKit/User.h') diff --git a/dev/Kernel/KernelKit/User.h b/dev/Kernel/KernelKit/User.h new file mode 100644 index 00000000..be911830 --- /dev/null +++ b/dev/Kernel/KernelKit/User.h @@ -0,0 +1,83 @@ +/* ------------------------------------------- + + Copyright (C) 2024, TQ B.V, all rights reserved. + +------------------------------------------- */ + +#ifndef INC_USER_H +#define INC_USER_H + +#include +#include +#include +#include + +///! 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 */ -- cgit v1.2.3