コード例 #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
ファイル: WifiRemote.cs プロジェクト: bbmjen/MPExtended
        public static User GetAuthentication()
        {
            User user = new User();

            try
            {
                user.Username = DecryptConfig(Mediaportal.ReadSectionFromConfigFile("WifiRemote")["username"]);
                user.SetPasswordFromPlaintext(DecryptConfig(Mediaportal.ReadSectionFromConfigFile("WifiRemote")["password"]));
            }
            catch (Exception)
            {
                user.Username = String.Empty;
                user.SetPasswordFromPlaintext(String.Empty);
            }

            return user;
        }
コード例 #3
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(txtUsername.Text) || String.IsNullOrEmpty(txtPassword.Password))
            {
                MessageBox.Show(Strings.UI.UserMustHaveNameAndPassword, "MPExtended", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            User u = new User() { Username = txtUsername.Text };
            u.SetPasswordFromPlaintext(txtPassword.Password);
            users.Add(u);
            txtUsername.Text = "";
            txtPassword.Password = "";

            // Given that we have an Add button here, the user expects that the account might directly work. So, save the
            // new account directly. Probably not the nicest way by directly calling the callback, but it works, so whatever.
            TabClosed();
        }
コード例 #4
0
 private MembershipUser GetMembershipUser(User user, bool userIsOnline)
 {
     return new MembershipUser(
         this.Name,
         user.Username,
         null,
         null,
         null,
         null,
         true,
         false,
         DateTime.Now,
         DateTime.Now,
         DateTime.Now,
         DateTime.Now,
         DateTime.Now
     );
 }
コード例 #5
0
ファイル: TabBarcode.xaml.cs プロジェクト: bbmjen/MPExtended
        /// <summary>
        /// Generate a QR Barcode with the server information
        /// </summary>
        private BitmapSource GenerateBarcode(User auth)
        {
            try
            {
                ServerDescription desc = new ServerDescription();

                desc.QRVersion = QR_VERSION;
                desc.GeneratorApp = GENERATOR_APP;

                desc.HardwareAddresses = String.Join(";", NetworkInformation.GetMACAddresses());
                desc.Addresses = String.Join(";", NetworkInformation.GetIPAddresses());
                desc.Name = Configuration.Services.GetServiceName();

                desc.Services = new List<ServiceDescription>();
                User wifiRemoteAuth = WifiRemote.IsInstalled ? WifiRemote.GetAuthentication() : null;
                foreach (var srv in Installation.GetInstalledServices())
                {
                    var srvdesc = new ServiceDescription()
                    {
                        Name = srv.Service.ToString(),
                        Port = srv.Port
                    };

                    if (auth != null)
                    {
                        srvdesc.User = (srv.Service == MPExtendedService.WifiRemote ? wifiRemoteAuth : auth).Username;
                        srvdesc.Password = (srv.Service == MPExtendedService.WifiRemote ? wifiRemoteAuth : auth).GetPassword();
                    }

                    desc.Services.Add(srvdesc);
                }

                Bitmap bm = QRCodeGenerator.Generate(desc.ToJSON());
                return bm.ToWpfBitmap();
            }
            catch (Exception ex)
            {
                Log.Error("Error generating barcode", ex);
                return null;
            }
        }
コード例 #6
0
        /// <summary>
        /// Generate a QR Barcode with the server information
        /// </summary>
        private BitmapSource GenerateBarcode(User auth)
        {
            try
            {
                ServerDescription desc = new ServerDescription();
                desc.HardwareAddresses = String.Join(";", NetworkInformation.GetMACAddresses());
                desc.Addresses = String.Join(";", NetworkInformation.GetIPAddresses());
                desc.Name = GetServiceName();
                desc.QRVersion = 1;

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

                    if (auth != null)
                    {
                        srvdesc.User = auth.Username;
                        srvdesc.Password = auth.GetPassword();
                    }

                    desc.Services.Add(srvdesc);
                }

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