【更新】授权模块
This commit is contained in:
@@ -5,7 +5,7 @@ std::string AppCfg::m_work_path="";
|
|||||||
std::string AppCfg::m_license="";
|
std::string AppCfg::m_license="";
|
||||||
float AppCfg::m_face_match_threshold = 0.78f;
|
float AppCfg::m_face_match_threshold = 0.78f;
|
||||||
void AppCfg::SetWorkPath(const std::string& work_path) {
|
void AppCfg::SetWorkPath(const std::string& work_path) {
|
||||||
|
m_work_path = work_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string AppCfg::GetWorkPath() {
|
const std::string AppCfg::GetWorkPath() {
|
||||||
@@ -18,6 +18,6 @@ bool AppCfg::SetLicense(const std::string& license) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AppCfg::SetFaceMatchThreshold(float threshold) {
|
void AppCfg::SetFaceMatchThreshold(float threshold) {
|
||||||
|
m_face_match_threshold = threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include "openssl/aes.h"
|
#include "openssl/aes.h"
|
||||||
#include "AuthModule.h"
|
#include "AuthModule.h"
|
||||||
|
#include "DeviceInfo.h"
|
||||||
#include "Base64.h"
|
#include "Base64.h"
|
||||||
#include "HttpRequest.h"
|
#include "HttpRequest.h"
|
||||||
// 获取时间戳
|
// 获取时间戳
|
||||||
@@ -115,8 +116,7 @@ void TimeInfo::Show() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AuthInfo::AuthInfo() :
|
AuthInfo::AuthInfo() :
|
||||||
m_type(AUTH_TYPE_INVALID) {
|
m_type(AUTH_TYPE_INVALID) { }
|
||||||
}
|
|
||||||
|
|
||||||
AuthInfo::AuthInfo(const std::string& key_data) {
|
AuthInfo::AuthInfo(const std::string& key_data) {
|
||||||
std::istringstream iss(key_data);
|
std::istringstream iss(key_data);
|
||||||
@@ -144,6 +144,7 @@ AuthInfo::AuthInfo(const std::string& key_data) {
|
|||||||
|
|
||||||
|
|
||||||
ret_t AuthModule::CheckKey(const std::string& key) {
|
ret_t AuthModule::CheckKey(const std::string& key) {
|
||||||
|
|
||||||
return RET_AUTH_FAILED;
|
return RET_AUTH_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,18 +156,19 @@ ret_t AuthModule::CheckKeyFile(const std::string& key_file) {
|
|||||||
}
|
}
|
||||||
m_auth_info = AuthInfo(key_data);
|
m_auth_info = AuthInfo(key_data);
|
||||||
// m_auth_info.m_expire_time.Show();
|
// m_auth_info.m_expire_time.Show();
|
||||||
switch (m_auth_info.m_type){
|
switch (m_auth_info.m_type) {
|
||||||
case AUTH_TYPE_OFFLINE_TIME:
|
case AUTH_TYPE_OFFLINE_TIME:
|
||||||
ret = CheckOfflineTime();
|
ret = CheckOfflineTime();
|
||||||
break;
|
break;
|
||||||
case AUTH_TYPE_OFFLINE_MAC:
|
case AUTH_TYPE_OFFLINE_MAC:
|
||||||
ret = CheckOfflineMac();
|
ret = CheckOfflineMac();
|
||||||
case AUTH_TYPE_ONLINE:
|
break;
|
||||||
ret = CheckOnline();
|
case AUTH_TYPE_ONLINE:
|
||||||
break;
|
ret = CheckOnline();
|
||||||
default:
|
break;
|
||||||
ret = RET_AUTH_FAILED;
|
default:
|
||||||
break;
|
ret = RET_AUTH_FAILED;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -242,6 +244,14 @@ ret_t AuthModule::CheckOfflineTime() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret_t AuthModule::CheckOfflineMac() {
|
ret_t AuthModule::CheckOfflineMac() {
|
||||||
|
std::vector<std::string> mac_list = DeviceInfo::GetInstance().GetMacAddress();
|
||||||
|
for (auto& mac : mac_list) {
|
||||||
|
for (auto& auth_mac : m_auth_info.m_mac_list) {
|
||||||
|
if (mac == auth_mac) {
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return RET_AUTH_FAILED;
|
return RET_AUTH_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user