Exemplo n.º 1
0
 public static void HandleIdentificationMessage(IdentificationMessage message, AuthClient client)
 {
     lock (LockObject)
     {
         Account account          = AccountsProvider.DecryptCredentialsFromClient(client, message.sessionOptionalSalt.ToString(), message.credentials);
         Account theoricalAccount = AccountsProvider.GetAccountFromDb(account.Username);
         if (theoricalAccount == null)
         {
             client.Send(new IdentificationFailedMessage((sbyte)IdentificationFailureReasonEnum.WRONG_CREDENTIALS));
             return;
         }
         if (theoricalAccount.Password == null || theoricalAccount.Password != account.Password)
         {
             client.Send(new IdentificationFailedMessage((sbyte)IdentificationFailureReasonEnum.WRONG_CREDENTIALS));
             return;
         }
         if (theoricalAccount.Banned || BanIpRecord.IsBanned(client.SSyncClient.Ip.Split(':')[0]))
         {
             client.Send(new IdentificationFailedMessage((sbyte)IdentificationFailureReasonEnum.BANNED));
             return;
         }
         client.Account = theoricalAccount;
         AccountInformationsRecord.CheckAccountInformations(client.Account.Id, ConfigurationManager.Instance.StartBankKamas);
         if (client.Account.Nickname == string.Empty || client.Account.Nickname == null)
         {
             client.Send(new NicknameRegistrationMessage());
             return;
         }
         Login(client, message.autoconnect);
     }
 }
        /// <summary>
        /// Procède a l'identification d'un client.
        /// </summary>
        /// <param name="client"></param>
        public static void ProcessIdentification(AuthClient client)
        {
            client.Send(new CredentialsAcknowledgementMessage());

            if (!client.IsVersionUpToDate())
            {
                client.Send(new IdentificationFailedForBadVersionMessage((sbyte)IdentificationFailureReasonEnum.BAD_VERSION, AuthConfiguration.Instance.GetVersionExtended()));

                return;
            }

            BigEndianReader reader   = new BigEndianReader(client.IdentificationMessage.credentials.Select(x => (byte)x).ToArray());
            string          username = reader.ReadUTF();
            string          password = reader.ReadUTF();

            client.AesKey = reader.ReadBytes(32);

            AccountData account = AccountRecord.GetAccountByUsername(username);

            if (account == null || account.Password != password)
            {
                client.Send(new IdentificationFailedMessage((sbyte)IdentificationFailureReasonEnum.WRONG_CREDENTIALS));

                return;
            }

            if (account.Banned || BanIpRecord.IsBanned(client.Ip))
            {
                client.Send(new IdentificationFailedMessage((sbyte)IdentificationFailureReasonEnum.BANNED));

                return;
            }

            client.Account = account;

            if (client.Account.Nickname == null || client.Account.Nickname == string.Empty)
            {
                client.Send(new NicknameRegistrationMessage());

                return;
            }

            Login(client, client.IdentificationMessage.autoconnect);
        }