Пример #1
0
        public void AddUser(string username, string password, int currentDplayId)
        {
            // First decrypt the password
            string decrypt = MessengerShared.EncodePassword(password, MessengerShared.ClientSideEncryptionKey);

            // Now we can add the user to the XML Schema
            this.AddUserXml(username, MessengerShared.EncodePassword(decrypt, MessengerShared.ServerSideEncryptionKey), true, currentDplayId);
        }
Пример #2
0
        private void btnOk_Click(object sender, System.EventArgs e)
        {
            // Make sure the values our filled out before continuing.
            if ((txtServer.Text == null) || (txtServer.Text == ""))
            {
                MessageBox.Show("You must enter a server name.", "No server name", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if ((txtUser.Text == null) || (txtUser.Text == ""))
            {
                MessageBox.Show("You must enter a user name.", "No user name", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if ((txtPwd.Text == null) || (txtPwd.Text == ""))
            {
                MessageBox.Show("You must enter a password.", "No password", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            // Great, save these settings, and lets move on.
            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\" + MessengerShared.ApplicationName + "\\Client", true);
            // If the key doesn't exist, create it
            if (key == null)
            {
                key = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\\" + MessengerShared.ApplicationName + "\\Client");
            }

            key.SetValue("ServerName", txtServer.Text);
            key.SetValue("Username", txtUser.Text);
            if (chkRemember.Checked)
            {
                key.SetValue("Password", txtPwd.Text);
            }
            else
            {
                key.SetValue("Password", "");
            }

            key.Close();

            parent.Select();
            parent.BringToFront();
            this.Hide();
            if ((parent.gConnected) && (parent.gServer == txtServer.Text))
            {
                // We've already connected to this server, and are still connected.  No
                // need to try and connect once more
                parent.LogonPlayer(txtUser.Text, MessengerShared.EncodePassword(txtPwd.Text));
            }
            else
            {
                // If we're connected, it's not to this server, go ahead and try to connect now
                parent.LogonPlayer(txtServer.Text, txtUser.Text, MessengerShared.EncodePassword(txtPwd.Text));
            }
        }
Пример #3
0
        public LogonTypes LogonUser(string username, string password)
        {
            XmlNode userNode = GetUserNode(username);

            if (userNode == null)
            {
                return(LogonTypes.AccountDoesNotExist);
            }

            // Now we know this user exists. Decrypt the password sent from the client
            string decrypt = MessengerShared.EncodePassword(password, MessengerShared.ClientSideEncryptionKey);

            //Now check the password vs what's stored in our xml node
            if (userNode.NextSibling.FirstChild.Value == MessengerShared.EncodePassword(decrypt, MessengerShared.ServerSideEncryptionKey))
            {
                // Great, this is the user, and the password matches
                return(LogonTypes.LogonSuccess);
            }
            else
            {
                // This guy doesn't know his own password, let'em know about it
                return(LogonTypes.InvalidPassword);
            }
        }