Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_security_session.hpp
1/*
2##############################################################################
3# file: ms_security_session.hpp #
4# 'msparser' toolkit #
5# Encapsulates a mascot session 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#if !defined(mascot_session_DA3EC794_90F8_4c4f_AD5D_13C3B6971A51__INCLUDED_)
20#define mascot_session_DA3EC794_90F8_4c4f_AD5D_13C3B6971A51__INCLUDED_
21
22
23// Includes from the standard template library
24#include <string>
25#include <set>
26#include <vector>
27#include <map>
28#include <time.h>
29
30namespace matrix_science {
35 class ms_security;
36 class ms_security_options;
37
39
122 class MS_MASCOTRESFILE_API ms_session : public ms_errors
123 {
124 public:
126 ms_session(const std::string session_id = "");
127
129 ms_session(const std::string userName,
130 const std::string userPassword);
131
133 ms_session(const std::string userName,
134 const std::string connectionID,
135 const std::string database);
136
138 ms_session(const int timeout, const std::string prefix);
139
140
141#if !defined(DOXYGEN_SHOULD_SKIP_THIS)
142 ms_session(const ms_session& src);
143#endif
144 /* SWIG function dispatcher fails in Perl 5.12 for some reason, and
145 * tries to use ms_session(const ms_security&, const std::string&) as
146 * the constructor for cases such as ms_session(300, "score_gif")...
147 * This constructor is supposed to be for internal use anyway, which
148 * is why it is defined out.
149 */
150#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(SWIG)
151 ms_session(const ms_security &sec,
152 const std::string &session_id);
153 ms_session(const ms_security &sec,
154 const ms_user & user);
155 ms_session& operator =(const ms_session& right);
156#endif
157
158 ~ms_session();
159
160 public:
162 std::string getID() const;
163
165 int getUserID() const;
166
168 std::string getUserName() const;
169
171 std::string getFullUserName() const;
172
174 std::string getEmailAddress() const;
175
177 bool isSecurityEnabled() const;
178
180 time_t getLastAccessed() const;
181
183 time_t getTimeout() const;
184
186 std::string getIPAddress() const;
187
189 matrix_science::ms_security_tasks getPermittedTasks() const;
190
192 bool setPermittedTasks(const matrix_science::ms_security_tasks & val);
193
195 std::map<std::string, std::string> getParams() const;
196
198 bool isPermitted(const int taskID) const;
199
201 bool isPermitted_long(const int taskID, const long value) const;
202
204 bool isPermitted_double(const int taskID, const double value) const;
205
207 bool isPermitted_string(const int taskID, const std::string value) const;
208
210 bool isFastaPermitted(const std::string database) const;
211
213 bool canResultsFileBeViewed(const int userID) const;
214
216 bool saveStringParam(const std::string name, const std::string param);
217
219 bool saveIntParam(const std::string name, int param);
220
222 bool saveLongParam(const std::string name, long param);
223
225 bool saveTimeParam(const std::string name, time_t param);
226
228 bool saveDoubleParam(const std::string name, double param);
229
231 bool saveBoolParam(const std::string name, bool param);
232
233#ifndef SWIG
235 bool getStringParam(const std::string name, std::string & param) const;
236#endif
238 std::string getStringParam(const std::string name) const;
239
241 bool getIntParam(const std::string name, int & param) const;
242
244 int getIntParam(const std::string name) const;
245
247 bool getLongParam(const std::string name, long & param) const;
248
250 long getLongParam(const std::string name) const;
251
253 bool getTimeParam(const std::string name, time_t & param) const;
254
256 time_t getTimeParam(const std::string name) const;
257
259 bool getDoubleParam(const std::string name, double & param) const;
260
262 double getDoubleParam(const std::string name) const;
263
265 bool getBoolParam(const std::string name, bool & param) const;
266
268 bool clearParam(const std::string name);
269
271 bool destroy();
272
274 bool isTimedOut() const;
275
277 matrix_science::ms_user::usertype getUserType() const;
278
280 bool update(const ms_security & sec);
281
283 std::vector<int> getSpoofableUsers() const;
284
285 private:
286 typedef std::map<std::string, std::string> param_t;
287 std::string sessionID_;
288 param_t params_;
289 param_t customParams_;
290 typedef std::set<std::string> cpIdentifier_t;
291 cpIdentifier_t systemIdentifiers_;
292 ms_security_tasks permittedTasks_;
293 bool saveParamShouldSaveFile_;
294 bool allowParamAndFileSaving_;
295
296 void init();
297 bool loadSessionFromFile(const ms_security * const sec);
298 bool saveSessionToFile(const ms_security * const sec);
299 void setDisabledSession(const ms_security_options & opts);
300 bool setCommandLineSession(const ms_security_options & secOpt);
301 bool setGuestSession();
302 bool doesSessionFileExist(const std::string sess);
303 bool getAllParams(const ms_user & u, const ms_security & sec);
304 std::string getSessionIDFromUser(const ms_user & user);
305 std::string getWebSvrAuthSessionID(std::string userName = "");
306 bool checkIPAddressOrComputerName(const std::string ipAddress,
307 std::string & sessionID);
308 bool checkAgentString(std::string & sessionID);
309 bool validateIntegraPassword(const ms_user & u,
310 const ms_security_options & secOpt,
311 const std::string & userPassword,
312 std::string & session_id,
313 int & errorFlag) const;
314 bool verifyIntegraConnection() const;
315 bool isSessionIdentical(const ms_session & sess) const;
316 void copyFrom(const ms_session * src);
317 void createSessionFromID(const std::string session_id);
318 }; // end of security_group
320}
321#endif // !defined(mascot_session_DA3EC794_90F8_4c4f_AD5D_13C3B6971A51__INCLUDED_)
This class is used as a base class for several Mascot Parser classes.
Definition: ms_errors.hpp:696
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
Use this class to determine if a user is logged in and if they have 'permission' to perform tasks.
Definition: ms_security_session.hpp:123
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