Exemplo n.º 1
0
 void testRLIwithAccountNumberAndPassword()
 {
     RliMessageHandler rlihandler(protocol_);
     VnocMessageSocketHandler<MockTcpConnection> handler(conn_);
     handler.setProtocol(protocol_);
     handler.start();
     MSG_RLI rliMessage;
     unsigned char tmp[16] = {0};
     srand((unsigned int)time(0));
     for(int i = 0; i < 16; ++i)
     {
         tmp[i] = rand() % 256;
     }
     rliMessage.SetAccountNumber(tmp, 16);
     for(int i = 0; i < 16; ++i)
     {
         tmp[i] = rand() % 256;
     }
     rliMessage.SetPassword(tmp, 16);
     PackMessage packer;
     int len = packer.GetMessageLen(&rliMessage);
     char *buf = new char[len];
     packer.Pack(&rliMessage, (byte *)buf, len);
     conn_->setRecv(buf, len);
     char *sendBuf = (char*)conn_->getSendBuf();
     //return an ALI message with login-success
     CMessageParser parser;
     CMessage *msg = parser.Parse((byte*)sendBuf, conn_->getSendLen());
     CPPUNIT_ASSERT(msg->GetMessageType() == MSG_ALI_TYPE);
     CPPUNIT_ASSERT(((MSG_ALI*)msg)->GetLoginResult() == 0);
     delete msg;
     delete buf;
 }
Exemplo n.º 2
0
void CVNOCLoginDlg::OnBnClickedOk()
{
    UpdateData(TRUE);
	Global->Logf(LogFile_Net,_T("登陆操作,用户名:%s 密码:%s\n"), m_strUsername, m_strPassword);
	if (m_strUsername.IsEmpty())
	{
		OnOK();
	}

	SHA1 shaer;
	shaer.Reset();

	CStringA pwdBuffer = CT2A(m_strPassword);
	shaer.Input(pwdBuffer,pwdBuffer.GetLength());
	UINT pResult[5];
	shaer.Result(pResult);
	pwdBuffer.Format("%08x%08x%08x%08x%08x"
		,pResult[0],pResult[1],pResult[2],pResult[3],pResult[4]);
	Global->Logf(LogFile_General,_T("SHA1后的密码为:%s\n"),CA2T(pwdBuffer));

	INetCenter *pInet=NULL;
	Global->GetINetCenter(&pInet);
	ATLASSERT(pInet);
	if (pInet)
	{
		MSG_RLI mRli;
		mRli.SetAccountNumber((byte*)(LPCTSTR)m_strUsername,m_strUsername.GetLength()*sizeof(TCHAR));
		mRli.SetPassword((byte*)(LPCSTR)pwdBuffer,pwdBuffer.GetLength()*sizeof(TCHAR));
		pInet->SendServer(mRli);

		_SetVerifyState(TRUE);
		SetTimer(0,5000,NULL);
	}
}
Exemplo n.º 3
0
HRESULT CLoginImpl::Login( LPCTSTR username,LPCTSTR pwd )
{
	INetCenter* pNetCenter = NULL;
	Global->GetINetCenter(&pNetCenter);
	if (pNetCenter)
	{
		MSG_RLI netMsg;
		netMsg.SetAccountNumber((const byte*)username,_tcslen(username)*sizeof(TCHAR));
		netMsg.SetPassword((const byte*)pwd,_tcslen(pwd)*sizeof(TCHAR));
		pNetCenter->SendServer(netMsg);
		return S_OK;
	}
	return E_FAIL;
}