Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_security.hpp
1/*
2##############################################################################
3# file: ms_security.hpp #
4# 'msparser' toolkit #
5# Encapsulates Mascot security as used in authentication #
6##############################################################################
7# COPYRIGHT NOTICE #
8# Copyright 1998-2004 Matrix Science Limited All Rights Reserved. #
9# #
10##############################################################################
11# $Archive:: /MowseBranches/ms_mascotresfile_1.2/include/ms_mascotresfi $ #
12# $Author: villek@matrixscience.com $ #
13# $Date: 2018-07-30 16:23:53 +0100 $ #
14# $Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $ #
15# $NoKeywords:: $ #
16##############################################################################
17*/
18
19
20
21#if !defined(ms_security_INCLUDED_)
22#define ms_security_INCLUDED_
23
24
25// Includes from the standard template library
26#include <string>
27#include <set>
28#include <vector>
29#include <map>
30
31
32#ifdef _WIN32
33#include <io.h>
34#endif
35
36#include <time.h>
37
38namespace matrix_science {
39 class ms_security_options;
40 class ms_security_task;
41 class ms_security_tasks;
42
43#ifndef SWIG
44 class ms_userSortByID
45 {
46 public:
47 bool operator() (const ms_user * t1, const ms_user * t2) const
48 {
49 return (t1->getID() < t2->getID());
50 }
51 };
52
53 class ms_userSortByLoginName
54 {
55 public:
56 bool operator() (const ms_user * t1, const ms_user * t2) const
57 {
58 return (t1->getName() < t2->getName());
59 }
60 };
61
62 class ms_userSortByFullName
63 {
64 public:
65 bool operator() (const ms_user * t1, const ms_user * t2) const
66 {
67 return (t1->getFullName() < t2->getFullName());
68 }
69 };
70
71 class ms_groupSortByID
72 {
73 public:
74 bool operator() (const ms_group * t1, const ms_group * t2) const
75 {
76 return (t1->getID() < t2->getID());
77 }
78 };
79
80#endif
81
87
93 class MS_MASCOTRESFILE_API ms_security : public ms_errors
94 {
95
96 public:
100
101 public:
102
105 {
106 USERID_SORTBY_ID = 1,
107 USERID_SORTBY_LOGINNAME = 2,
108 USERID_SORTBY_FULLNAME = 3
109 };
110
112 bool addNewUser(const std::string sessionID,
113 const int userID,
114 const std::string userName,
115 const std::string password,
116 const time_t passwordExpiry,
117 const std::string fullName,
118 const std::string emailAddress,
119 const ms_user::usertype userType,
120 const bool enabled);
121
123 ms_user getUser(const std::string userName) const;
124
126 ms_user getUserFromID(const int userID) const;
127
129 bool isUserExists(const int userID) const;
130
132 std::vector<int> sortUsers(std::vector<ms_user*> & vecUsers, const USERID_SORTBY sortby) const;
133
135 std::vector<int> getAllUserIDs(const USERID_SORTBY sortby = USERID_SORTBY_ID) const;
136
138 bool deleteUser(const std::string sessionID, const std::string userName);
139
141 bool updateUser(const std::string sessionID, const ms_user user);
142
144 bool updatePassword(const std::string sessionID,
145 const std::string userName,
146 const std::string oldPassword,
147 const std::string newPassword);
148
150 std::vector<std::string> getIntegraUsers() const;
151
153 bool addNewGroup(const std::string sessionID,
154 const int groupID,
155 const std::string groupName);
156
158 ms_group getGroup(const std::string groupName) const;
159
161 ms_group getGroupFromID(const int groupID) const;
162
164 std::vector<int> getAllGroupIDs() const;
165
167 bool deleteGroup(const std::string sessionID, const std::string groupName);
168
170 bool updateGroup(const std::string sessionID, const ms_group & group);
171
173 ms_security_tasks getPermittedTasksForUser(const std::string name) const;
174
176 ms_user::customParams_t getAllCustomParamsForUser(const ms_user & user) const;
177
179 ms_security_options getMascotSecurityOptions() const;
180
182 ms_security_tasks getTasks() const;
183
185 bool isTaskExists(const int taskID) const;
186
188 bool createDefaults(const std::string sessionID = "");
189
191 bool updateAllSessionFiles(bool deleteOnly = false);
192
193 protected:
194 bool loadFromFile();
195 bool saveToFile();
196
197 private:
198 //do not copy this class
199 ms_security(const ms_security & src);
200 ms_security& operator=(const ms_security & right);
201
202 typedef std::set<ms_user *, ms_userSortByID> userlist_t;
203 typedef std::set<ms_group *, ms_groupSortByID> grouplist_t;
204
205 const char * invalidChars_;
206
207 userlist_t users_;
208 grouplist_t groups_;
209 ms_security_tasks * tasks_;
210 ms_security_options options_;
211 int nextFreeGroupID_;
212 int nextFreeUserID_;
213
214 void removeAllUsersFromMemory();
215 void removeAllGroupsFromMemory();
216 bool doUpdateUser(const ms_user user);
217
218 }; // end of security_group
220}
221#endif // !defined(ms_security_INCLUDED_)
This class is used as a base class for several Mascot Parser classes.
Definition: ms_errors.hpp:696
This class will normally only be used by Mascot Security Administration applications.
Definition: ms_security_group.hpp:39
Options for the Mascot security system.
Definition: ms_security_options.hpp:46
Each group has permission to do one or more tasks. This class defines a collection of tasks.
Definition: ms_security_tasks.hpp:51
The main security class to be used by the administration application.
Definition: ms_security.hpp:94
USERID_SORTBY
Sorting criterion to retrieve all users.
Definition: ms_security.hpp:105
This class will normally only be used by Mascot Security Administration applications.
Definition: ms_security_user.hpp:49
usertype
Definitions for types of user.
Definition: ms_security_user.hpp:57