Esempio n. 1
0
		/// <summary>
		/// Common function used by all the various connection cases to install the eap config and actually connect
		/// </summary>
		/// <param name="eapConfig">Configuration to install, must have all credentials set</param>
		private async Task ConnectAndUpdateUI(EapConfig eapConfig)
		{
			Debug.Assert(
				!eapConfig.NeedsClientCertificatePassphrase && !eapConfig.NeedsLoginCredentials,
				"Cannot configure EAP config that still needs credentials"
			);

			if (!EduroamNetwork.IsWlanServiceApiAvailable())
			{
				// TODO: update this when wired x802 is a thing
				tbStatus.Text = "Wireless is unavailable on this computer";

				mainWindow.btnNext.Content = "Connect";

				return;
			}
			pbCertBrowserPassword.IsEnabled = false;
			try
			{
				InstallEapConfig(eapConfig);

				// Any profile installed by us must also be removed by us when it is not needed anymore
				// so install the geteduroam app when we have installed a profile
				_ = Task.Run(App.Installer.EnsureIsInstalled); // TODO: must be ensured to complete before the user exits

				bool connected = await TryToConnect();
				if (connected)
				{
					tbStatus.Text = "You are now connected to eduroam.\n\nPress Close to exit the wizard.";
					mainWindow.btnNext.Content = "Close";
				}
				else
				{
					if (EduroamNetwork.IsNetworkInRange(eapConfig))
					{
						tbStatus.Text = "Everything is configured!\nUnable to connect to eduroam.";
					}
					else
					{
						// Hs2 is not enumerable
						tbStatus.Text = "Everything is configured!\nUnable to connect to eduroam, you're probably out of coverage.";
					}
					mainWindow.btnNext.Content = "Connect";
				}
			}
			catch (EduroamAppUserException ex)
			{
				tbStatus.Text = "Unknown error while installing profile\n\n" + ex.UserFacingMessage;

				mainWindow.btnNext.Content = "Connect";
			}
			catch (Exception ex)
			{
				tbStatus.Text = "Unknown error while installing profile\n\n" + ex.Message;

				mainWindow.btnNext.Content = "Connect";
			}
			pbCertBrowserPassword.IsEnabled = true;
		}
Esempio n. 2
0
 public static bool CheckIfEapConfigIsSupported(EapConfig eapConfig)
 {
     if (!EduroamNetwork.IsEapConfigSupported(eapConfig))
     {
         MessageBox.Show(
             "The profile you have selected is not supported by this application.",
             "No supported authentification method was found.",
             MessageBoxButton.OK, MessageBoxImage.Exclamation);
         return(false);
     }
     return(true);
 }
Esempio n. 3
0
            /// <summary>
            /// Will install the authMethod as a profile
            /// Having run InstallCertificates successfully before calling this is a prerequisite
            /// If this returns FALSE: It means there is a missing TLS client certificate left to be installed
            /// </summary>
            /// <returns>True if the profile was installed on any interface</returns>
            public void InstallWLANProfile()
            {
                if (!HasInstalledCertificates)
                {
                    throw new EduroamAppUserException("missing certificates",
                                                      "You must first install certificates with InstallCertificates");
                }

                // Install wlan profile
                foreach (var network in EduroamNetwork.GetAll(AuthMethod.EapConfig))
                {
                    Debug.WriteLine("Install profile {0}", network.ProfileName);
                    network.InstallProfiles(AuthMethod, forAllUsers: true);
                }
            }
Esempio n. 4
0
        /// <summary>
        /// Checks if an EAP-config file exists in the same folder as the executable.
        /// If the installed and a EAP-config was bundled in a EXE using 7z, then this case will trigger
        /// </summary>
        /// <returns>EapConfig or null</returns>
        public static EapConfig GetBundledEapConfig()
        {
            string exeLocation = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            string[] files = Directory.GetFiles(exeLocation, "*.eap-config");

            if (!files.Any())
            {
                return(null);
            }
            try
            {
                string eapPath   = files.First();
                string eapString = File.ReadAllText(eapPath);
                var    eapconfig = EapConfig.FromXmlData(eapString);

                return(EduroamNetwork.IsEapConfigSupported(eapconfig)
                                        ? eapconfig
                                        : null);
            }
            catch (XmlException) { }
            return(null);
        }