Пример #1
0
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     User u = new User() { Username = txtUsername.Text };
     u.SetPasswordFromPlaintext(txtPassword.Password);
     users.Add(u);
     txtUsername.Text = "";
     txtPassword.Password = "";
 }
Пример #2
0
        /// <summary>
        /// Generate a QR Barcode with the server information
        /// </summary>
        private void GenerateBarcode(User auth)
        {
            try
            {
                ServerDescription desc = new ServerDescription();
                desc.HardwareAddresses = String.Join(";", GetHardwareAddresses());
                desc.Addresses = String.Join(";", GetIPAddresses());
                desc.Name = GetServiceName();
                desc.QRVersion = 1;

                desc.Services = new List<ServiceDescription>();
                foreach (var srv in Installation.GetInstalledServices())
                {
                    var srvdesc = new ServiceDescription()
                    {
                        Name = srv.ServiceName.ToString(),
                        Port = srv.Port
                    };

                    if (auth != null)
                    {
                        string usernameOut, passwordOut;
                        srv.GetUsernameAndPassword(auth, out usernameOut, out passwordOut);
                        srvdesc.User = usernameOut;
                        srvdesc.Password = passwordOut;
                    }

                    desc.Services.Add(srvdesc);
                }

                Bitmap bm = QRCodeGenerator.Generate(desc.ToJSON());
                imgQRCode.Source = bm.ToWpfBitmap();
            }
            catch (Exception ex)
            {
                Log.Error("Error generating barcode", ex);
            }
        }
Пример #3
0
 public override void GetUsernameAndPassword(User user, out string username, out string password)
 {
     username = DecryptConfig(Mediaportal.ReadSectionFromConfigFile("WifiRemote")["username"]);
     password = DecryptConfig(Mediaportal.ReadSectionFromConfigFile("WifiRemote")["password"]);
 }
Пример #4
0
        /// <summary>
        /// Generate a QR Barcode with the server information
        /// </summary>
        private void GenerateBarcode(User auth)
        {
            try
            {
                ServerDescription desc = new ServerDescription();
                desc.GeneratorApp = "ServiceConfigurator";
                desc.ServiceType = "Client";

                desc.Port = Configuration.Services.Port;
                desc.Name = Configuration.Services.BonjourName;
                desc.HardwareAddresses = GetHardwareAddresses();
                desc.Hostname = GetServiceName();

                IPHostEntry host;
                String localIP = "?";
                StringBuilder localIPs = new StringBuilder();
                host = Dns.GetHostEntry(Dns.GetHostName());
                foreach (IPAddress ip in host.AddressList)
                {
                    if (ip.AddressFamily == AddressFamily.InterNetwork)
                    {
                        // Single address field
                        localIP = ip.ToString();

                        // Multiple addresses field
                        if (localIPs.Length > 0)
                        {
                            localIPs.Append(";");
                        }

                        localIPs.Append(ip.ToString());
                    }
                }

                desc.Addresses = (localIPs.Length > 0) ? localIPs.ToString() : "?";

                if (auth != null)
                {
                    desc.User = auth.Username;
                    desc.Password = auth.Password;
                    desc.AuthOptions = 1;
                }

                Bitmap bm = QRCodeGenerator.Generate(desc.ToJSON());
                imgQRCode.Source = bm.ToWpfBitmap();
            }
            catch (Exception ex)
            {
                Log.Error("Error generating barcode", ex);
            }
        }