コード例 #1
0
        /// <exception cref="System.IO.IOException"/>
        protected internal virtual char[] PromptForCredential()
        {
            CredentialShell.PasswordReader c = GetPasswordReader();
            if (c == null)
            {
                throw new IOException("No console available for prompting user.");
            }
            char[] cred = null;
            bool   noMatch;

            do
            {
                char[] newPassword1 = c.ReadPassword("Enter password: "******"Enter password again: ");
                noMatch = !Arrays.Equals(newPassword1, newPassword2);
                if (noMatch)
                {
                    if (newPassword1 != null)
                    {
                        Arrays.Fill(newPassword1, ' ');
                    }
                    c.Format("Passwords don't match. Try again.%n");
                }
                else
                {
                    cred = newPassword1;
                }
                if (newPassword2 != null)
                {
                    Arrays.Fill(newPassword2, ' ');
                }
            }while (noMatch);
            return(cred);
        }
コード例 #2
0
 public virtual CredentialShell.PasswordReader GetPasswordReader()
 {
     if (passwordReader == null)
     {
         passwordReader = new CredentialShell.PasswordReader();
     }
     return(passwordReader);
 }
コード例 #3
0
 public virtual void SetPasswordReader(CredentialShell.PasswordReader reader)
 {
     passwordReader = reader;
 }