Exemple #1
0
        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;
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(txtUsername.Text) || String.IsNullOrEmpty(txtPassword.Password))
            {
                MessageBox.Show(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();
        }
 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
     );
 }
 public WifiRemoteClient(User authentication, String address, int port)
 {
     this.AuthenticationInformation = authentication;
     this.Address = address;
     this.Port = port;
 }
 public AccessRequestingClient(User authentication, String address, int port)
     : base(authentication, address, port)
 {
 }
        /// <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.NetbiosName = System.Environment.MachineName;
                desc.ExternalIp = ExternalAddress.GetAddress();

                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,
                        Port = srv.Port
                    };

                    if (auth != null)
                    {
                        srvdesc.User = (srv.Service == "WifiRemote" ? wifiRemoteAuth : auth).Username;
                        srvdesc.Password = (srv.Service == "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;
            }
        }