Ejemplo n.º 1
0
 /// <summary>
 /// Uninstalls the installed WLAN profile
 /// </summary>
 /// <param name="omitRootCa">Keep the installed root certificate</param>
 /// <remarks>
 /// On one hand, keeping the root is a security risk,
 /// on the other, it's a hassle for the user to get too many prompts
 /// while reinstalling a profile.
 /// </remarks>
 public static void RemoveSettings(bool omitRootCa = false)
 {
     LetsWifi.WipeTokens();
     ConnectToEduroam.RemoveAllWLANProfiles();
     CertificateStore.UninstallAllInstalledCertificates(omitRootCa: omitRootCa);
     PersistingStore.IdentityProvider = null;
 }
        /// <summary>
        /// Loads relevant elements of the page
        /// </summary>
        private void Load()
        {
            tbInfo.Text = "In order to continue you have to install the listed certificates";

            installers = ConnectToEduroam.EnumerateCAInstallers(eapConfig).ToList();
            foreach (ConnectToEduroam.CertificateInstaller installer in installers)
            {
                AddSeparator();
                AddCertGrid(installer);
            }
            // remove the first separator
            if (stpCerts.Children.Count != 0)
            {
                stpCerts.Children.RemoveAt(0);
            }

            VerifyNextButton();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// downloads eap config based on profileId
        /// seperated into its own function as this can happen either through
        /// user selecting a profile or a profile being autoselected
        /// </summary>
        /// <param name="profileId"></param>
        /// <param name="eapConfigXml"></param>
        /// <param name="skipOverview"></param>
        /// <returns>True if function navigated somewhere</returns>
        /// <exception cref="XmlException">Parsing eap-config failed</exception>
        private async Task <bool> HandleProfileSelect(string profileId, string eapConfigXml = null, bool skipOverview = false)
        {
            LoadPageLoading();
            IdentityProviderProfile profile = null;

            if (!string.IsNullOrEmpty(profileId) &&
                !string.IsNullOrEmpty(eapConfigXml))
            {
                // TODO: ^perhaps reuse logic from PersistingStore.IsReinstallable
                Debug.WriteLine(nameof(eapConfigXml) + " was set", category: nameof(HandleProfileSelect));

                eapConfig           = EapConfig.FromXmlData(eapConfigXml);
                eapConfig.ProfileId = profileId;
            }
            else
            {
                Debug.WriteLine(nameof(eapConfigXml) + " was not set", category: nameof(HandleProfileSelect));

                profile = IdpDownloader.GetProfileFromId(profileId);
                try
                {
                    eapConfig = await DownloadEapConfig(profile);
                }
                catch (EduroamAppUserException ex)                 // TODO: catch this on some higher level
                {
                    MessageBox.Show(
                        ex.UserFacingMessage,
                        caption: "geteduroam - Exception");
                    eapConfig = null;
                }
            }

            // reenable buttons after LoadPageLoading() disables them
            btnBack.IsEnabled = true;
            btnNext.IsEnabled = true;

            if (eapConfig != null)
            {
                if (!CheckIfEapConfigIsSupported(eapConfig))
                {
                    return(false);
                }

                if (HasInfo(eapConfig) && !skipOverview)
                {
                    LoadPageProfileOverview();
                    return(true);
                }
                if (ConnectToEduroam.EnumerateCAInstallers(eapConfig)
                    .Any(installer => installer.IsInstalledByUs || !installer.IsInstalled))
                {
                    LoadPageCertificateOverview();
                    return(true);
                }

                LoadPageLogin();
                return(true);
            }
            else if (!string.IsNullOrEmpty(profile?.redirect))
            {
                // TODO: add option to go to selectmethod from redirect
                LoadPageRedirect(new Uri(profile.redirect));
                return(true);
            }
            else if (profile?.oauth ?? false)
            {
                LoadPageOAuthWait(profile);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Logic for navigating to forward
        /// </summary>
        /// <exception cref="XmlException">TODO catch</exception>
        public async void NextPage()
        {
            // adds current form to history for easy backtracking
            historyFormId.Add(currentFormId);
            switch (currentFormId)
            {
            case FormId.InstalledProfile:
                LoadPageMainMenu();
                break;

            case FormId.MainMenu:
                if (LocalEapConfig != null)
                {
                    eapConfig = LocalEapConfig;
                    LoadPageProfileOverview();
                    break;
                }
                if (pageMainMenu.UseExtracted)
                {
                    eapConfig = ExtractedEapConfig;
                    LoadPageProfileOverview();
                    break;
                }

                LoadPageSelectInstitution();
                break;

            case FormId.SelectInstitution:
                var profiles = IdpDownloader.GetIdentityProviderProfiles(pageSelectInstitution.IdProviderId);
                if (profiles.Count == 1)                         // skip the profile select and go with the first one
                {
                    string autoProfileId = profiles.FirstOrDefault().Id;
                    if (!string.IsNullOrEmpty(autoProfileId))
                    {
                        // if profile could not be handled then return to form
                        if (!await HandleProfileSelect(autoProfileId))
                        {
                            LoadPageSelectInstitution(refresh: false);
                        }
                        break;
                    }
                }
                LoadPageSelectProfile();
                break;

            case FormId.SelectProfile:
                string profileId = pageSelectProfile.ProfileId;
                // if profile could not be handled then return to form
                if (!await HandleProfileSelect(profileId))
                {
                    LoadPageSelectProfile(refresh: false);
                }
                break;

            case FormId.ProfileOverview:
                if (pageProfileOverview.ShowTou)
                {
                    LoadPageTermsOfUse();
                    break;
                }
                if (ConnectToEduroam.EnumerateCAInstallers(eapConfig)
                    .Any(installer => installer.IsInstalledByUs || !installer.IsInstalled))
                {
                    LoadPageCertificateOverview();
                    break;
                }

                LoadPageLogin();
                break;

            case FormId.TermsOfUse:
                historyFormId.Remove(currentFormId);
                PreviousPage();
                break;

            case FormId.CertificateOverview:
                LoadPageLogin();
                break;

            case FormId.Login:
                if (pageLogin.IsConnected)
                {
                    if (!App.Installer.IsRunningInInstallLocation)
                    {
                        Shutdown();
                    }
                    else
                    {
                        Hide();
                        LoadPageInstalledProfile();
                        historyFormId.Clear();
                    }
                    break;
                }
                pageLogin.ConnectClick();
                break;

            case FormId.Redirect:
                break;
            }


            // removes current form from history if it gets added twice
            if (historyFormId.LastOrDefault() == currentFormId)
            {
                historyFormId.RemoveAt(historyFormId.Count - 1);
            }

            UpdateBackButton();
        }
Ejemplo n.º 5
0
		private void InstallEapConfig(EapConfig eapConfig)
		{
			if (!MainWindow.CheckIfEapConfigIsSupported(eapConfig)) // should have been caught earlier, but check here too for sanity
			{
				throw new Exception("Invalid eap config provided, this should not happen, please report a bug.");
			}

			ConnectToEduroam.RemoveAllWLANProfiles();
			mainWindow.ProfileCondition = MainWindow.ProfileStatus.NoneConfigured;

			bool success = false;
			Exception lastException = null;
			// Install EAP config as a profile
			foreach (var authMethod in eapConfig.SupportedAuthenticationMethods)
			{
				var authMethodInstaller = new ConnectToEduroam.EapAuthMethodInstaller(authMethod);

				// install intermediate CAs and client certificates
				// if user refuses to install a root CA (should never be prompted to at this stage), abort
				try
				{
					authMethodInstaller.InstallCertificates();
				}
				catch (UserAbortException ex)
				{
					lastException = new Exception("Required CA certificate was not installed, this should not happen, please report a bug", ex);
					// failed, try the next method
					continue;
				}
				catch (Exception e)
				{
					lastException = e;
					// failed, try the next method
					continue;
				}

				// Everything is now in order, install the profile!
				try
				{
					authMethodInstaller.InstallWLANProfile();
				}
				catch (Exception e)
				{
					lastException = e;
					// failed, try the next method
					continue;
				}

				// check if we need to wait for the certificate to become valid
				certValid = authMethodInstaller.GetTimeWhenValid().From;
				if (DateTime.Now <= certValid)
				{
					// dispatch the event which creates the clock the end user sees
					dispatcherTimer_Tick(dispatcherTimer, new EventArgs());
					dispatcherTimer.Start();
					throw new Exception("Client credential is not valid yet");
				}

				success = true;
				break;
			}

			if (success)
			{
				mainWindow.ProfileCondition = MainWindow.ProfileStatus.Configured;
			}
			else if (lastException != null)
			{
				throw lastException;
			}
			else
			{
				throw new Exception(
					"No supported authentication method found in current profile, please report a bug.");
			}
		}