linux版本中间件

SoftAuth.h 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <string>
  6. using namespace std;
  7. //#define MSHY "/etc/mshy.so" // 验证权限文件
  8. #define MSHY "mshy.so" // 验证权限文件
  9. typedef struct {
  10. std::string code; // 机器码
  11. std::string data; // 到期时间
  12. int trunkNum; // 中继数量
  13. int agentNum; // 坐席数量
  14. } AuthInfo;
  15. class SoftAuth
  16. {
  17. public:
  18. bool MakeAuth(std::string machCode);
  19. bool MakeAuthV2(std::string machCode);
  20. bool Auth();
  21. bool AuthV2();
  22. bool Auth(std::string& encode); // 解码
  23. bool AuthV2(std::string& encode); // 解码
  24. bool isExpire();
  25. int trunkNum() { return aInfo.trunkNum; }
  26. int acdNum() { return aInfo.agentNum; }
  27. bool getMachineCode(std::string& code);
  28. void getAuthInfo(AuthInfo &authInfo) { authInfo = aInfo; }
  29. static SoftAuth* GetInstance() { return &instance; }
  30. private:
  31. SoftAuth() { /*aInfo = nullptr; */ };
  32. ~SoftAuth() {};
  33. SoftAuth(const SoftAuth&) = default;
  34. SoftAuth& operator=(const SoftAuth&) = delete;
  35. int __getdiskid(std::string& hardc);
  36. bool Base64Encode(const string & input, string & output);
  37. bool Base64Decode(const string & input, string & output);
  38. private:
  39. static SoftAuth instance;
  40. /*AuthInfo* aInfo;*/
  41. AuthInfo aInfo;
  42. };