Integrating authentication - now all authentication attempts fail (still work in progress).
This commit is contained in:
@@ -674,11 +674,14 @@ ClientStateStartSession::Enter(boost::shared_ptr<ClientThread> client)
|
||||
InitMessage_t *netInit = &init->GetMsg()->choice.initMessage;
|
||||
netInit->requestedVersion.major = NET_VERSION_MAJOR;
|
||||
netInit->requestedVersion.minor = NET_VERSION_MINOR;
|
||||
netInit->login.present = login_PR_anonymousLogin;
|
||||
AnonymousLogin_t *anonLogin = &netInit->login.choice.anonymousLogin;
|
||||
OCTET_STRING_fromBuf(&anonLogin->playerName,
|
||||
netInit->login.present = login_PR_authenticatedLogin;
|
||||
AuthenticatedLogin_t *authLogin = &netInit->login.choice.authenticatedLogin;
|
||||
OCTET_STRING_fromBuf(&authLogin->playerName,
|
||||
context.GetPlayerName().c_str(),
|
||||
context.GetPlayerName().length());
|
||||
OCTET_STRING_fromBuf(&authLogin->password,
|
||||
context.GetPassword().c_str(),
|
||||
context.GetPassword().length());
|
||||
//context.GetPassword();
|
||||
string avatarFile = client->GetQtToolsInterface().stringFromUtf8(context.GetAvatarFile());
|
||||
if (!avatarFile.empty())
|
||||
@@ -687,7 +690,7 @@ ClientStateStartSession::Enter(boost::shared_ptr<ClientThread> client)
|
||||
if (client->GetAvatarManager().GetHashForAvatar(avatarFile, tmpMD5))
|
||||
{
|
||||
// TODO: use sha1.
|
||||
anonLogin->avatar =
|
||||
authLogin->avatar =
|
||||
OCTET_STRING_new_fromBuf(
|
||||
&asn_DEF_OCTET_STRING,
|
||||
(const char *)tmpMD5.data,
|
||||
|
||||
@@ -38,7 +38,7 @@ ServerAcceptHelper::~ServerAcceptHelper()
|
||||
}
|
||||
|
||||
void
|
||||
ServerAcceptHelper::Listen(unsigned serverPort, bool ipv6, bool sctp, const string &pwd, const string &logDir, boost::shared_ptr<ServerLobbyThread> lobbyThread)
|
||||
ServerAcceptHelper::Listen(unsigned serverPort, bool ipv6, bool sctp, const string &/*logDir*/, boost::shared_ptr<ServerLobbyThread> lobbyThread)
|
||||
{
|
||||
m_lobbyThread = lobbyThread;
|
||||
|
||||
@@ -61,7 +61,7 @@ ServerAcceptHelper::Listen(unsigned serverPort, bool ipv6, bool sctp, const stri
|
||||
}
|
||||
|
||||
void
|
||||
ServerAcceptHelper::InternalListen(unsigned serverPort, bool ipv6, bool sctp)
|
||||
ServerAcceptHelper::InternalListen(unsigned serverPort, bool ipv6, bool /*sctp*/)
|
||||
{
|
||||
if (serverPort < 1024)
|
||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_INVALID_PORT, 0);
|
||||
|
||||
@@ -883,7 +883,7 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage
|
||||
memcpy(avatarMD5.data, authLogin->avatar->buf, MD5_DATA_SIZE);
|
||||
}
|
||||
else
|
||||
SessionError(session, ERR_NET_INVALID_PASSWORD); // TODO not yet supported
|
||||
SessionError(session, ERR_NET_INVALID_PASSWORD);
|
||||
|
||||
// Check the server password.
|
||||
/* if (!CheckPassword(initData.password))
|
||||
@@ -1268,6 +1268,7 @@ ServerLobbyThread::AuthenticationSuccess(unsigned playerId, db_id dbPlayerId)
|
||||
void
|
||||
ServerLobbyThread::AuthenticationFailure(unsigned playerId)
|
||||
{
|
||||
SessionError(m_sessionManager.GetSessionByUniquePlayerId(playerId, true), ERR_NET_INVALID_PASSWORD);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1578,7 +1579,7 @@ ServerLobbyThread::InternalCheckSessionTimeouts(SessionWrapper session)
|
||||
void
|
||||
ServerLobbyThread::SessionError(SessionWrapper session, int errorCode)
|
||||
{
|
||||
if (session.sessionData.get())
|
||||
if (session.sessionData)
|
||||
{
|
||||
SendError(session.sessionData, errorCode);
|
||||
CloseSession(session);
|
||||
|
||||
@@ -55,13 +55,13 @@ ServerManager::Init(unsigned serverPort, bool ipv6, ServerNetworkMode mode, cons
|
||||
if (mode & NETWORK_MODE_TCP)
|
||||
{
|
||||
boost::shared_ptr<ServerAcceptHelper> tcpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
|
||||
tcpAcceptHelper->Listen(serverPort, ipv6, false, pwd, logDir, m_lobbyThread);
|
||||
tcpAcceptHelper->Listen(serverPort, ipv6, false, logDir, m_lobbyThread);
|
||||
m_acceptHelperPool.push_back(tcpAcceptHelper);
|
||||
}
|
||||
/* if (mode & NETWORK_MODE_SCTP)
|
||||
{
|
||||
boost::shared_ptr<ServerAcceptHelper> sctpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
|
||||
sctpAcceptHelper->Listen(serverPort, ipv6, true, pwd, logDir, m_lobbyThread);
|
||||
sctpAcceptHelper->Listen(serverPort, ipv6, true, logDir, m_lobbyThread);
|
||||
m_acceptHelperPool.push_back(sctpAcceptHelper);
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ SessionManager::GetSessionByPlayerName(const string playerName) const
|
||||
}
|
||||
|
||||
SessionWrapper
|
||||
SessionManager::GetSessionByUniquePlayerId(unsigned uniqueId) const
|
||||
SessionManager::GetSessionByUniquePlayerId(unsigned uniqueId, bool preInitSessions) const
|
||||
{
|
||||
SessionWrapper tmpSession;
|
||||
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
|
||||
@@ -132,7 +132,7 @@ SessionManager::GetSessionByUniquePlayerId(unsigned uniqueId) const
|
||||
while (session_i != session_end)
|
||||
{
|
||||
// Check all players which are fully connected.
|
||||
if (session_i->second.sessionData->GetState() != SessionData::Init)
|
||||
if (preInitSessions || session_i->second.sessionData->GetState() != SessionData::Init)
|
||||
{
|
||||
boost::shared_ptr<PlayerData> tmpPlayer(session_i->second.playerData);
|
||||
if (!tmpPlayer.get())
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
virtual ~ServerAcceptHelper();
|
||||
|
||||
// Set the parameters.
|
||||
void Listen(unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd, const std::string &logDir,
|
||||
void Listen(unsigned serverPort, bool ipv6, bool sctp, const std::string &logDir,
|
||||
boost::shared_ptr<ServerLobbyThread> lobbyThread);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
SessionWrapper GetSessionById(SessionId id) const;
|
||||
SessionWrapper GetSessionByPlayerName(const std::string playerName) const;
|
||||
SessionWrapper GetSessionByUniquePlayerId(unsigned uniqueId) const;
|
||||
SessionWrapper GetSessionByUniquePlayerId(unsigned uniqueId, bool preInitSessions = false) const;
|
||||
|
||||
PlayerDataList GetPlayerDataList() const;
|
||||
PlayerIdList GetPlayerIdList(SessionData::State state) const;
|
||||
|
||||
Reference in New Issue
Block a user