KDE3Support
#include <k3passworddialog.h>
Public Types | |
enum | Types { Password, NewPassword } |
Public Member Functions | |
K3PasswordDialog (Types type, bool enableKeep, ButtonCodes extraBttn, QWidget *parent=0) | |
K3PasswordDialog (Types type, bool enableKeep, ButtonCodes extraBttn, const QString &iconName, QWidget *parent=0) | |
virtual | ~K3PasswordDialog () |
virtual void | accept () |
void | addLine (const QString &key, const QString &value) |
bool | allowEmptyPasswords () const |
void | clearPassword () |
bool | keep () const |
int | maximumPasswordLength () const |
int | minimumPasswordLength () const |
const char * | password () const |
int | passwordStrengthWarningLevel () const |
QString | prompt () const |
int | reasonablePasswordLength () const |
void | setAllowEmptyPasswords (bool allowed) |
void | setMaximumPasswordLength (int maxLength) |
void | setMinimumPasswordLength (int minLength) |
void | setPasswordStrengthWarningLevel (int warningLevel) |
void | setPrompt (const QString &prompt) |
void | setReasonablePasswordLength (int reasonableLength) |
Static Public Member Functions | |
static void | disableCoreDumps () |
static int | getNewPassword (QWidget *parent, QByteArray &password, const QString &caption, const QString &prompt) |
static int | getNewPassword (QWidget *parent, QByteArray &password, const QString &prompt) |
static int | getPassword (QWidget *parent, QByteArray &password, const QString &caption, const QString &prompt, bool *keep=0L) |
static int | getPassword (QWidget *parent, QByteArray &password, const QString &prompt, int *keep=0L) |
Protected Slots | |
void | slotKeep (bool) |
Protected Member Functions | |
virtual bool | checkPassword (const char *password) |
Detailed Description
A password input dialog.
This dialog asks the user to enter a password. The functions you're probably interested in are the static methods, getPassword() and getNewPassword().
Usage example
Security notes:
Keeping passwords in memory can be a potential security hole. You should handle this situation with care.
- You may want to use disableCoreDump() to disable core dumps. Core dumps are dangerous because they are an image of the process memory, and thus include any passwords that were in memory.
- You should delete passwords as soon as they are not needed anymore. The functions getPassword() and getNewPassword() return the password as a QCString. I believe this is safer than a QString. A QString stores its characters internally as 16-bit wide values, so conversions are needed, both for creating the QString and by using it. The temporary memory used for these conversion is probably not erased. This could lead to stray passwords in memory, even if you think you erased all of them.
Definition at line 159 of file k3passworddialog.h.
Member Enumeration Documentation
This enum distinguishes the two operation modes of this dialog:
Enumerator | |
---|---|
Password |
The user is asked to enter a password. |
NewPassword |
The user is asked to enter a password and to confirm it a second time. This is usually used when the user changes his password. |
Definition at line 168 of file k3passworddialog.h.
Constructor & Destructor Documentation
K3PasswordDialog::K3PasswordDialog | ( | Types | type, |
bool | enableKeep, | ||
ButtonCodes | extraBttn, | ||
QWidget * | parent = 0 |
||
) |
Constructs a password dialog.
- Parameters
-
type if NewPassword is given here, the dialog contains two input fields, so that the user must confirm his password and possible typos are detected immediately. enableKeep if true, a check box is shown in the dialog which allows the user to keep his password input for later. extraBttn allows to show additional buttons, KDialog. parent Passed to lower level constructor.
Definition at line 293 of file k3passworddialog.cpp.
K3PasswordDialog::K3PasswordDialog | ( | Types | type, |
bool | enableKeep, | ||
ButtonCodes | extraBttn, | ||
const QString & | iconName, | ||
QWidget * | parent = 0 |
||
) |
Construct a password dialog.
Essentially the same as above but allows the icon in the password dialog to be set via iconName
.
- Parameters
-
type if NewPassword is given here, the dialog contains two input fields, so that the user must confirm his password and possible typos are detected immediately enableKeep if true, a check box is shown in the dialog which allows the user to keep his password input for later. extraBttn allows to show additional buttons. iconName the name of the icon to be shown in the dialog. If empty, a default icon is used parent Passed to lower level constructor.
Definition at line 305 of file k3passworddialog.cpp.
|
virtual |
Destructs the password dialog.
Definition at line 442 of file k3passworddialog.cpp.
Member Function Documentation
|
virtual |
Definition at line 495 of file k3passworddialog.cpp.
Adds a line of information to the dialog.
Definition at line 467 of file k3passworddialog.cpp.
bool K3PasswordDialog::allowEmptyPasswords | ( | ) | const |
Allow empty passwords?
Definition at line 672 of file k3passworddialog.cpp.
|
protectedvirtual |
Virtual function that can be overridden to provide password checking in derived classes.
It should return true
if the password is valid, false
otherwise.
Definition at line 533 of file k3passworddialog.cpp.
void K3PasswordDialog::clearPassword | ( | ) |
Clears the password input field.
You might want to use this after the user failed to enter the correct password.
Definition at line 448 of file k3passworddialog.cpp.
|
static |
Static helper function that disables core dumps.
Definition at line 592 of file k3passworddialog.cpp.
|
static |
Pops up the dialog, asks the user for a password and returns it.
The user has to enter the password twice to make sure it was entered correctly.
- Parameters
-
parent The widget the dialog belongs too password The password is returned in this reference parameter. caption A caption for the dialog. prompt A prompt for the password. This can be a few lines of information. The text is word broken to fit nicely in the dialog.
- Returns
- Result code: Accepted or Rejected.
Definition at line 572 of file k3passworddialog.cpp.
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Deprecated:
- Use the new version with the caption argument
Definition at line 585 of file k3passworddialog.cpp.
|
static |
Pops up the dialog, asks the user for a password, and returns it.
- Parameters
-
parent The widget the dialog belongs too password The password is returned in this reference parameter. caption A caption for the dialog. prompt A prompt for the password. This can be a few lines of information. The text is word broken to fit nicely in the dialog. keep Enable/disable a checkbox controlling password keeping. If you pass a null pointer, or a pointer to the value false, the checkbox is not shown. If you pass a pointer to a true value, the checkbox is shown and the result is stored in *keep.
- Returns
- Result code: Accepted or Rejected.
Definition at line 539 of file k3passworddialog.cpp.
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Deprecated:
- Use the new version with the caption argument
Definition at line 556 of file k3passworddialog.cpp.
bool K3PasswordDialog::keep | ( | ) | const |
Returns true if the user wants to keep the password.
Definition at line 732 of file k3passworddialog.cpp.
int K3PasswordDialog::maximumPasswordLength | ( | ) | const |
Maximum acceptable password length.
Definition at line 697 of file k3passworddialog.cpp.
int K3PasswordDialog::minimumPasswordLength | ( | ) | const |
Minimum acceptable password length.
Definition at line 681 of file k3passworddialog.cpp.
const char * K3PasswordDialog::password | ( | ) | const |
Returns the password entered.
The memory is freed in the destructor, so you should make a copy.
Definition at line 727 of file k3passworddialog.cpp.
int K3PasswordDialog::passwordStrengthWarningLevel | ( | ) | const |
Password strength level below which a warning is given.
Definition at line 723 of file k3passworddialog.cpp.
QString K3PasswordDialog::prompt | ( | ) | const |
Returns the password prompt.
Definition at line 460 of file k3passworddialog.cpp.
int K3PasswordDialog::reasonablePasswordLength | ( | ) | const |
Password length that is expected to be reasonably safe.
Definition at line 712 of file k3passworddialog.cpp.
void K3PasswordDialog::setAllowEmptyPasswords | ( | bool | allowed | ) |
Allow empty passwords? - Default: false.
Definition at line 666 of file k3passworddialog.cpp.
void K3PasswordDialog::setMaximumPasswordLength | ( | int | maxLength | ) |
Maximum acceptable password length.
Limited to 199. Default: No limit, i.e. -1
- Parameters
-
maxLength The new maximum password length.
Definition at line 685 of file k3passworddialog.cpp.
void K3PasswordDialog::setMinimumPasswordLength | ( | int | minLength | ) |
Minimum acceptable password length.
Default: If empty passwords are forbidden, 1; Otherwise, 0.
- Parameters
-
minLength The new minimum password length
Definition at line 676 of file k3passworddialog.cpp.
void K3PasswordDialog::setPasswordStrengthWarningLevel | ( | int | warningLevel | ) |
Set the password strength level below which a warning is given Value is in the range 0 to 99.
Empty passwords score 0; non-empty passwords score up to 100, depending on their length and whether they contain numbers, mixed case letters and punctuation.
Default: 1 - warn if the password has no discernable strength whatsoever
- Parameters
-
warningLevel The level below which a warning should be given.
Definition at line 717 of file k3passworddialog.cpp.
void K3PasswordDialog::setPrompt | ( | const QString & | prompt | ) |
Sets the password prompt.
Definition at line 453 of file k3passworddialog.cpp.
void K3PasswordDialog::setReasonablePasswordLength | ( | int | reasonableLength | ) |
Password length that is expected to be reasonably safe.
Default: 8 - the standard UNIX password length
- Parameters
-
reasonableLength The new reasonable password length.
Definition at line 703 of file k3passworddialog.cpp.
|
protectedslot |
Definition at line 528 of file k3passworddialog.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.