Matrix Science header

ms_security_session.hpp

00001 /*
00002 ##############################################################################
00003 # file: ms_security_session.hpp                                              #
00004 # 'msparser' toolkit                                                         #
00005 # Encapsulates a mascot session as used in authentication                    #
00006 ##############################################################################
00007 # COPYRIGHT NOTICE                                                           #
00008 # Copyright 1998-2004 Matrix Science Limited  All Rights Reserved.           #
00009 #                                                                            #
00010 ##############################################################################
00011 #    $Archive:: /MowseBranches/ms_mascotresfile_1.2/include/ms_mascotresfi $ #
00012 #     $Author: davidc $ #
00013 #       $Date: 2015/07/31 15:48:07 $ #
00014 #   $Revision: 1.26 $ #
00015 # $NoKeywords::                                                            $ #
00016 ##############################################################################
00017 */
00018 
00019 #if !defined(mascot_session_DA3EC794_90F8_4c4f_AD5D_13C3B6971A51__INCLUDED_)
00020 #define mascot_session_DA3EC794_90F8_4c4f_AD5D_13C3B6971A51__INCLUDED_
00021 
00022 #ifdef _WIN32
00023 #pragma warning(disable:4251)   // Don't want all classes to be exported
00024 #pragma warning(disable:4786)   // Debug symbols too long
00025 #   ifndef _MATRIX_USE_STATIC_LIB
00026 #       ifdef MS_MASCOTRESFILE_EXPORTS
00027 #           define MS_MASCOTRESFILE_API __declspec(dllexport)
00028 #       else
00029 #           define MS_MASCOTRESFILE_API __declspec(dllimport)
00030 #       endif
00031 #   else
00032 #       define MS_MASCOTRESFILE_API
00033 #   endif
00034 #else
00035 #   define MS_MASCOTRESFILE_API
00036 #endif
00037 
00038 // for the sake of #include <string>
00039 #ifdef __ALPHA_UNIX__
00040 #include <ctype.h>
00041 #endif
00042 
00043 // Includes from the standard template library
00044 #include <string>
00045 #include <set>
00046 #include <vector>
00047 #include <map>
00048 #include <time.h>
00049 
00050 namespace matrix_science {
00055     class ms_security;
00056     class ms_security_options;
00057 
00059 
00142     class MS_MASCOTRESFILE_API ms_session : public ms_errors
00143     {
00144     public:
00146         ms_session(const std::string session_id = "");
00147 
00149         ms_session(const std::string userName, 
00150                    const std::string userPassword);
00151 
00153         ms_session(const std::string userName,
00154                    const std::string connectionID,
00155                    const std::string database);
00156 
00158         ms_session(const int timeout, const std::string prefix);
00159 
00160 
00161 #if !defined(DOXYGEN_SHOULD_SKIP_THIS)
00162         ms_session(const ms_session& src);
00163 #endif
00164         /* SWIG function dispatcher fails in Perl 5.12 for some reason, and
00165          * tries to use ms_session(const ms_security&, const std::string&) as
00166          * the constructor for cases such as ms_session(300, "score_gif")...
00167          * This constructor is supposed to be for internal use anyway, which
00168          * is why it is defined out.
00169          */
00170 #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(SWIG)
00171         ms_session(const ms_security &sec,
00172                    const std::string &session_id);
00173         ms_session(const ms_security &sec,
00174                    const ms_user & user);
00175         ms_session& operator =(const ms_session& right);
00176 #endif 
00177 
00178         ~ms_session();
00179 
00180     public:
00182         std::string getID() const;
00183 
00185         int getUserID() const;
00186 
00188         std::string getUserName() const;
00189 
00191         std::string getFullUserName() const;
00192 
00194         std::string getEmailAddress() const;
00195 
00197         bool isSecurityEnabled() const;
00198 
00200         time_t getLastAccessed() const;
00201 
00203         time_t getTimeout() const;
00204 
00206         std::string getIPAddress() const;
00207 
00209         matrix_science::ms_security_tasks getPermittedTasks() const;
00210 
00212         bool setPermittedTasks(const matrix_science::ms_security_tasks & val);
00213 
00215         std::map<std::string, std::string> getParams() const;
00216 
00218         bool isPermitted(const int taskID) const;
00219 
00221         bool isPermitted_long(const int taskID, const long value) const;
00222 
00224         bool isPermitted_double(const int taskID, const double value) const;
00225 
00227         bool isPermitted_string(const int taskID, const std::string value) const;
00228 
00230         bool isFastaPermitted(const std::string database) const;
00231 
00233         bool canResultsFileBeViewed(const int userID) const;
00234 
00236         bool saveStringParam(const std::string name, const std::string param);
00237 
00239         bool saveIntParam(const std::string name, int param);
00240 
00242         bool saveLongParam(const std::string name, long param);
00243 
00245         bool saveTimeParam(const std::string name, time_t param);
00246 
00248         bool saveDoubleParam(const std::string name, double param);
00249 
00251         bool saveBoolParam(const std::string name, bool param);
00252 
00253 #ifndef SWIG
00254 
00255         bool getStringParam(const std::string name, std::string & param) const;
00256 #endif
00257 
00258         std::string getStringParam(const std::string name) const;
00259 
00261         bool getIntParam(const std::string name, int & param) const;
00262 
00264         int getIntParam(const std::string name) const;
00265 
00267         bool getLongParam(const std::string name, long & param) const;
00268 
00270         long getLongParam(const std::string name) const;
00271 
00273         bool getTimeParam(const std::string name, time_t & param) const;
00274 
00276         time_t getTimeParam(const std::string name) const;
00277 
00279         bool getDoubleParam(const std::string name, double & param) const;
00280 
00282         double getDoubleParam(const std::string name) const;
00283 
00285         bool getBoolParam(const std::string name, bool & param) const;
00286 
00288         bool clearParam(const std::string name);
00289 
00291         bool destroy();
00292 
00294         bool isTimedOut() const;
00295 
00297         matrix_science::ms_user::usertype getUserType() const;
00298 
00300         bool update(const ms_security & sec);
00301 
00303         std::vector<int> getSpoofableUsers() const;
00304     
00305     private:
00306         typedef std::map<std::string, std::string> param_t;
00307         std::string sessionID_;
00308         param_t  params_;
00309         param_t  customParams_;
00310         typedef std::set<std::string> cpIdentifier_t;
00311         cpIdentifier_t systemIdentifiers_;
00312         ms_security_tasks permittedTasks_;
00313         bool saveParamShouldSaveFile_;
00314         bool allowParamAndFileSaving_;
00315 
00316         void init();
00317         bool loadSessionFromFile(const ms_security * const sec);
00318         bool saveSessionToFile(const ms_security * const sec);
00319         void setDisabledSession(const ms_security_options & opts);
00320         bool setCommandLineSession(const ms_security_options & secOpt);
00321         bool setGuestSession();
00322         bool doesSessionFileExist(const std::string sess);
00323         bool getAllParams(const ms_user & u, const ms_security & sec);
00324         std::string getSessionIDFromUser(const ms_user & user);
00325         std::string getWebSvrAuthSessionID(std::string userName = "");
00326         bool checkIPAddressOrComputerName(const std::string ipAddress,
00327                                           std::string & sessionID);
00328         bool checkAgentString(std::string & sessionID);
00329         bool validateIntegraPassword(const ms_user & u, 
00330                                      const ms_security_options & secOpt,
00331                                      const std::string & userPassword,
00332                                      std::string & session_id,
00333                                      int & errorFlag) const;
00334         bool verifyIntegraConnection() const;
00335         bool isSessionIdentical(const ms_session & sess) const;
00336         void copyFrom(const ms_session * src);
00337         void createSessionFromID(const std::string session_id);
00338     }; // end of security_group
00340 }
00341 #endif // !defined(mascot_session_DA3EC794_90F8_4c4f_AD5D_13C3B6971A51__INCLUDED_)
Copyright © 2016 Matrix Science Ltd.  All Rights Reserved. Generated on Fri Jun 2 2017 01:44:51