Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
UserProfile.hpp
Go to the documentation of this file.
1#ifndef IV_SRC_MODEL_DIAMAR_USERPROFILE_HPP_
2#define IV_SRC_MODEL_DIAMAR_USERPROFILE_HPP_
3
4#include "channels/enums.hpp"
6#include "core/types.hpp"
7#include "diamar/enums.hpp"
8#include "model/enums.hpp"
9#include "model/structs.hpp"
10
11#include <memory>
12
13namespace iv::diamar
14{
15
16class UserProfile final
17{
18public:
21
27
33
35 explicit UserProfile(const iv::diamar::eUserProfileType &type, const bool &enabled = false);
36 UserProfile(const UserProfile &userProfile);
37 UserProfile(UserProfile &&other) noexcept = delete;
39
40 UserProfile &operator=(const UserProfile &other) = delete;
41 UserProfile &operator=(UserProfile &&other) noexcept = delete;
42
43 bool load(const iv::file::xml::node &nodeProfile);
44 bool save(iv::file::xml::node &nodeProfile) const;
45 void update(const UserProfile &other);
46
47 void blockUser() const;
48
49 void unBlockUser() const;
50
51 [[nodiscard]] iv::diamar::eUserProfileType getType() const;
52 [[nodiscard]] std::string getPassword() const;
53 [[nodiscard]] std::string getDecipheredPassword() const;
54 [[nodiscard]] iv::types::milliseconds getMaxTimeInProfile() const;
55
56 [[nodiscard]] uint32_t getRemainingLoginAttempts() const;
57
58 void getRemainingBlockTime(uint32_t &hoursLeft, uint32_t &minutesLeft, uint32_t &secondsLeft) const;
59
60 [[nodiscard]] std::string getRemainingBlockTimeStr() const;
61 [[nodiscard]] std::string getTypeStr() const;
62 [[nodiscard]] std::string getIconUser() const;
63
64 void setActive(bool isActive);
65 void setPassword(const std::string &newPassword, bool mustBeChanged);
66
67 [[nodiscard]] bool canPermitAlarmAck() const;
68
69 [[nodiscard]] bool canChangePassword(std::string *reasonMsg) const;
70
71 [[nodiscard]] bool hasPermissionAccessControl(iv::model::eShipArea areaStationAlarm) const;
72 [[nodiscard]] bool hasPermissionAck(iv::model::eShipArea areaShip) const;
73 [[nodiscard]] bool hasPermissionChangeParameters(iv::model::eShipArea areaShip,
74 iv::channels::eChannelArea areaStationAlarm) const;
75
76 [[nodiscard]] bool hasPermissionChangeVariablesOnline(iv::model::eShipArea areaShip) const;
77 [[nodiscard]] bool isEnabled() const;
78 [[nodiscard]] bool isRoot() const;
79 [[nodiscard]] bool isPasswordCorrect(const std::string &password) const;
80 [[nodiscard]] bool mustChangePassword() const;
81 [[nodiscard]] bool isPasswordExpired() const;
82
83 [[nodiscard]] bool isNotifiedAlarm(iv::model::eShipArea areaShip, uint64_t areaStationAlarm) const;
84
85 [[nodiscard]] bool isNotifiedByZoneRepeaters(iv::model::eShipArea areaShip,
86 iv::model::eShipArea typeZoneRepeater) const;
87
88 [[nodiscard]] bool shouldBeNotifiedForPasswordChange(iv::types::timestamp &remainingTime) const;
89
91
92 [[nodiscard]] bool isBlocked() const;
93
96 void registerFailedLoginAttempt() const;
98
100
102 std::string m_password;
104
105 std::unique_ptr<PasswordProperties> m_passwordProperties;
106
107 std::unique_ptr<LoginAttemptsProperties> m_loginAttemptsProperties;
108
109private:
111 {
112 static constexpr std::string EngineAdvancedManagementPassword {"7410"};
113 static constexpr std::string DeckAdvancedManagementPassword {"8520"};
114 static constexpr std::string EngineManagementPassword {"1234"};
115 static constexpr std::string DeckManagementPassword {"1234"};
116 static constexpr std::string MonitorPassword {"0000"};
117 static constexpr std::string RootPassword {"1234"};
118 };
119 struct Keys
120 {
121 static constexpr std::string_view enabled {"Enabled"};
122 static constexpr std::string_view type {"Type"};
123 static constexpr std::string_view password {"Password"};
124 static constexpr std::string_view maxTime {"MaxTime"};
125 static constexpr std::string_view passwordMustBeChanged = "PasswordMustBeChanged";
126 static constexpr std::string_view passwordLastUpdated = "PasswordLastUpdated";
127 };
129 {
130 static constexpr std::string string {};
131 static constexpr std::string_view userProfileType {"EngineManagement"};
132 };
133};
134
135}// namespace iv::diamar
136
137#endif//IV_SRC_MODEL_DIAMAR_USERPROFILE_HPP_
Definition MonotonicTimer.hpp:12
Definition UserProfile.hpp:17
void setActive(bool isActive)
Definition UserProfile.cpp:240
void registerSuccessfulLoginAttempt() const
Definition UserProfile.cpp:696
bool isPasswordExpired() const
Definition UserProfile.cpp:467
bool hasPermissionChangeVariablesOnline(iv::model::eShipArea areaShip) const
Definition UserProfile.cpp:386
iv::types::milliseconds m_maxTimeInProfile
Definition UserProfile.hpp:103
bool isNotifiedAlarm(iv::model::eShipArea areaShip, uint64_t areaStationAlarm) const
Definition UserProfile.cpp:488
uint32_t getRemainingLoginAttempts() const
Definition UserProfile.cpp:166
std::string getIconUser() const
Definition UserProfile.cpp:202
bool m_enabled
Definition UserProfile.hpp:99
UserProfile & operator=(UserProfile &&other) noexcept=delete
UserProfile(UserProfile &&other) noexcept=delete
iv::diamar::eUserProfileType getType() const
Definition UserProfile.cpp:142
bool isEnabled() const
Definition UserProfile.cpp:440
bool mustChangePassword() const
Definition UserProfile.cpp:455
iv::types::milliseconds getMaxTimeInProfile() const
Get how much time the user can be logged in in seconds.
Definition UserProfile.cpp:161
UserProfile & operator=(const UserProfile &other)=delete
std::string m_password
Definition UserProfile.hpp:102
static iv::diamar::eUserProfileType getProfileUserInArea(iv::model::eShipArea area)
Definition UserProfile.cpp:13
std::string getRemainingBlockTimeStr() const
Definition UserProfile.cpp:184
bool isNotifiedByZoneRepeaters(iv::model::eShipArea areaShip, iv::model::eShipArea typeZoneRepeater) const
Definition UserProfile.cpp:520
bool save(iv::file::xml::node &nodeProfile) const
Definition UserProfile.cpp:108
bool hasPermissionAck(iv::model::eShipArea areaShip) const
Definition UserProfile.cpp:351
void setPasswordAndMaxTime(iv::diamar::eUserProfileType type)
Definition UserProfile.cpp:577
void registerFailedLoginAttempt() const
Definition UserProfile.cpp:707
bool canPermitAlarmAck() const
Definition UserProfile.cpp:252
bool load(const iv::file::xml::node &nodeProfile)
Definition UserProfile.cpp:79
bool isPasswordCorrect(const std::string &password) const
Definition UserProfile.cpp:450
bool isRoot() const
Definition UserProfile.cpp:445
bool hasPermissionAccessControl(iv::model::eShipArea areaStationAlarm) const
Definition UserProfile.cpp:302
bool isBlocked() const
Definition UserProfile.cpp:618
std::string getTypeStr() const
Definition UserProfile.cpp:197
std::unique_ptr< PasswordProperties > m_passwordProperties
Definition UserProfile.hpp:105
void update(const UserProfile &other)
Definition UserProfile.cpp:121
static iv::diamar::eUserProfileType getProfileUserInAreaWithAccess(iv::model::eShipArea area)
Definition UserProfile.cpp:31
bool hasPermissionChangeParameters(iv::model::eShipArea areaShip, iv::channels::eChannelArea areaStationAlarm) const
Definition UserProfile.cpp:630
std::string getDecipheredPassword() const
Definition UserProfile.cpp:152
std::string getPassword() const
Definition UserProfile.cpp:147
UserProfile()
Definition UserProfile.cpp:49
bool canChangePassword(std::string *reasonMsg) const
Definition UserProfile.cpp:257
bool shouldBeNotifiedForPasswordChange(iv::types::timestamp &remainingTime) const
Definition UserProfile.cpp:554
void blockUser() const
Definition UserProfile.cpp:129
void setPassword(const std::string &newPassword, bool mustBeChanged)
Definition UserProfile.cpp:245
void unBlockUser() const
Definition UserProfile.cpp:137
void getRemainingBlockTime(uint32_t &hoursLeft, uint32_t &minutesLeft, uint32_t &secondsLeft) const
Definition UserProfile.cpp:173
std::unique_ptr< LoginAttemptsProperties > m_loginAttemptsProperties
Definition UserProfile.hpp:107
void registerLoginAttemptInBlockedProfile() const
Definition UserProfile.cpp:725
iv::diamar::eUserProfileType m_type
Definition UserProfile.hpp:101
void resetFailedLoginAttemptsCounter() const
Definition UserProfile.cpp:687
Definition xmlFile.hpp:15
eChannelArea
Definition enums.hpp:55
Definition DataLoggerManager.cpp:10
eUserProfileType
Definition enums.hpp:34
eShipArea
Definition enums.hpp:11
uint64_t timestamp
Definition types.hpp:21
uint64_t milliseconds
Definition types.hpp:22
Definition UserProfile.hpp:111
static constexpr std::string DeckManagementPassword
Definition UserProfile.hpp:115
static constexpr std::string DeckAdvancedManagementPassword
Definition UserProfile.hpp:113
static constexpr std::string EngineAdvancedManagementPassword
Definition UserProfile.hpp:112
static constexpr std::string EngineManagementPassword
Definition UserProfile.hpp:114
static constexpr std::string RootPassword
Definition UserProfile.hpp:117
static constexpr std::string MonitorPassword
Definition UserProfile.hpp:116
Definition UserProfile.hpp:129
static constexpr std::string_view userProfileType
Definition UserProfile.hpp:131
Definition UserProfile.hpp:120
static constexpr std::string_view type
Definition UserProfile.hpp:122
static constexpr std::string_view enabled
Definition UserProfile.hpp:121
static constexpr std::string_view maxTime
Definition UserProfile.hpp:124
static constexpr std::string_view passwordMustBeChanged
Definition UserProfile.hpp:125
static constexpr std::string_view passwordLastUpdated
Definition UserProfile.hpp:126
static constexpr std::string_view password
Definition UserProfile.hpp:123
iv::core::MonotonicTimer blockTimer
Definition UserProfile.hpp:30
uint32_t unsuccessfulLoginAttempts
Definition UserProfile.hpp:31
Definition UserProfile.hpp:23
bool mustBeChanged
Definition UserProfile.hpp:24
iv::types::timestamp lastUpdated
Definition UserProfile.hpp:25