Beispiel #1
0
        private void LoadUserAuthenticate()
        {
            if (File.Exists(CORE.USER_AUTH_PATH))
            {
                using (Stream UserAuthenticationStream = File.OpenRead(CORE.USER_AUTH_PATH))
                {
                    try { CORE.UpdateUserAuthentication(UserAuthenticationStream.Deserialize <UserAuthenticationObject>(SerializeType: SerializeType.XML)); }
                    catch { }
                }
            }

            if (UserAuthenticationObject.Equals(CORE.UserAuthentication, null))
            {
                CORE.UpdateUserAuthentication(new UserAuthenticationObject());
            }

            CancellationTokenSource cts = new CancellationTokenSource();

            foreach (UserPluginAuthenticationObject upa in CORE.UserAuthentication.UserPluginAuthentications)
            {
                try
                {
                    IExtension extension = CORE.Extensions[upa.PluginName, upa.PluginLanguage];
                    extension.Authenticate(new System.Net.NetworkCredential(upa.Username, upa.Password), cts.Token, null);
                }
                catch
                {
                    MessageBox.Show(String.Format("There was an error decoding {0} ({1}). Please reauthenticate.", upa.PluginName, upa.PluginLanguage));
                }
            }
            SaveUserAuthentication();
        }