⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stdrights.h

📁 SecurityLib一个user-rights系统控件
💻 H
字号:
//---------------------------------------------------------------------------
#ifndef StdRightsH
#define StdRightsH

#ifndef __NOSYSTEM_HPP
#	include <system.hpp>
#endif

#include <strings.hpp>

//#define __SSPI_H__
//#include "SecurityCpp.h"

//) && defined(SecurityDlgH)

#if defined(__DLL__) && defined(SECURITYLIB_DLL)
#	define _DLLPORT __export
#else
#	define _DLLPORT __import
#endif

#define ParamValLen 16
#define FullNameLen 50

namespace Security {

class ESecExcept /*: public exception */ {};

#define defexcept(co, anc) class co : public anc {}

defexcept(EDBProviderError, ESecExcept);
defexcept(EDBProviderDModError, EDBProviderError);
//defexcept(EDBProvDestructError, EDBProviderError);

defexcept(ESecAutoLoginFailed , ESecExcept);
#undef defexcept

typedef smallstr<ParamValLen> SecString;
typedef smallstr<FullNameLen> FullString;
typedef pswdsstr<ParamValLen> PswdString;

class TSecurity;

enum SecPasswdOption { poFalse, poTrue, poGroup }; // compatible with TCheckBoxState and bool


enum SecRightsMask { rmView=1, rmInsert=2, rmModify=4, rmDelete=8 };
enum SecAutoLoginType { altNone, altFixedPasswd, altSimplePasswd, altPasswdDlg, altCustom };


typedef char * __stdcall (*SecDecodeFnc)(const char *enc, char *dec);
typedef PswdString __stdcall (*SecEncodeFnc)(const char *co1,const char *co2); // laczy ze soba oba stringi w jeden zakodowany, nie musza miec 16 dlugosci
// obsolete
// encodes main passwords

// encodes db editor password
typedef PswdString __stdcall (*SecDBEditEncodeFnc)(const char *co, int paramkey, int userkey);
typedef bool __stdcall (*SecOnLogin) (TSecurity *co, void *);
class _DLLPORT TSecParamEd;

#pragma anon_struct on

class _DLLPORT TSecStdRights  {
	public:
	private:
		TSecurity *s;

	public:
		union {
			mutable SecRightsMask Rights;
			struct {
				mutable bool View  :1;
				mutable bool Insert:1;
				mutable bool Modify:1;
				mutable bool Delete:1;
			};
		};


		bool getRight(int mask) { return Rights & mask; }

	public:
		__stdcall TSecStdRights() : s(0) {}
		__stdcall TSecStdRights(TSecurity *co);
		__stdcall TSecStdRights(const TSecStdRights &co);
		__stdcall TSecStdRights(const char *co);
		__stdcall ~TSecStdRights();

		bool __stdcall PrepareLogin();
		bool __stdcall PrepareLoginWindow(char *fullname);

		void __stdcall PostLogin();

		static bool __stdcall PrepareLogin(TSecurity *s);
		static bool __stdcall PrepareLoginWindow(TSecurity *s,char *fullname);

		static void __stdcall PostLogin(TSecurity *s);

		bool __stdcall AutoLogin();
		bool __stdcall Login(SecAutoLoginType t);
		bool __stdcall Login();
		bool __stdcall Login(const char *name,const  char *passwd);
		bool __stdcall Login(const char *error,const  char *wrongpswd, const char *t, const char *fullname);

		static bool __stdcall AutoLogin(TSecurity *);
		static bool __stdcall Login(TSecurity *,SecAutoLoginType t);
		static bool __stdcall Login(TSecurity *);
		static bool __stdcall Login(TSecurity *, const char *name,const  char *passwd);
		static bool __stdcall Login(TSecurity *, const char *error,const  char *wrongpswd, const char *t, const char *fullname);

		void __stdcall Logout();
		void __stdcall ShowDlg(SecDBEditEncodeFnc fnc = 0, bool mdichild =false);
		void __stdcall ShowSmpDlg(SecDBEditEncodeFnc fnc = 0, bool mdichild =false);

		bool __stdcall Logged() const;
		bool __stdcall Binded() const;

		bool __stdcall Bind(const char *);
		void __stdcall Bind(TSecurity *);

		TSecStdRights &operator=(TSecurity *co) { Bind(co); return *this; }
		TSecStdRights & __stdcall operator=(const TSecStdRights &);

		static void __stdcall Logout(TSecurity *);
		static void __stdcall ShowDlg(TSecurity *, SecDBEditEncodeFnc fnc = 0, bool mdichild =false);
		static void __stdcall ShowSmpDlg(TSecurity *, SecDBEditEncodeFnc fnc = 0, bool mdichild =false);

		static bool __stdcall Logged(TSecurity *);
		/**********************************/

		int       __stdcall GetRight(const char *name) const;
		int       __stdcall GetRight(int FormID) const;

		SecString __stdcall GetParam(const char *name) const;
		SecString __stdcall GetParam(int ParamID) const;
		PswdString __stdcall GetPswdParam(const char *name) const;
		PswdString __stdcall GetPswdParam(int ParamID) const;
		bool      __stdcall GetBoolParam(const char *name) const;
		bool      __stdcall GetBoolParam(int ParamID) const;
		int       __stdcall GetIntParam(const char *name) const;
		int       __stdcall GetIntParam(int ParamID) const;


		SecString __stdcall GetDBParam(const char *name) const;
		bool      __stdcall GetBoolDBParam(const char *name) const;
		PswdString __stdcall GetPswdDBParam(const char *name) const;

		operator SecRightsMask&() const { return Rights; }

		static TSecurity * __stdcall AddSecurity(const char *secname, const char *alias, const char *dbprov, const char *dbend,  void * data, const char *secuser, const char *secencpswd, SecEncodeFnc f=0, bool autolog = true);
		static TSecurity * __stdcall AddSecurity(const char *secname, const char *alias, const char *dbprov, const char *dbend,  void * data, const char *secuser, const char *secencpswd,const char *fullname, SecEncodeFnc f=0, bool autolog = true);
		static TSecurity * __stdcall AddSecurity(const char *secname, const char *alias, const char *dbprov, const char *dbend,  void * data, const char *secuser, const char *secencpswd,const char *user, const char *pswd, SecEncodeFnc f=0, bool autolog = true);
		static TSecurity * __stdcall AddSecurity(const char *secname, const char *alias, const char *dbprov, const char *dbend,  void * data, const char *secuser, const char *secencpswd,const char *error, const char *wrongpswd, const char *t, const char *fullname, SecEncodeFnc f=0, bool autolog = true);
		static TSecurity * __stdcall AddSecurity(const char *secname, const char *alias, const char *dbprov, const char *dbend,  void * data, const char *secuser, const char *secencpswd, SecOnLogin onlogin, void *autodata, bool autolog = true);

		static TSecurity * __stdcall DeleteSecurity(const char *secname);
		static TSecurity * __stdcall FindSecurity(const char *name);


		//security zaalokuje strlen(enc+1) bajt體 i poda ci je w dec. zwr骳 dec
		static void __stdcall SetPasswdDecoder (SecDecodeFnc co );

		SecString __stdcall YesString() const;
		SecString __stdcall NoString() const;

//		void __stdcall SetPass(char *co);

		static void __stdcall SetAppHWnd(HWND app);
		static void __stdcall SetMDIClient(HWND app);
		static HWND __stdcall GetMDIClient();

	public:
		SecString __stdcall UserName() const;
		FullString __stdcall  UserFullName() const;
		PswdString __stdcall UserPasswd() const;
		int __stdcall UserID() const;
		int __stdcall GroupID() const;

		SecPasswdOption __stdcall UserAllowChangePswd() const;
		SecPasswdOption __stdcall UserAllowNullPasswd() const;
		SecPasswdOption __stdcall UserNoChPswdAtLogin() const;
		SecPasswdOption __stdcall UserAccountEnabled()  const;
		SecPasswdOption __stdcall UserPasswdControl()   const;

		bool __stdcall GroupAllowChangePswd() const;
		bool __stdcall GroupAllowNullPasswd() const;
		bool __stdcall GroupNoChPswdAtLogin() const;
		bool __stdcall GroupAccountEnabled () const;
		bool __stdcall GroupPasswdControl  () const;

		bool __stdcall GroupForceAddMod() const;

		bool __stdcall GetAllowChangePswd() const;
		bool __stdcall GetAllowNullPasswd() const;
		bool __stdcall GetNoChPswdAtLogin() const;
		bool __stdcall GetAccountEnabled() const;
		bool __stdcall GetPasswdControl() const;

		TSecParamEd *__stdcall ModifyStart(const PswdString &key);
		void __stdcall ModifyEnd(TSecParamEd *co);


};

} //  namespace Security

using namespace Security;


//---------------------------------------------------------------------------
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -