Example #1
0
        /// <summary>
        /// Create the version checker instance
        /// </summary>
        public WinAuthUpdater(WinAuthConfig config)
        {
            Config = config;

            // read the update interval and last known latest version from the registry
            TimeSpan interval;

            if (TimeSpan.TryParse(Config.ReadSetting(WINAUTHREGKEY_CHECKFREQUENCY, string.Empty), out interval) == true)
            {
                _autocheckInterval = interval;
            }

            long lastCheck = 0;

            if (long.TryParse(Config.ReadSetting(WINAUTHREGKEY_LASTCHECK, null), out lastCheck) == true)
            {
                _lastCheck = new DateTime(lastCheck);
            }

            Version version;

            if (Version.TryParse(Config.ReadSetting(WINAUTHREGKEY_LATESTVERSION, string.Empty), out version) == true)
            {
                _latestVersion = version;
            }
        }
Example #2
0
        /// <summary>
        /// Load the form and pretick checkboxes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ChangePasswordForm_Load(object sender, EventArgs e)
        {
            if ((PasswordType & Authenticator.PasswordTypes.Machine) != 0 || (PasswordType & Authenticator.PasswordTypes.User) != 0)
            {
                machineCheckbox.Checked = true;
            }
            if ((PasswordType & Authenticator.PasswordTypes.User) != 0)
            {
                userCheckbox.Checked = true;
            }
            userCheckbox.Enabled = machineCheckbox.Checked;

            if ((PasswordType & Authenticator.PasswordTypes.Explicit) != 0)
            {
                passwordCheckbox.Checked = true;
                if (HasPassword == true)
                {
                    passwordField.Text = EXISTING_PASSWORD;
                    verifyField.Text   = EXISTING_PASSWORD;
                }
            }

            this.autologinCheckbox.Checked = WinAuthConfig.checkIfAutologinOnKeyPress();
            showHideAutologin();
        }
Example #3
0
 /// <summary>
 /// Clone return a new WinAuthConfig object
 /// </summary>
 /// <returns></returns>
 public object Clone()
 {
   WinAuthConfig clone = (WinAuthConfig)this.MemberwiseClone();
   // close the internal authenticator so the data is kept separate
   clone.OnConfigChanged = null;
   clone._authenticators = new List<WinAuthAuthenticator>();
   foreach (var wa in _authenticators)
   {
     clone._authenticators.Add(wa.Clone() as WinAuthAuthenticator);
   }
   clone.CurrentAuthenticator = (this.CurrentAuthenticator != null ? clone._authenticators[this._authenticators.IndexOf(this.CurrentAuthenticator)] : null);
   return clone;
 }
Example #4
0
        /// <summary>
        /// Build a diagnostics string for the current Config and any exception that had been thrown
        /// </summary>
        /// <returns>diagnostics information</returns>
        private string BuildDiagnostics()
        {
            StringBuilder diag = new StringBuilder();

            if (this.Config != null)
            {
                // clone the current config so we can extract key in case machine/user encrypted
                WinAuthConfig clone = this.Config.Clone() as WinAuthConfig;
                clone.PasswordType = Authenticator.PasswordTypes.None;

                // add the config and authenticator
                try
                {
                    StringBuilder     xml      = new StringBuilder();
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;
                    using (XmlWriter writer = XmlWriter.Create(xml, settings))
                    {
                        clone.WriteXmlString(writer);
                    }
                    diag.Append("--CURRENT CONFIG--").Append(Environment.NewLine);
                    diag.Append(xml.ToString()).Append(Environment.NewLine).Append(Environment.NewLine);
                }
                catch (Exception ex)
                {
                    diag.Append(ex.Message).Append(Environment.NewLine).Append(Environment.NewLine);
                }
            }

            // add each of the entries from the registry
            if (this.Config != null)
            {
                diag.Append("--REGISTRY--").Append(Environment.NewLine);
                diag.Append(WinAuthHelper.ReadBackupFromRegistry(this.Config)).Append(Environment.NewLine).Append(Environment.NewLine);
            }

            // add current config file
            if (string.IsNullOrEmpty(ConfigFileContents) == false)
            {
                diag.Append("--CONFIGFILE--").Append(Environment.NewLine);
                diag.Append(ConfigFileContents).Append(Environment.NewLine).Append(Environment.NewLine);
            }

            // add winauth log
            string dir        = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), WinAuthMain.APPLICATION_NAME);
            string winauthlog = Path.Combine(dir, "winauth.log");

            if (File.Exists(winauthlog) == true)
            {
                diag.Append("--WINAUTH.LOG--").Append(Environment.NewLine);
                diag.Append(File.ReadAllText(winauthlog)).Append(Environment.NewLine).Append(Environment.NewLine);
            }

            // add the exception
            if (ErrorException != null)
            {
                diag.Append("--EXCEPTION--").Append(Environment.NewLine);

                Exception ex = ErrorException;
                while (ex != null)
                {
                    diag.Append("Stack: ").Append(ex.Message).Append(Environment.NewLine).Append(new System.Diagnostics.StackTrace(ex).ToString()).Append(Environment.NewLine);
                    ex = ex.InnerException;
                }
                if (ErrorException is InvalidEncryptionException)
                {
                    diag.Append("Plain: " + ((InvalidEncryptionException)ErrorException).Plain).Append(Environment.NewLine);
                    diag.Append("Password: "******"Encrypted: " + ((InvalidEncryptionException)ErrorException).Encrypted).Append(Environment.NewLine);
                    diag.Append("Decrypted: " + ((InvalidEncryptionException)ErrorException).Decrypted).Append(Environment.NewLine);
                }
                else if (ErrorException is InvalidSecretDataException)
                {
                    diag.Append("EncType: " + ((InvalidSecretDataException)ErrorException).EncType).Append(Environment.NewLine);
                    diag.Append("Password: "******"Data: " + data).Append(Environment.NewLine);
                    }
                }
            }

            return(diag.ToString());
        }