示例#1
0
        /// <summary>
        /// Shows the saved password after confirm the master password.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonShowPassword_Click(object sender, EventArgs e)
        {
            Passwordinput pin = new Passwordinput();
            DialogResult  res = pin.ShowDialog();

            if (res == DialogResult.OK)
            {
                if (Password_helper.Check_password(pin._password))
                {
                    Passwordinput pinshow       = new Passwordinput("drive", checkBoxPim.Checked, _password, _pim);
                    DialogResult  pinshowresult = pinshow.ShowDialog();
                    if (pinshowresult == DialogResult.OK)
                    {
                        _password = pinshow._password;
                        _pim      = pinshow._pim;
                        buttonShowPassword.Enabled = true;
                    }
                    pinshow._password = null;
                    pinshow._pim      = null;
                    pinshow.Dispose();
                }
                else
                {
                    DialogResult wrongres = MessageBox.Show(this, LanguagePool.GetInstance().GetString(LanguageRegion, "MessageMasterPasswordWrong", _language), "", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                    if (wrongres == DialogResult.Retry)
                    {
                        buttonShowPassword_Click(sender, e);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Password input for encrypted xml config.
        /// </summary>
        public Password()
        {
            InitializeComponent();
            toolStripStatusLabel1.Text = "";
            fail = 1;
#if DEBUG
            toolStripStatusLabel1.Text = _language;
#endif
            //checkConfigPath();
            _confDir = Password_helper.CheckConfDir();
            FillLanguage();

            if (File.Exists(_confDir))
            {
                labelPassword_second.Visible   = false;
                textBoxPassword_second.Visible = false;
                labelOldPassword.Visible       = false;
                textBoxOldPassword.Visible     = false;
            }
            else
            {
                labelOldPassword.Visible   = false;
                textBoxOldPassword.Visible = false;
            }
        }
示例#3
0
        //private void checkConfigPath()
        //{
        //    _confDir = string.Format("{0}\\TRM.config", Application.StartupPath);

        //    try
        //    {
        //        using (FileStream fs = File.Create(Path.Combine(Application.StartupPath, Path.GetRandomFileName()), 1, FileOptions.DeleteOnClose))
        //        { }
        //    }
        //    catch
        //    {
        //        _confDir = string.Format("{0}\\TRM.config", Application.LocalUserAppDataPath);
        //    }
        //    //if (File.Exists(string.Format(_confDir)))
        //    //    return;
        //}

        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (textBoxOldPassword.Visible)
            {
                Password_helper.Password = textBoxOldPassword.Text;
                if (!Password_helper.Check_password())
                {
                    return;
                }

                if (!string.Equals(textBoxPassword_first.Text, textBoxPassword_second.Text))
                {
                    return;
                }

                Password_helper.ChangePassword(textBoxPassword_first.Text);
            }

            if (textBoxPassword_second.Visible)
            {
                if (textBoxPassword_first.Text == textBoxPassword_second.Text)
                {
                    Password_helper.Password = textBoxPassword_first.Text;
                    this.DialogResult        = DialogResult.OK;
                    Close();
                }
                return;
            }
            else
            {
                Password_helper.Password = textBoxPassword_first.Text;
                if (Password_helper.Check_password())
                {
                    this.DialogResult = DialogResult.OK;
                    Close();
                }
                else
                {
                    set_wrong();
                    return;
                }
            }
        }
示例#4
0
        /// <summary>
        /// initialized the singelton.
        /// </summary>
        /// <param name="conf"></param>
        /// <returns></returns>
        public Config Init(Config conf)
        {
            string dirPath = string.Format(Application.StartupPath);

            conf.XmlPathName = Password_helper.CheckConfDir();

            conf.GroupName = null;

            if (!conf.HasEntry(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Type))
            {
                conf.SetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Type, ConfigTrm.Mainconfig.Typename);
            }

            if (!conf.HasEntry(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Passwordtest))
            {
                conf.SetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Passwordtest, "Waldmann");
            }

            if (!conf.HasEntry(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Defaultlanguage))
            {
                conf.SetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Defaultlanguage, "E");
            }

            if (!conf.HasEntry(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Language))
            {
                conf.SetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Language,
                              Application.StartupPath + "\\language.xml");
            }

            if (conf.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Languagefile, "") !=
                Application.StartupPath + "\\language.xml")
            {
                conf.SetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Languagefile,
                              Application.StartupPath + "\\language.xml");
            }

            return(conf);
        }