[ref]同步
This commit is contained in:
parent
0305921c3e
commit
af1fea79cb
@ -30,7 +30,7 @@
|
||||
|
||||
|
||||
|
||||
#define SYNCTHING_GUI_APIKEY "kbdct@0755"
|
||||
#define SYNCTHING_GUI_APIKEY EMS_DEFAULT_PASSWD
|
||||
|
||||
#define FILE_SYNC_CFG_FILENAME "file_sync_cfg.xml"
|
||||
|
||||
|
||||
13
platform/src/sys/license_manager/Main.cpp
Normal file
13
platform/src/sys/license_manager/Main.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//QApplication a(argc, argv);
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
BIN
platform/src/sys/license_manager/license_manager.ico
Normal file
BIN
platform/src/sys/license_manager/license_manager.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
54
platform/src/sys/license_manager/license_manager.pro
Normal file
54
platform/src/sys/license_manager/license_manager.pro
Normal file
@ -0,0 +1,54 @@
|
||||
QT += core gui
|
||||
QT += network
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
TEMPLATE = app
|
||||
TARGET = license_manager
|
||||
|
||||
# CONFIG += console
|
||||
|
||||
|
||||
INCLUDEPATH += ../../include
|
||||
|
||||
win32-msvc* {
|
||||
LIBS += -ladvapi32
|
||||
}
|
||||
|
||||
|
||||
# Input
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
SOURCES += \
|
||||
Main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
|
||||
#LIBS += -lboost_system -lboost_chrono -llog4cplus
|
||||
#LIBS += -lpub_utility_api -lpub_logger_api -lrdb_api -lsys_dog_auth_api -lsys_license_auth_api -lcrypto
|
||||
LIBS += -lcrypto
|
||||
|
||||
|
||||
win32 {
|
||||
LIBS += -ladvapi32
|
||||
LIBS += -ltaskschd
|
||||
LIBS += -lcomsupp
|
||||
}
|
||||
|
||||
DEFINES += QAPPLICATION_CLASS=QApplication
|
||||
#-------------------------------------------------------------------
|
||||
COMMON_PRI=$$PWD/../../common.pri
|
||||
exists($$COMMON_PRI) {
|
||||
include($$COMMON_PRI)
|
||||
}else {
|
||||
error("FATAL error: can not find common.pri")
|
||||
}
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
RESOURCES += \
|
||||
res.qrc
|
||||
|
||||
contains(DEFINES, OS_WINDOWS) {
|
||||
RC_ICONS = license_manager.ico
|
||||
}
|
||||
204
platform/src/sys/license_manager/mainwindow.cpp
Normal file
204
platform/src/sys/license_manager/mainwindow.cpp
Normal file
@ -0,0 +1,204 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "sys_dog_auth_api/DogAuthInterface.h"
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include "common/Common.h"
|
||||
#include "openssl/err.h"
|
||||
|
||||
//< 公钥
|
||||
static const char *szPublicKey = "\
|
||||
-----BEGIN PUBLIC KEY-----\n\
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDnrsIgkFfGVi2Ja5rD0sh5paxH\n\
|
||||
EXJb4soJb2RyGMa2qbRgyXLAQaRjGosODl4UJlxr6WOjjkWMXRNpxPztxXjrX3gS\n\
|
||||
QKBt1wWkQrnQD/HQNDURBthM+M/St+ai9ZmOdhAJs584Ul6gE+jvMpxPid+bsZs7\n\
|
||||
ysTE7nEojz8oNLhISQIDAQAB\n\
|
||||
-----END PUBLIC KEY-----\n";
|
||||
|
||||
static const char *szPrivateKey = "\
|
||||
-----BEGIN PRIVATE KEY-----\n\
|
||||
MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAOeuwiCQV8ZWLYlr\n\
|
||||
msPSyHmlrEcRclviyglvZHIYxraptGDJcsBBpGMaiw4OXhQmXGvpY6OORYxdE2nE\n\
|
||||
/O3FeOtfeBJAoG3XBaRCudAP8dA0NREG2Ez4z9K35qL1mY52EAmznzhSXqAT6O8y\n\
|
||||
nE+J35uxmzvKxMTucSiPPyg0uEhJAgMBAAECgYEAxKyT2zTtbk8l5OxVuzqqOKot\n\
|
||||
bz8eR2ZkgFHxgPILbnDt0OPx58dRl1enB82mi5BtEKZVkThrTdaNblJtLCNgm0Ea\n\
|
||||
Hnuh2OVRZvMqhYk2AH9Awscv1ONQ46tHwJb47pBhheCJCybFb29pSIZdvDH6SFjH\n\
|
||||
aANfYZyl1TY0mo7SAEkCQQD5pV3NIyLh6Fz/hLBpK4aMaQdEwuberhOnxaqhDywu\n\
|
||||
vG3Kbc1y9m7PLixw3uuDKerw54cNfh5knlW5catQsD5jAkEA7ZRY5D49lt/NElUx\n\
|
||||
YK/E8T2MP29W5xMXMwwzD3vA1V2Jsqk25RwzyUSV1E9uPiyOEiiuiG9jQUwVQMnZ\n\
|
||||
YjO4YwJBAMoUfDujp4bqiu0jQZHAc+eQ1RtqEWxLyQlTzm0VVRR33v+vplDa/pOi\n\
|
||||
ssKjEE1aTx22rPHVF1Enggjc5GoqYDUCQQCY2mn6p0TO7jytf9xd/ZhzMYsrQQIj\n\
|
||||
d3fkowOzAYcGf8DZDt+/tk5nPtY7G8OtAtOBQWVRaIDugPnnjjZrZSVLAkAyIoh5\n\
|
||||
XTRAbawuC7hpoToZTpTW2rJ5DO9LfW3FpkWKFbg9fLIKGV9hTn5aWgeNH/n0x8XV\n\
|
||||
jH8afx1na7fvO62l\n\
|
||||
-----END PRIVATE KEY-----\n";
|
||||
|
||||
|
||||
using namespace iot_sys;
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// this->resize(QSize(300,200));
|
||||
// connect(ui->recheckBtn, &QPushButton::clicked, this, &MainWindow::slot_recheckBtn);
|
||||
}
|
||||
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//读取密钥
|
||||
RSA *MainWindow::createRSA( const unsigned char *szKey, bool bPubKey )
|
||||
{
|
||||
RSA *pRsa = nullptr;
|
||||
BIO *pKeyBio;
|
||||
pKeyBio = BIO_new_mem_buf( szKey, -1 );
|
||||
if ( pKeyBio == nullptr )
|
||||
{
|
||||
qDebug( "Failed to create key BIO\n" );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if ( bPubKey )
|
||||
{
|
||||
pRsa = PEM_read_bio_RSA_PUBKEY( pKeyBio, &pRsa, nullptr, nullptr );
|
||||
}
|
||||
else
|
||||
{
|
||||
pRsa = PEM_read_bio_RSAPrivateKey( pKeyBio, &pRsa, nullptr, nullptr );
|
||||
}
|
||||
if ( pRsa == nullptr )
|
||||
{
|
||||
qDebug( "Failed to create RSA\n" );
|
||||
}
|
||||
BIO_free( pKeyBio );
|
||||
return pRsa;
|
||||
}
|
||||
|
||||
// base64 编码
|
||||
char * base64Encode(const char *buffer, int length, bool newLine)
|
||||
{
|
||||
BIO *bmem = NULL;
|
||||
BIO *b64 = NULL;
|
||||
BUF_MEM *bptr;
|
||||
|
||||
b64 = BIO_new(BIO_f_base64());
|
||||
if (!newLine) {
|
||||
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
|
||||
}
|
||||
bmem = BIO_new(BIO_s_mem());
|
||||
b64 = BIO_push(b64, bmem);
|
||||
BIO_write(b64, buffer, length);
|
||||
BIO_flush(b64);
|
||||
BIO_get_mem_ptr(b64, &bptr);
|
||||
BIO_set_close(b64, BIO_NOCLOSE);
|
||||
|
||||
char *buff = (char *)malloc(bptr->length + 1);
|
||||
memcpy(buff, bptr->data, bptr->length);
|
||||
buff[bptr->length] = 0;
|
||||
BIO_free_all(b64);
|
||||
|
||||
return buff;
|
||||
}
|
||||
|
||||
QString MainWindow::createActiveCode(const QString &strRegCode,const QString &strAppId)
|
||||
{
|
||||
QString strActiveCode = "invalid register code";
|
||||
QStringList listRegCode = strRegCode.split("\n");
|
||||
if(listRegCode.empty() || listRegCode[0].isEmpty()){
|
||||
return strActiveCode;
|
||||
}
|
||||
|
||||
QString strCode = listRegCode[0] + " " + strAppId;
|
||||
|
||||
RSA *pRsa = createRSA(( unsigned char * ) szPrivateKey, false );
|
||||
int len = RSA_size(pRsa);
|
||||
char *encryptedText = (char *)malloc(len+1);
|
||||
memset(encryptedText, 0, len+1);
|
||||
|
||||
QByteArray clearDataArry = strCode.toUtf8();
|
||||
int nClearDataLen = clearDataArry.length();
|
||||
uchar* pClearData = (uchar*)clearDataArry.data();
|
||||
|
||||
|
||||
int nSize = RSA_private_encrypt(nClearDataLen, pClearData, (unsigned char*)encryptedText, pRsa, RSA_PKCS1_PADDING);
|
||||
|
||||
if(nSize > 0 )
|
||||
{
|
||||
QByteArray arr(encryptedText,nSize);
|
||||
strActiveCode = arr.toBase64().toBase64();
|
||||
}
|
||||
|
||||
RSA_free( pRsa );
|
||||
free(encryptedText);
|
||||
|
||||
return strActiveCode;
|
||||
}
|
||||
|
||||
void MainWindow::test(const QString &str,const unsigned char *data)
|
||||
{
|
||||
//< RSA_NO_PADDING 模式最长128
|
||||
char szDecryptText[128];
|
||||
memset( szDecryptText, 0, 128 );
|
||||
|
||||
RSA *pRsa = createRSA( (unsigned char * )szPublicKey, true );
|
||||
//int nLen = RSA_public_decrypt( 128, ( unsigned char * ) baActiveCode.data(), ( unsigned char * ) szDecryptText, pRsa, RSA_NO_PADDING );
|
||||
int nLen = RSA_public_decrypt( 128, data, ( unsigned char * ) szDecryptText, pRsa, RSA_NO_PADDING );
|
||||
unsigned long e = ERR_get_error();
|
||||
char szErrMsg[1024] = {0};
|
||||
char * pTmp = ERR_error_string(e,szErrMsg);
|
||||
RSA_free( pRsa );
|
||||
|
||||
if ( nLen <= 0 )
|
||||
{
|
||||
qDebug( "decryptByPublic() failed !" );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::test1(const QString &str)
|
||||
{
|
||||
QByteArray ba1 = QByteArray::fromBase64(str.toLatin1() );
|
||||
QString str1(ba1);
|
||||
QByteArray baActiveCode = QByteArray::fromBase64(QByteArray::fromBase64(str.toLatin1()) );
|
||||
|
||||
str1 = baActiveCode;
|
||||
QByteArray Block = str1.toLatin1();
|
||||
int ns = str1.size();
|
||||
char szCode[129];
|
||||
memset(szCode,0,129);
|
||||
memcpy(szCode,Block.data(),Block.size()+1);
|
||||
|
||||
//< RSA_NO_PADDING 模式最长128
|
||||
char szDecryptText[128];
|
||||
memset( szDecryptText, 0, 128 );
|
||||
int nsize = baActiveCode.size();
|
||||
RSA *pRsa = createRSA( (unsigned char * )szPublicKey, true );
|
||||
int nLen = RSA_public_decrypt( 128, ( unsigned char * ) baActiveCode.data(), ( unsigned char * ) szDecryptText, pRsa, RSA_PKCS1_PADDING );
|
||||
// int nLen = RSA_public_decrypt( 128, ( unsigned char * )szCode, ( unsigned char * ) szDecryptText, pRsa, RSA_PKCS1_PADDING );
|
||||
unsigned long e = ERR_get_error();
|
||||
char szErrMsg[1024] = {0};
|
||||
char * pTmp = ERR_error_string(e,szErrMsg);
|
||||
RSA_free( pRsa );
|
||||
|
||||
if ( nLen <= 0 )
|
||||
{
|
||||
qDebug( "decryptByPublic() failed !" );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_recheckBtn_clicked()
|
||||
{
|
||||
QString strRegCode = ui->reg_code->toPlainText();
|
||||
QString strAppId = ui->app_id->text();
|
||||
|
||||
QString strActiveCode = createActiveCode(strRegCode,strAppId);
|
||||
|
||||
ui->active_code->setText(strActiveCode);
|
||||
}
|
||||
36
platform/src/sys/license_manager/mainwindow.h
Normal file
36
platform/src/sys/license_manager/mainwindow.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class QPushButton;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
|
||||
private slots:
|
||||
void on_recheckBtn_clicked();
|
||||
|
||||
private:
|
||||
RSA *createRSA( const unsigned char *szKey, bool bPubKey );
|
||||
QString createActiveCode(const QString &strRegCode,const QString &strAppId);
|
||||
void test(const QString &str,const unsigned char *data);
|
||||
void test1(const QString &str);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
105
platform/src/sys/license_manager/mainwindow.ui
Normal file
105
platform/src/sys/license_manager/mainwindow.ui
Normal file
@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>720</width>
|
||||
<height>487</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>授权管理</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="8" column="0" colspan="5">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="active_code"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>注册码:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>机器码:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="5">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="reg_code"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>产品名称:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QPushButton" name="recheckBtn">
|
||||
<property name="text">
|
||||
<string>生成</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="app_id">
|
||||
<property name="text">
|
||||
<string>PSCADA</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<slots>
|
||||
<slot>slot_regedit()</slot>
|
||||
<slot>slot_unRegedit()</slot>
|
||||
<slot>slot_igoreCurTime()</slot>
|
||||
<slot>slot_stopRefesh()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
5
platform/src/sys/license_manager/res.qrc
Normal file
5
platform/src/sys/license_manager/res.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>license_manager.ico</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@ -7,7 +7,7 @@ SUBDIRS += \
|
||||
sys_license_auth_api \
|
||||
sys_dog_auth_api \
|
||||
sys_login_api \
|
||||
sys_dog_auth_check \
|
||||
# sys_dog_auth_check \
|
||||
sys_network_check_api \
|
||||
sys_proc_mng_api \
|
||||
sys_node_mng_api \
|
||||
@ -18,7 +18,7 @@ SUBDIRS += \
|
||||
sys_nodeinfo_tran \
|
||||
show_node_info \
|
||||
sys_launcher_srv \
|
||||
file_sync_auto
|
||||
# sys_file_auto
|
||||
|
||||
sys_dog_auth_api.depends = sys_license_auth_api
|
||||
sys_dog_auth_check.depends = sys_license_auth_api sys_dog_auth_api
|
||||
@ -28,4 +28,3 @@ sys_proc_mng.depends = sys_network_check_api sys_proc_mng_api
|
||||
sys_node_mng.depends = sys_network_check_api sys_proc_mng_api
|
||||
sys_network_check.depends = sys_network_check_api sys_proc_mng_api
|
||||
sys_nodeinfo_tran.depends = sys_proc_mng_api sys_node_mng_api
|
||||
file_sync_auto.depends = sys_proc_mng_api sys_node_mng_api
|
||||
|
||||
@ -4,7 +4,19 @@
|
||||
@author 曹顶法
|
||||
*/
|
||||
#include "BaseCfgParam.h"
|
||||
|
||||
//< 屏蔽xml_parser编译告警
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-copy"
|
||||
#endif
|
||||
|
||||
#include "boost/property_tree/xml_parser.hpp"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#include "boost/typeof/typeof.hpp"
|
||||
#include "boost/filesystem.hpp"
|
||||
#include "Common.h"
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
#include "pub_utility_api/CommonConfigParse.h"
|
||||
#include "pub_utility_api/FileUtil.h"
|
||||
#include <QString>
|
||||
#include <QDate>
|
||||
#include "boost/concept_check.hpp"
|
||||
|
||||
#ifndef DISABLE_DOG_AUTH
|
||||
#ifdef KBD_X86
|
||||
@ -17,12 +17,8 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define AUTH_MODEL_LICENCE 1 //licence模式
|
||||
#define AUTH_MODEL_SUPPERDOG 2 //硬件狗授权模式
|
||||
|
||||
#define AUTH_STATUS_OK 1 //授权状态-成功
|
||||
#define AUTH_STATUS_EXPIRED 0 //授权状态-过期
|
||||
#define AUTH_STATUS_FAILD -1 //授权状态-失败
|
||||
#define AUTH_MODEL_LICENCE 1
|
||||
#define AUTH_MODEL_SUPPERDOG 2
|
||||
|
||||
#define MEM_MEMBUFFER_SIZE 128
|
||||
|
||||
@ -37,7 +33,6 @@ iot_sys::CDogAuthImpl::CDogAuthImpl()
|
||||
#ifndef DISABLE_DOG_AUTH
|
||||
m_nProductId = PRODUCT_ID_PSCADA;
|
||||
m_ptrLicenseAuth = NULL;
|
||||
m_nAuthModel = AUTH_MODEL_SUPPERDOG;//默认硬件狗授权
|
||||
#ifdef KBD_X86
|
||||
m_dogStatus = DOG_NOT_FOUND ;
|
||||
m_dogHandle = 0 ;
|
||||
@ -62,63 +57,48 @@ iot_sys::CDogAuthImpl::~CDogAuthImpl()
|
||||
//检查系统授权状态
|
||||
int iot_sys::CDogAuthImpl::checkAuthStatus()
|
||||
{
|
||||
if(m_nAuthModel == AUTH_MODEL_LICENCE)
|
||||
// if(iotSuccess == checkDogAuthStatus())
|
||||
// {
|
||||
// return iotSuccess;
|
||||
// }
|
||||
if(iotSuccess == checLicenseAuthStatus())
|
||||
{
|
||||
return checLicenseAuthStatus();
|
||||
return iotSuccess;
|
||||
}
|
||||
else if(m_nAuthModel == AUTH_MODEL_SUPPERDOG)
|
||||
{
|
||||
return checkDogAuthStatus();
|
||||
}
|
||||
return AUTH_STATUS_FAILD;
|
||||
return iotFailed;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief 检查License授权状态
|
||||
@return 成功返回iotSucces,失败返回相应错误码
|
||||
@return 成功返回iotSuccess,失败返回相应错误码
|
||||
*/
|
||||
int iot_sys::CDogAuthImpl::checLicenseAuthStatus()
|
||||
{
|
||||
#ifndef DISABLE_DOG_AUTH
|
||||
|
||||
QString strTemp ;
|
||||
QDate objCurDate = QDate::currentDate(); //当前日期
|
||||
QString strAppId ;
|
||||
|
||||
std::string strLicensePath = iot_public::CFileUtil::getAbsolutePath( "../../product/common/license/" ) ;
|
||||
if(!m_ptrLicenseAuth->checkRegistration(QString::fromStdString(strLicensePath), "license.txt",strTemp) )
|
||||
if(!m_ptrLicenseAuth->checkRegistration(QString::fromStdString(strLicensePath), "license.txt",strAppId) )
|
||||
{
|
||||
LOGINFO("授权校验失败,AppId:Time=[%s]!\n",strTemp.toStdString().c_str());
|
||||
return AUTH_STATUS_FAILD;
|
||||
LOGINFO("授权校验失败,AppId=[%s]!\n",strAppId.toStdString().c_str());
|
||||
return iotFailed;
|
||||
}
|
||||
QStringList listTemp = strTemp.split(":") ;//appName:授权截至时间
|
||||
if(listTemp.size()<2)
|
||||
if(strAppId == "PSCADA" || strAppId == "EMS")
|
||||
{
|
||||
LOGINFO("授权license 解析错误 [%s]!\n",strTemp.toStdString().c_str());
|
||||
return AUTH_STATUS_FAILD;
|
||||
return iotSuccess;
|
||||
}
|
||||
if((objCurDate.daysTo(QDate::fromString(listTemp.at(1),"yyyy-MM-dd")) < 0)
|
||||
&&(objCurDate.daysTo(QDate::fromString(listTemp.at(1),"yyyy-MM-dd")) >= -90)) //授权截至时间到
|
||||
{
|
||||
return AUTH_STATUS_EXPIRED;
|
||||
}
|
||||
else if(objCurDate.daysTo(QDate::fromString(listTemp.at(1),"yyyy-MM-dd")) < -90) //3个月未授权,停用
|
||||
{
|
||||
return AUTH_STATUS_FAILD;
|
||||
}
|
||||
|
||||
QString strAppId = strTemp.split(":").at(0) ;
|
||||
if(strAppId !="PSCADA")
|
||||
else
|
||||
{
|
||||
LOGINFO("授权产品ID不匹配,AppId=[%s]!\n", strAppId.toStdString().c_str());
|
||||
return AUTH_STATUS_FAILD;
|
||||
return iotFailed;
|
||||
}
|
||||
#endif
|
||||
return AUTH_STATUS_OK;
|
||||
return iotSuccess;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief 检查超级狗授权状态
|
||||
@return 成功返回iotSucces,失败返回相应错误码
|
||||
@return 成功返回iotSuccess,失败返回相应错误码
|
||||
*/
|
||||
int iot_sys::CDogAuthImpl::checkDogAuthStatus()
|
||||
{
|
||||
@ -154,21 +134,18 @@ int iot_sys::CDogAuthImpl::checkDogAuthStatus()
|
||||
case DOG_NOT_FOUND:
|
||||
LOGDEBUG("超级狗文件读写状态:key/license container not available\n");
|
||||
break;
|
||||
case DOG_FEATURE_EXPIRED:
|
||||
LOGDEBUG("超级狗文件读写状态:Feature has expired \n");
|
||||
break;
|
||||
default:
|
||||
LOGDEBUG("超级狗文件读写状态:read memory failed\n");
|
||||
}
|
||||
|
||||
if (DOG_STATUS_OK != m_dogStatus) { //读写失败返回错误码
|
||||
return AUTH_STATUS_FAILD; //
|
||||
return m_dogStatus; //
|
||||
}
|
||||
#else
|
||||
return AUTH_STATUS_FAILD;
|
||||
return iotFailed;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return AUTH_STATUS_OK;
|
||||
return iotSuccess;
|
||||
}
|
||||
|
||||
/* @brief 初始化 */
|
||||
@ -188,11 +165,6 @@ int iot_sys::CDogAuthImpl::initialize()
|
||||
{
|
||||
LOGWARN("CDogAuthImpl::initialize() get product id fail, use default.\n");
|
||||
}
|
||||
//获取授权模式
|
||||
if (objCfgParse.getIntValue("setup_config", "authModel", m_nAuthModel) != iotSuccess)
|
||||
{
|
||||
m_nAuthModel = AUTH_MODEL_SUPPERDOG;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -216,6 +188,8 @@ int iot_sys::CDogAuthImpl::initialize()
|
||||
*/
|
||||
int iot_sys::CDogAuthImpl::loginSupperDog(int nProductId)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(nProductId);
|
||||
|
||||
#ifndef DISABLE_DOG_AUTH
|
||||
#ifdef KBD_X86
|
||||
//超级狗登陆状态不正常,退出
|
||||
|
||||
@ -24,26 +24,26 @@ namespace iot_sys
|
||||
|
||||
/**
|
||||
@brief 检查系统授权状态
|
||||
@return 成功返回iotSucces,失败返回相应错误码
|
||||
@return 成功返回iotSuccess,失败返回相应错误码
|
||||
*/
|
||||
virtual int checkAuthStatus() override;
|
||||
|
||||
/**
|
||||
@brief 初始化
|
||||
@return 成功返回iotSucces,失败返回相应错误码
|
||||
@return 成功返回iotSuccess,失败返回相应错误码
|
||||
*/
|
||||
int initialize();
|
||||
|
||||
protected:
|
||||
/**
|
||||
@brief 检查超级狗授权状态
|
||||
@return 成功返回iotSucces,失败返回相应错误码
|
||||
@return 成功返回iotSuccess,失败返回相应错误码
|
||||
*/
|
||||
int checkDogAuthStatus();
|
||||
|
||||
/**
|
||||
@brief 检查License授权状态
|
||||
@return 成功返回iotSucces,失败返回相应错误码
|
||||
@return 成功返回iotSuccess,失败返回相应错误码
|
||||
*/
|
||||
int checLicenseAuthStatus();
|
||||
|
||||
@ -62,7 +62,6 @@ namespace iot_sys
|
||||
#endif
|
||||
CLicenseAuthInterfacePtr m_ptrLicenseAuth;
|
||||
int m_nProductId;
|
||||
int m_nAuthModel;//授权模式
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<CDogAuthImpl> CDogAuthImplPtr;
|
||||
|
||||
@ -32,15 +32,15 @@ if(CONFIG(disable_dog_auth)) {
|
||||
}
|
||||
else{
|
||||
# 判架构
|
||||
contains(QMAKE_HOST.arch, x86_64):{
|
||||
contains(QMAKE_HOST.arch, x86_64): !linux-aarch64*{
|
||||
message("Host is amd64")
|
||||
DEFINES += KBD_X86
|
||||
# DEFINES += KBD_X86
|
||||
# 判系统
|
||||
win32{
|
||||
LIBS += -ldog_windows_x64_3151646
|
||||
# LIBS += -ldog_windows_x64_3151646
|
||||
}
|
||||
unix{
|
||||
LIBS += -ldog_linux_x86_64_3151646
|
||||
# LIBS += -ldog_linux_x86_64_3151646
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
@ -2,6 +2,36 @@
|
||||
#include <QApplication>
|
||||
#include <string.h>
|
||||
#include "SingleApplication.h"
|
||||
#include "pub_utility_api/FileStyle.h"
|
||||
#include <QFile>
|
||||
|
||||
void loadStyle()
|
||||
{
|
||||
QString qss = QString();
|
||||
std::string strFullPath = iot_public::CFileStyle::getPathOfStyleFile("public.qss","zh","light");
|
||||
|
||||
QFile qssfile1(QString::fromStdString(strFullPath));
|
||||
qssfile1.open(QFile::ReadOnly);
|
||||
if (qssfile1.isOpen())
|
||||
{
|
||||
qss += QLatin1String(qssfile1.readAll());
|
||||
qssfile1.close();
|
||||
}
|
||||
|
||||
strFullPath = iot_public::CFileStyle::getPathOfStyleFile("sys_dog_auth_check.qss","zh","light");
|
||||
QFile qssfile2(QString::fromStdString(strFullPath));
|
||||
qssfile2.open(QFile::ReadOnly);
|
||||
if (qssfile2.isOpen())
|
||||
{
|
||||
qss += QLatin1String(qssfile2.readAll());
|
||||
qssfile2.close();
|
||||
}
|
||||
|
||||
if (!qss.isEmpty())
|
||||
{
|
||||
qApp->setStyleSheet(qss);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -13,6 +43,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
//QApplication a(argc, argv);
|
||||
SingleApplication a(argc, argv);
|
||||
loadStyle();
|
||||
|
||||
MainWindow w;
|
||||
QObject::connect( &a, &SingleApplication::instanceStarted, [ &w ]() {
|
||||
w.show();
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
@ -6,9 +6,12 @@
|
||||
|
||||
using namespace iot_sys;
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
CustomUiMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
setAutoLayout(true);
|
||||
setWindowTitle(tr("授权检测"));
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
this->resize(QSize(300,200));
|
||||
@ -30,22 +33,15 @@ void MainWindow::slot_recheckBtn()
|
||||
ui->statusLab->setText("");
|
||||
|
||||
CDogAuthInterfacePtr ptrDogAuth = getDogAuthInstance();
|
||||
|
||||
int nRet = ptrDogAuth->checkAuthStatus();
|
||||
if (nRet == AUTH_STATUS_OK)
|
||||
{
|
||||
LOGINFO("加密狗检测正确(OK)!");
|
||||
ui->statusLab->setText(tr("正常"));
|
||||
}
|
||||
else if(nRet == AUTH_STATUS_EXPIRED)
|
||||
{
|
||||
LOGERROR("加密狗检测错误(授权过期)!");
|
||||
ui->statusLab->setText(tr("授权过期,错误码[%1]").arg(nRet));
|
||||
}
|
||||
else
|
||||
if (nRet > 0)
|
||||
{
|
||||
LOGERROR("加密狗检测错误(FAIL)!");
|
||||
ui->statusLab->setText(tr("异常,错误码[%1]").arg(nRet));
|
||||
}
|
||||
return;
|
||||
else
|
||||
{
|
||||
LOGERROR("加密狗检测正确(OK)!");
|
||||
ui->statusLab->setText(tr("正常"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "pub_widget/CustomMainWindow.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@ -9,7 +10,7 @@ namespace Ui {
|
||||
|
||||
class QPushButton;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
class MainWindow : public CustomUiMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ SOURCES += \
|
||||
|
||||
|
||||
LIBS += -lboost_system -lboost_chrono -llog4cplus
|
||||
LIBS += -lpub_utility_api -lpub_logger_api -lrdb_api -lsys_dog_auth_api -lsys_license_auth_api -lcrypto
|
||||
LIBS += -lpub_utility_api -lpub_logger_api -lrdb_api -lsys_dog_auth_api -lsys_license_auth_api -lcrypto -lpub_widget
|
||||
|
||||
|
||||
win32 {
|
||||
|
||||
@ -175,5 +175,5 @@ bool CSysLauncher::doStop()
|
||||
return true;
|
||||
}
|
||||
|
||||
} //< iot_sys
|
||||
} //< namespace iot_sys
|
||||
|
||||
|
||||
@ -49,5 +49,5 @@ private:
|
||||
int m_nRetryCntBeforeStart;
|
||||
};
|
||||
|
||||
} //< iot_sys
|
||||
} //< namespace iot_sys
|
||||
|
||||
|
||||
@ -17,11 +17,11 @@
|
||||
#include "pub_logger_api/logger.h"
|
||||
|
||||
#include "CSysLauncher.h"
|
||||
#include "setup/CommonDef.h"
|
||||
|
||||
void WINAPI serviceMain();
|
||||
void WINAPI serviceStrl(DWORD dwOpcode);
|
||||
|
||||
static TCHAR chServiceName[] = _T("iscs6000_launcher");
|
||||
static SERVICE_STATUS_HANDLE g_hServiceStatus = NULL;
|
||||
static SERVICE_STATUS g_stStatus;
|
||||
|
||||
@ -45,7 +45,7 @@ int main(int /*argc*/, char ** /*argv[]*/)
|
||||
|
||||
SERVICE_TABLE_ENTRY st[] =
|
||||
{
|
||||
{ chServiceName, (LPSERVICE_MAIN_FUNCTION)serviceMain },
|
||||
{ g_chLauncherServiceName, (LPSERVICE_MAIN_FUNCTION)serviceMain },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
@ -69,7 +69,7 @@ void WINAPI serviceMain()
|
||||
g_stStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
|
||||
|
||||
//< 注册服务控制
|
||||
g_hServiceStatus = RegisterServiceCtrlHandler(chServiceName, serviceStrl);
|
||||
g_hServiceStatus = RegisterServiceCtrlHandler(g_chLauncherServiceName, serviceStrl);
|
||||
if (g_hServiceStatus == NULL)
|
||||
{
|
||||
LOGERROR("serviceMain(): RegisterServiceCtrlHandler() return NULL !");
|
||||
|
||||
@ -11,10 +11,11 @@
|
||||
#include "sigar_format.h"
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <QCryptographicHash>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "LicenseAuthImpl.h"
|
||||
//#include "Common.h"
|
||||
@ -25,15 +26,16 @@ namespace iot_sys
|
||||
{
|
||||
|
||||
//< 注意:私钥不能写在发布出去的代码中,不排除通过分析编译后的二进制文件可以获得
|
||||
|
||||
//< 公钥
|
||||
static const char *szPublicKey = "\
|
||||
-----BEGIN PUBLIC KEY-----\n\
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA15DXITkGQuLMrFP98RWj6BDQ\n\
|
||||
iLK/t3H4e1HbyUIGt8Bdu/CmIm07x8AINbAomBK1Hmd1TL/47Y+XgQ7BduOHEncI\n\
|
||||
Gw8+emLpg0ms3p85U1k9qndeOe86gC9j6eFuvl8M4wqkGCIiqcIDSx1Nq2kuL/aw\n\
|
||||
VCzHJLc1nVNOBGXBvwIDAQAB\n\
|
||||
-----END PUBLIC KEY-----\n";
|
||||
-----BEGIN RSA PUBLIC KEY-----\n\
|
||||
MIIBCgKCAQEA1t7y9Wqvwhjw5IKVKVMzGKAAiPniXPIWyjkmTB0OVQhYNIej6aQ2\n\
|
||||
NM2EZZULbYnUvjF5hds9kYM46IIhr2M5RSOWmisKmco0AUe93mhAKTgRdpNXgrjc\n\
|
||||
yVdfI9KrjDdt+YYtlrPiLz+QgydOnlGeJlZ86yIZJ87RafQzp5Cun0Cam5+CVrt2\n\
|
||||
KOVWGO6tBfmBJtkBxJOGxx1SB9IVCSU3ikZpfwZ8SjvN1UE7y3A8BbGtEaevj2kI\n\
|
||||
Amqb8WJaw7BkHGzncVS38qcNo634j9Tzv/ighx+BLSPVZG3jk/KR8nYXwNvLbukQ\n\
|
||||
EEULz4rQCoAfMOcJsz6JlIk6kmyUCR9K1QIDAQAB\n\
|
||||
-----END RSA PUBLIC KEY-----\n";
|
||||
|
||||
|
||||
//读取密钥
|
||||
RSA *CLicenseAuthImpl::createRSA( const unsigned char *szKey, bool bPubKey )
|
||||
@ -49,7 +51,7 @@ RSA *CLicenseAuthImpl::createRSA( const unsigned char *szKey, bool bPubKey )
|
||||
|
||||
if ( bPubKey )
|
||||
{
|
||||
pRsa = PEM_read_bio_RSA_PUBKEY( pKeyBio, &pRsa, nullptr, nullptr );
|
||||
pRsa = PEM_read_bio_RSAPublicKey( pKeyBio, &pRsa, nullptr, nullptr );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -67,8 +69,13 @@ RSA *CLicenseAuthImpl::createRSA( const unsigned char *szKey, bool bPubKey )
|
||||
int CLicenseAuthImpl::publicDecrypt( const unsigned char *pEncData, int nDataLen, const unsigned char *szKey,
|
||||
unsigned char *pDecrypted )
|
||||
{
|
||||
|
||||
RSA *pRsa = createRSA( szKey, true );
|
||||
int nRc = RSA_public_decrypt( nDataLen, pEncData, pDecrypted, pRsa, RSA_NO_PADDING );
|
||||
if (!pRsa)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int nRc = RSA_public_decrypt( nDataLen, pEncData, pDecrypted, pRsa, RSA_PKCS1_PADDING);
|
||||
RSA_free( pRsa );
|
||||
return nRc;
|
||||
}
|
||||
@ -321,21 +328,21 @@ bool CLicenseAuthImpl::checkRegistration_private
|
||||
//< 公钥解密
|
||||
{
|
||||
//< RSA_NO_PADDING 模式最长128
|
||||
char szDecryptText[128];
|
||||
memset( szDecryptText, 0, 128 );
|
||||
int nLen = publicDecrypt(( unsigned char * ) baActiveCode.data(), 128,
|
||||
char szDecryptText[512];
|
||||
memset( szDecryptText, 0, 512);
|
||||
int nLen = publicDecrypt(( unsigned char * ) baActiveCode.data(), baActiveCode.size(),
|
||||
( unsigned char * ) szPublicKey,
|
||||
( unsigned char * ) szDecryptText );
|
||||
if ( nLen <= 0 )
|
||||
{
|
||||
qDebug( "decryptByPublic() failed !" );
|
||||
qDebug( "RSA_public_decrypt() failed !" );
|
||||
return false;
|
||||
}
|
||||
|
||||
//< todo 注意:解密后的内容切勿输出,对于科大讯飞TTS别人可以用我们的 APPID,算我们的装机量
|
||||
|
||||
const char *pText = szDecryptText;
|
||||
for ( nLen = 128; nLen > 0; --nLen )
|
||||
for ( nLen = 512; nLen > 0; --nLen )
|
||||
{
|
||||
if ( *pText == 0 )
|
||||
++pText;
|
||||
@ -352,9 +359,19 @@ bool CLicenseAuthImpl::checkRegistration_private
|
||||
baActiveCode = QByteArray( pText, nLen );
|
||||
|
||||
QList<QByteArray> listAc = baActiveCode.split( ' ' );
|
||||
if ( listAc.size() != 2 )
|
||||
if ( listAc.size() != 3 )
|
||||
{
|
||||
qDebug( "listAc.size() != 2" );
|
||||
qDebug( "listAc.size() != 3" );
|
||||
return false;
|
||||
}
|
||||
|
||||
QDateTime curDataTime = QDateTime::currentDateTime();
|
||||
QDateTime licTime = QDateTime::fromString(listAc[2],"yyyy-MM-dd_hh:mm:ss");
|
||||
uint nCurTime = curDataTime.toTime_t();
|
||||
uint nLicTime = licTime.toTime_t();
|
||||
if (nCurTime > nLicTime)
|
||||
{
|
||||
qDebug("Invalid active time !");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -380,4 +397,4 @@ bool CLicenseAuthImpl::checkRegistration_private
|
||||
return true;
|
||||
}
|
||||
|
||||
} //< namespace iot_application
|
||||
} //< namespace iot_app
|
||||
|
||||
@ -48,4 +48,4 @@ private:
|
||||
|
||||
typedef boost::shared_ptr<CLicenseAuthImpl> CLicenseAuthImplPtr;
|
||||
|
||||
} //< namespace iot_application
|
||||
} //< namespace iot_app
|
||||
|
||||
@ -7,15 +7,18 @@
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include "pub_widget/PubWidgetInit.h"
|
||||
#include <QKeyEvent>
|
||||
|
||||
#define INTERNAL_ACCOUNT_MAX_ID 10 //最大内置账号ID
|
||||
|
||||
CLoginDlg::CLoginDlg(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
CustomUiDialog(parent),
|
||||
ui(new Ui::CLoginDlg),
|
||||
m_pReadDb(Q_NULLPTR)
|
||||
{
|
||||
setResizeable(false);
|
||||
|
||||
const std::string strLanguage = std::move(iot_public::getCurLanguage());
|
||||
const std::string strQmFile = std::move(
|
||||
iot_public::CFileUtil::getPathOfResFile( "sys_login_api/translate/" + strLanguage + ".qm" ));
|
||||
@ -26,10 +29,12 @@ CLoginDlg::CLoginDlg(QWidget *parent) :
|
||||
QApplication::installTranslator( pTrans );
|
||||
}
|
||||
|
||||
iot_public::installTranslator(strLanguage);
|
||||
|
||||
ui->setupUi(this);
|
||||
Qt::WindowFlags flags=Qt::Dialog;
|
||||
flags |=Qt::WindowCloseButtonHint;
|
||||
setWindowFlags(flags);
|
||||
// Qt::WindowFlags flags=Qt::Dialog;
|
||||
// flags |=Qt::WindowCloseButtonHint;
|
||||
// setWindowFlags(flags);
|
||||
|
||||
init();
|
||||
initData();
|
||||
@ -41,6 +46,8 @@ CLoginDlg::CLoginDlg(QWidget *parent) :
|
||||
m_permFunc1 = QString();
|
||||
ui->alias->setEnabled(false);
|
||||
ui->password->setFocus();
|
||||
|
||||
setAutoLayout(true);
|
||||
}
|
||||
|
||||
CLoginDlg::~CLoginDlg()
|
||||
@ -148,12 +155,17 @@ bool CLoginDlg::eventFilter(QObject *obj, QEvent *event)
|
||||
emit sigDirectConnect();
|
||||
return true;
|
||||
}
|
||||
else if(keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return)
|
||||
{
|
||||
login();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return QDialog::eventFilter(obj, event);
|
||||
return CustomUiDialog::eventFilter(obj, event);
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,7 +311,7 @@ void CLoginDlg::initView()
|
||||
ui->userg->setView(new QListView);
|
||||
ui->user->setView(new QListView);
|
||||
ui->password->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
this->setFixedSize(240,165);
|
||||
// this->setFixedSize(200,212);
|
||||
this->setWindowTitle(tr("登录"));
|
||||
|
||||
ui->user->installEventFilter(this);
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>212</width>
|
||||
<height>164</height>
|
||||
<width>268</width>
|
||||
<height>208</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
||||
103
platform/src/sys/sys_login_api/en.ts
Normal file
103
platform/src/sys/sys_login_api/en.ts
Normal file
@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="zh_CN">
|
||||
<context>
|
||||
<name>CLoginDlg</name>
|
||||
<message>
|
||||
<location filename="CLoginDlg.ui" line="14"/>
|
||||
<source>CLoginDlg</source>
|
||||
<translation>Login</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.ui" line="34"/>
|
||||
<source>账号</source>
|
||||
<translation>Account</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.ui" line="88"/>
|
||||
<source>密码</source>
|
||||
<translation>Password</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.ui" line="123"/>
|
||||
<source>用户组</source>
|
||||
<translation>User group</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.ui" line="130"/>
|
||||
<source>姓名</source>
|
||||
<translation>Name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.ui" line="163"/>
|
||||
<location filename="CLoginDlg.cpp" line="303"/>
|
||||
<source>登录</source>
|
||||
<translation>Login</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.ui" line="182"/>
|
||||
<source>取消</source>
|
||||
<translation>Cancel</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.cpp" line="93"/>
|
||||
<source>未找到此普通权限</source>
|
||||
<translation>The permission was not found</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.cpp" line="98"/>
|
||||
<source>未进行密码验证</source>
|
||||
<translation>No password verification</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.cpp" line="419"/>
|
||||
<location filename="CLoginDlg.cpp" line="422"/>
|
||||
<location filename="CLoginDlg.cpp" line="425"/>
|
||||
<location filename="CLoginDlg.cpp" line="428"/>
|
||||
<location filename="CLoginDlg.cpp" line="431"/>
|
||||
<source>提示</source>
|
||||
<translation>Tip</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.cpp" line="419"/>
|
||||
<source>用户信息错误!</source>
|
||||
<translation>User infomation error!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.cpp" line="422"/>
|
||||
<source>密码不能为空!</source>
|
||||
<translation>Password can not be blank!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.cpp" line="425"/>
|
||||
<source>密码错误!</source>
|
||||
<translation>Wrong password!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.cpp" line="428"/>
|
||||
<source>不具备权限!</source>
|
||||
<translation>Does not have this permission!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.cpp" line="431"/>
|
||||
<source>用户已失效!</source>
|
||||
<translation>User has expired!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.cpp" line="179"/>
|
||||
<location filename="CLoginDlg.cpp" line="185"/>
|
||||
<source>警告</source>
|
||||
<translation>Warning</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.cpp" line="179"/>
|
||||
<source>创建数据库对象失败!</source>
|
||||
<translation>create db object failed!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="CLoginDlg.cpp" line="185"/>
|
||||
<source>打开数据库失败!</source>
|
||||
<translation>open db failed!</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
@ -25,7 +25,7 @@ DEFINES += LOGIN_EXPORT
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
LIBS += -ldb_base_api -ldb_api_ex -lpub_logger_api -llog4cplus \
|
||||
-lpub_sysinfo_api -lpub_utility_api \
|
||||
-lpub_sysinfo_api -lpub_utility_api -lpub_widget
|
||||
|
||||
SOURCES += \
|
||||
CLoginDlg.cpp
|
||||
@ -44,3 +44,5 @@ exists($$COMMON_PRI) {
|
||||
}else {
|
||||
error("FATAL error: can not find common.pri")
|
||||
}
|
||||
|
||||
TRANSLATIONS = $$PWD/en.ts
|
||||
|
||||
@ -181,7 +181,7 @@ void iot_sys::CPinger::handleTimeout()
|
||||
if (m_nFailTime >= m_nPingRetryTime) //< 超过指定次数才认为失败
|
||||
{
|
||||
bUpdateTable = true;
|
||||
LOGERROR("网络故障");
|
||||
LOGERROR("网络故障,目标IP地址:[%s]",m_strDstIP.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -110,13 +110,31 @@ int iot_sys::CRemoteAppInfoMng::checkRemoteBuffer()
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_objRecvBufMutex);
|
||||
|
||||
const bool bNetworkIsActive = m_ptrNetworkCheck->isNormal();
|
||||
bool bNetworkIsActive = false;
|
||||
SNetworkState stNetSta;
|
||||
if(iotSuccess == m_ptrNetworkCheck->getLocalNetStatus(stNetSta))
|
||||
{
|
||||
bNetworkIsActive = (stNetSta.bIP1State || stNetSta.bIP2State);
|
||||
}
|
||||
|
||||
int64 lCurTime = getMonotonicMsec();
|
||||
|
||||
for (AppKeyToHeartbeatMAP::iterator pNode = m_mapRecvAppInfo.begin(); pNode != m_mapRecvAppInfo.end(); ++pNode)
|
||||
{
|
||||
SAppHeartbeatInfo &stAppInfo = pNode->second;
|
||||
/* @brief 检查冗余相关状态是否发生变化 */
|
||||
if(!stNetSta.bIP1State && stAppInfo.bIP1Active)
|
||||
{
|
||||
stAppInfo.bIP1Active = false;
|
||||
stAppInfo.bNetworkStateChanged = true;
|
||||
}
|
||||
|
||||
if(!stNetSta.bIP2State && stAppInfo.bIP2Active)
|
||||
{
|
||||
stAppInfo.bIP2Active = false;
|
||||
stAppInfo.bNetworkStateChanged = true;
|
||||
}
|
||||
|
||||
if (stAppInfo.bRedundancyStateChanged || stAppInfo.bNetworkStateChanged)
|
||||
{
|
||||
m_ptrNodeInfoMng->updateAppRedundancyInfo(stAppInfo);
|
||||
@ -259,11 +277,34 @@ int iot_sys::CRemoteAppInfoMng::updateRecvHeartbeatInfo(const SAppHeartbeatInfo
|
||||
|
||||
/* @brief 更新访问信息字段 */
|
||||
if (stAppInfo.bIP1Active != stHeartbeat.bIP1Active || stAppInfo.bIP2Active != stHeartbeat.bIP2Active)
|
||||
{
|
||||
bool bIP1Active = stHeartbeat.bIP1Active;
|
||||
bool bIP2Active = stHeartbeat.bIP2Active;
|
||||
|
||||
SNetworkState stNetSta;
|
||||
if(iotSuccess == m_ptrNetworkCheck->getLocalNetStatus(stNetSta))
|
||||
{
|
||||
//为了解决如下情况:本机A、B网都正常,接收者只有A网正常,但是在接收者的内存中记录了AB网都正常
|
||||
//调整为:本机某网不正常时,不管对端是否正常,以本机为准
|
||||
//为了降低正常情况下此处访问网络状态的次数,没有每次都获取网络状态,而通过与checkRemoteBuffer配合完成
|
||||
if(!stNetSta.bIP1State && bIP1Active)
|
||||
{
|
||||
bIP1Active = false;
|
||||
}
|
||||
|
||||
if(!stNetSta.bIP2State && bIP2Active)
|
||||
{
|
||||
bIP2Active = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(stAppInfo.bIP1Active != bIP1Active || stAppInfo.bIP2Active == bIP2Active)
|
||||
{
|
||||
stAppInfo.bIP1Active = stHeartbeat.bIP1Active;
|
||||
stAppInfo.bIP2Active = stHeartbeat.bIP2Active;
|
||||
stAppInfo.bNetworkStateChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* @brief 更新心跳时间戳 */
|
||||
stAppInfo.lLastTime = getMonotonicMsec();
|
||||
|
||||
@ -4,7 +4,19 @@
|
||||
@author 曹顶法
|
||||
*/
|
||||
#include "ProcMngConfigParam.h"
|
||||
|
||||
//< 屏蔽xml_parser编译告警
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-copy"
|
||||
#endif
|
||||
|
||||
#include "boost/property_tree/xml_parser.hpp"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#include "boost/typeof/typeof.hpp"
|
||||
#include "boost/filesystem.hpp"
|
||||
#include "common/Common.h"
|
||||
|
||||
@ -131,12 +131,12 @@ int iot_sys::CProcMngThread::collectSingleProcessInfo(SProcInfoMngParam &stProcI
|
||||
//< 如果获取失败,暂不处理,依赖心跳超时进行异常处理
|
||||
STableRunProcInfo stRunProcInfo;
|
||||
int nRet = m_ptrRunProcInfoOpt->getProcInfoByKey(stProcInfo.stProcKey, stRunProcInfo);
|
||||
if (kbdErrProcMngApi_NoRecord == nRet) //< 进程管理启动时,其它应用进程可能未启动
|
||||
if (iotErrProcMngApi_NoRecord == nRet) //< 进程管理启动时,其它应用进程可能未启动
|
||||
{
|
||||
return iotSuccess;
|
||||
}
|
||||
|
||||
if (iotSuccess != nRet && kbdErrProcMngApi_NoRecord != nRet)
|
||||
if (iotSuccess != nRet && iotErrProcMngApi_NoRecord != nRet)
|
||||
{
|
||||
LOGERROR("更新进程信息失败.域[%d],应用[%d],节点[%s],进程[%s],启动参数[%s]",
|
||||
stProcInfo.stProcKey.nDomainId, stProcInfo.stProcKey.nAppId,
|
||||
|
||||
@ -62,7 +62,7 @@ int iot_sys::CRunProcInfoTableOperate::getProcInfoByKey(const SProcessInfoKey &s
|
||||
}
|
||||
else if (nCount == 0)
|
||||
{
|
||||
return kbdErrProcMngApi_NoRecord;
|
||||
return iotErrProcMngApi_NoRecord;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
namespace iot_sys
|
||||
{
|
||||
const int kbdErrProcMngApi_NoRecord = 2; //< 记录不存在
|
||||
const int iotErrProcMngApi_NoRecord = 2; //< 记录不存在
|
||||
|
||||
/* @brief 进程信息内存表操作类 */
|
||||
class CRunProcInfoTableOperate
|
||||
|
||||
@ -10,7 +10,8 @@
|
||||
//#include "pub_sysinfo_api/SysInfoApi.h"
|
||||
#include "pub_utility_api/ProcUtil.h"
|
||||
#include "pub_utility_api/TimeUtil.h"
|
||||
|
||||
#include "pub_utility_api/CommonConfigParse.h"
|
||||
#include "pub_utility_api/FileUtil.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace iot_public;
|
||||
@ -68,7 +69,7 @@ void iot_sys::CProcMngApiThread::execute()
|
||||
if(getMonotonicMsec() - m_lLastCheckDogTime >60*1000) //一分钟检查一次狗错误
|
||||
{
|
||||
m_lLastCheckDogTime = getMonotonicMsec();
|
||||
if(AUTH_STATUS_FAILD == m_ptrDogAuthApi->checkAuthStatus()) //DOG CHECK不成功
|
||||
if(iotSuccess != m_ptrDogAuthApi->checkAuthStatus()) //DOG CHECK不成功
|
||||
{
|
||||
m_nDogTimeOutCount++ ; //超时计次++
|
||||
if((m_nDogTimeOutCount*60) >= DOG_TIMEOUT)
|
||||
@ -321,6 +322,15 @@ int iot_sys::CProcMngApiThread::getProcessInfo(SProcRunInfo &stProcInfo)
|
||||
/* @brief 初始化线程相关资源 */
|
||||
int iot_sys::CProcMngApiThread::initialize()
|
||||
{
|
||||
CCommonConfigParse objConfig;
|
||||
if (iotSuccess != objConfig.load(CFileUtil::getPathOfCfgFile("proc_param_cfg.xml")))
|
||||
{
|
||||
LOGERROR("加载配置文件proc_param_cfg.xml失败,进程心跳使用默认参数");
|
||||
}
|
||||
|
||||
m_nRunPeriodMsec = objConfig.getIntWithDefault("sys_proc_mng_api","period",200);
|
||||
LOGINFO("进程心跳周期%d ms",m_nRunPeriodMsec);
|
||||
|
||||
#ifndef DISABLE_DOG_AUTH
|
||||
//< 不需要检查加密狗的程序,不构造实例,避免不必要的开销
|
||||
if(m_bNeedCheckAuth)
|
||||
@ -402,9 +412,9 @@ int iot_sys::CProcMngApiThread::heartbeat()
|
||||
|
||||
// 增加心跳间隔时间较大时的日志输出
|
||||
static int64 nLastHeartBeatItem = 0;
|
||||
if ( nLastHeartBeatItem != 0 && m_stProcRunInfo.lLastTime - nLastHeartBeatItem > 200 )
|
||||
if ( nLastHeartBeatItem != 0 && m_stProcRunInfo.lLastTime - nLastHeartBeatItem > 5 * m_nRunPeriodMsec)
|
||||
{
|
||||
LOGWARN( "请注意!标准心跳间隔时间【100ms】,当前心跳间隔时间【%dms】", m_stProcRunInfo.lLastTime - nLastHeartBeatItem );
|
||||
LOGWARN( "请注意!标准心跳间隔时间【100ms】,当前心跳间隔时间【%d ms】", static_cast<int>(m_stProcRunInfo.lLastTime - nLastHeartBeatItem) );
|
||||
}
|
||||
nLastHeartBeatItem = m_stProcRunInfo.lLastTime;
|
||||
|
||||
|
||||
@ -48,14 +48,14 @@ namespace iot_sys
|
||||
/**
|
||||
@brief 向进程管理注册进程信息
|
||||
@param const SProcessInfoKey & stProcKey 进程标识主键
|
||||
@return 成功返回iotSucces,失败返回iotFailed
|
||||
@return 成功返回iotSuccess,失败返回iotFailed
|
||||
@retval
|
||||
*/
|
||||
//int registerProcInfo(const SProcessInfoKey &stProcKey);
|
||||
|
||||
/**
|
||||
@brief 初始化
|
||||
@return 成功返回iotSucces,失败返回相应错误码
|
||||
@return 成功返回iotSuccess,失败返回相应错误码
|
||||
*/
|
||||
int initialize();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user