Ejemplo n.º 1
0
		public static SecureString AskForPassword(string label, Window owner)
		{
			SecureString secureString = null;
			var passwordDialog = new PasswordDialog(label) { Owner = owner };
			if (passwordDialog.ShowDialog() == true)
			{
				secureString = new SecureString();
				foreach (var character in passwordDialog.Password)
				{
					secureString.AppendChar(character);
				}
			}

			passwordDialog.TextPassword.Password = String.Empty;

			return secureString;
		}
Ejemplo n.º 2
0
        private bool TryOpenPdf()
        {
            if (!HasPdfHeader())
            {
                return(false);
            }

            String password = null;

            do
            {
                try
                {
                    PdfViewer.Open(new MemorySource(_largeBinaryValue.Value), password);
                    TabPdf.Visibility = Visibility.Visible;
                    TabPdf.IsSelected = true;
                    return(true);
                }
                catch (MissingOrInvalidPdfPasswordException)
                {
                    if (password != null)
                    {
                        Messages.ShowError("Invalid password");
                    }

                    var securePassword = PasswordDialog.AskForPassword("PDF password: ", this);
                    if (securePassword == null)
                    {
                        return(false);
                    }

                    password = securePassword.ToString();
                }
                catch
                {
                    break;
                }
            }while (true);

            return(false);
        }
Ejemplo n.º 3
0
        public static SecureString AskForPassword(string label, Window owner)
        {
            SecureString secureString   = null;
            var          passwordDialog = new PasswordDialog(label)
            {
                Owner = owner
            };

            if (passwordDialog.ShowDialog() == true)
            {
                secureString = new SecureString();
                foreach (var character in passwordDialog.Password)
                {
                    secureString.AppendChar(character);
                }
            }

            passwordDialog.TextPassword.Password = String.Empty;

            return(secureString);
        }