Skip to content

Commit b941a14

Browse files
committed
added:pass encrypt supported
1 parent 691228f commit b941a14

File tree

9 files changed

+72
-4
lines changed

9 files changed

+72
-4
lines changed

XEngine_Release/XEngine_Config/XEngine_Config.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
"st_XCDKey":{
2323
"tszKeyFile":"./APPVer.key",
2424
"tszKeyPass":"123123qa"
25-
}
25+
},
26+
"st_PassCrypto":{
27+
"bEnable":true,
28+
"nCodec":2
29+
}
2630
},
2731
"XLogin":{
2832
"bHTTPAuth":false,

XEngine_Source/AuthorizeModule_Configure/Config_Define.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ typedef struct
3838
XCHAR tszKeyFile[MAX_PATH]; //本地CDKEY文件地址
3939
XCHAR tszKeyPass[MAX_PATH]; //本地CDKEY密码
4040
}st_XCDKey;
41+
struct
42+
{
43+
bool bEnable; //是否启用
44+
int nCodec; //加密方法:ENUM_XENGINE_OPENSSL_DIGEST
45+
}st_PassCrypto;
4146
int nCheckTimeNumber; //检测次数
4247
int nCheckTimeout; //超时时间
4348
int nTokenTimeout; //TOKEN登录超时时间

XEngine_Source/AuthorizeModule_Configure/ModuleConfigure_Json/ModuleConfigure_Json.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE
101101
pSt_ServerConfig->st_XMax.nWSThread = st_JsonXMax["nWSThread"].asInt();
102102
pSt_ServerConfig->st_XMax.nHTTPThread = st_JsonXMax["nHTTPThread"].asInt();
103103
//验证配置
104-
if (st_JsonRoot["XVerification"].empty() || (7 != st_JsonRoot["XVerification"].size()))
104+
if (st_JsonRoot["XVerification"].empty() || (8 != st_JsonRoot["XVerification"].size()))
105105
{
106106
Config_IsErrorOccur = true;
107107
Config_dwErrorCode = ERROR_AUTHORIZE_MODULE_CONFIGURE_XVER;
@@ -117,6 +117,9 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE
117117

118118
_tcsxcpy(pSt_ServerConfig->st_XVerification.st_XCDKey.tszKeyFile, st_JsonXVerification["st_XCDKey"]["tszKeyFile"].asCString());
119119
_tcsxcpy(pSt_ServerConfig->st_XVerification.st_XCDKey.tszKeyPass, st_JsonXVerification["st_XCDKey"]["tszKeyPass"].asCString());
120+
121+
pSt_ServerConfig->st_XVerification.st_PassCrypto.bEnable = st_JsonXVerification["st_PassCrypto"]["bEnable"].asBool();
122+
pSt_ServerConfig->st_XVerification.st_PassCrypto.nCodec = st_JsonXVerification["st_PassCrypto"]["nCodec"].asInt();
120123
//登录配置
121124
if (st_JsonRoot["XLogin"].empty() || (6 != st_JsonRoot["XLogin"].size()))
122125
{

XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Config.cpp

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ void CDialog_Config::DoDataExchange(CDataExchange* pDX)
3838
DDX_Control(pDX, IDC_COMBO2, m_ListEncrypto);
3939
DDX_Control(pDX, IDC_EDIT6, m_EditPassword);
4040
DDX_Control(pDX, IDC_EDIT11, m_EditDCode);
41+
DDX_Control(pDX, IDC_COMBO7, m_ComboPassCodec);
42+
DDX_Control(pDX, IDC_RADIO4, m_RadioPassDisable);
43+
DDX_Control(pDX, IDC_RADIO3, m_RadioPassEnable);
4144
}
4245

4346

@@ -48,6 +51,8 @@ BEGIN_MESSAGE_MAP(CDialog_Config, CDialogEx)
4851
ON_BN_CLICKED(IDC_RADIO2, &CDialog_Config::OnBnClickedRadio2)
4952
ON_BN_CLICKED(IDC_RADIO1, &CDialog_Config::OnBnClickedRadio1)
5053
ON_BN_CLICKED(IDC_BUTTON8, &CDialog_Config::OnBnClickedButton8)
54+
ON_BN_CLICKED(IDC_RADIO3, &CDialog_Config::OnBnClickedRadio3)
55+
ON_BN_CLICKED(IDC_RADIO4, &CDialog_Config::OnBnClickedRadio4)
5156
END_MESSAGE_MAP()
5257

5358

@@ -70,6 +75,15 @@ BOOL CDialog_Config::OnInitDialog()
7075

7176
m_CheckCodecEnable.SetCheck(BST_UNCHECKED);
7277
m_CheckCodecDisable.SetCheck(BST_CHECKED);
78+
79+
m_RadioPassDisable.SetCheck(BST_CHECKED);
80+
m_ComboPassCodec.EnableWindow(false);
81+
m_ComboPassCodec.InsertString(0, _T("MD4"));
82+
m_ComboPassCodec.InsertString(1, _T("MD5"));
83+
m_ComboPassCodec.InsertString(2, _T("SHA1"));
84+
m_ComboPassCodec.InsertString(3, _T("SHA256"));
85+
m_ComboPassCodec.SetCurSel(1);
86+
7387
m_ListEncrypto.AddString(_T("XCrypto(X加密)"));
7488
m_ListEncrypto.SetCurSel(0);
7589
m_ListEncrypto.EnableWindow(false);
@@ -101,14 +115,26 @@ void CDialog_Config::OnBnClickedButton1()
101115
m_EditPass.GetWindowText(m_StrPass);
102116
m_EditDCode.GetWindowText(m_StrDCode);
103117

118+
TCHAR tszMDBuffer[64] = {};
119+
if (m_RadioPassEnable.GetCheck() == BST_CHECKED)
120+
{
121+
int nPLen = m_StrPass.GetLength();
122+
XBYTE byMD5Buffer[MAX_PATH] = {};
123+
OPenSsl_Api_Digest(m_StrPass.GetBuffer(), byMD5Buffer, &nPLen, false, m_ComboPassCodec.GetCurSel() + 1);
124+
BaseLib_OperatorString_StrToHex((LPCXSTR)byMD5Buffer, nPLen, tszMDBuffer);
125+
}
126+
else
127+
{
128+
_tcsxcpy(tszMDBuffer, m_StrPass.GetBuffer());
129+
}
104130
if (m_StrDCode.GetLength() > 0)
105131
{
106132
m_EditToken.GetWindowText(m_StrToken);
107-
_xstprintf(tszUrlAddr, _T("http://%s:%s/api?function=login&user=%s&pass=%s&device=%d&token=%s&dcode=%s"), m_StrIPAddr.GetBuffer(), m_StrIPPort.GetBuffer(), m_StrUser.GetBuffer(), m_StrPass.GetBuffer(), ENUM_PROTOCOL_FOR_DEVICE_TYPE_PC_WINDOWS, m_StrToken.GetBuffer(), m_StrDCode.GetBuffer());
133+
_xstprintf(tszUrlAddr, _T("http://%s:%s/api?function=login&user=%s&pass=%s&device=%d&token=%s&dcode=%s"), m_StrIPAddr.GetBuffer(), m_StrIPPort.GetBuffer(), m_StrUser.GetBuffer(), tszMDBuffer, ENUM_PROTOCOL_FOR_DEVICE_TYPE_PC_WINDOWS, m_StrToken.GetBuffer(), m_StrDCode.GetBuffer());
108134
}
109135
else
110136
{
111-
_xstprintf(tszUrlAddr, _T("http://%s:%s/api?function=login&user=%s&pass=%s&device=%d"), m_StrIPAddr.GetBuffer(), m_StrIPPort.GetBuffer(), m_StrUser.GetBuffer(), m_StrPass.GetBuffer(), ENUM_PROTOCOL_FOR_DEVICE_TYPE_PC_WINDOWS);
137+
_xstprintf(tszUrlAddr, _T("http://%s:%s/api?function=login&user=%s&pass=%s&device=%d"), m_StrIPAddr.GetBuffer(), m_StrIPPort.GetBuffer(), m_StrUser.GetBuffer(), tszMDBuffer, ENUM_PROTOCOL_FOR_DEVICE_TYPE_PC_WINDOWS);
112138
}
113139
//请求用户信息
114140
int nMsgLen = 0;
@@ -357,3 +383,17 @@ void CDialog_Config::OnBnClickedButton8()
357383
m_EditDCode.SetWindowText(tszDCodeStr);
358384
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
359385
}
386+
387+
388+
void CDialog_Config::OnBnClickedRadio3()
389+
{
390+
// TODO: 在此添加控件通知处理程序代码
391+
m_ComboPassCodec.EnableWindow(TRUE);
392+
}
393+
394+
395+
void CDialog_Config::OnBnClickedRadio4()
396+
{
397+
// TODO: 在此添加控件通知处理程序代码
398+
m_ComboPassCodec.EnableWindow(FALSE);
399+
}

XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,9 @@ class CDialog_Config : public CDialogEx
4343
CEdit m_EditPassword;
4444
CEdit m_EditDCode;
4545
afx_msg void OnBnClickedButton8();
46+
CComboBox m_ComboPassCodec;
47+
CButton m_RadioPassDisable;
48+
CButton m_RadioPassEnable;
49+
afx_msg void OnBnClickedRadio3();
50+
afx_msg void OnBnClickedRadio4();
4651
};
Binary file not shown.
Binary file not shown.

XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/resource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#define IDC_EDIT8 1014
5050
#define IDC_CHECK2 1014
5151
#define IDC_EDIT22 1014
52+
#define IDC_COMBO7 1014
5253
#define IDC_RADIO1 1015
5354
#define IDC_EDIT23 1015
5455
#define IDC_RADIO2 1016

XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/AuthorizeHTTP_Post/AuthorizeHTTP_User.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ bool XEngine_AuthorizeHTTP_User(XNETHANDLE xhToken, LPCXSTR lpszClientAddr, LPCX
108108
return false;
109109
}
110110
bSuccess = false;
111+
112+
if (st_AuthConfig.st_XVerification.st_PassCrypto.bEnable)
113+
{
114+
int nPLen = _tcsxlen(st_UserTable.st_UserInfo.tszUserPass);
115+
XBYTE byMD5Buffer[MAX_PATH] = {};
116+
OPenSsl_Api_Digest(st_UserTable.st_UserInfo.tszUserPass, byMD5Buffer, &nPLen, false, st_AuthConfig.st_XVerification.st_PassCrypto.nCodec);
117+
memset(st_UserTable.st_UserInfo.tszUserPass, '\0', sizeof(st_UserTable.st_UserInfo.tszUserPass));
118+
BaseLib_OperatorString_StrToHex((LPCXSTR)byMD5Buffer, nPLen, st_UserTable.st_UserInfo.tszUserPass);
119+
}
120+
111121
if (0 == st_AuthConfig.st_XSql.nDBType)
112122
{
113123
bSuccess = DBModule_SQLite_UserRegister(&st_UserTable);

0 commit comments

Comments
 (0)