KPasswordDialog Class Reference
A password input dialog. More...
#include <kpassdlg.h>
Inheritance diagram for KPasswordDialog:


Public Types | |
enum | Types { Password, NewPassword } |
Public Member Functions | |
KPasswordDialog (Types type, bool enableKeep, int extraBttn, QWidget *parent=0, const char *name=0) | |
KPasswordDialog (int type, QString prompt, bool enableKeep=false, int extraBttn=0) KDE_DEPRECATED | |
KPasswordDialog (Types type, bool enableKeep, int extraBttn, const QString &iconName, QWidget *parent=0, const char *name=0) | |
virtual | ~KPasswordDialog () |
void | setPrompt (QString prompt) |
QString | prompt () const |
void | addLine (QString key, QString value) |
void | setAllowEmptyPasswords (bool allowed) |
bool | allowEmptyPasswords () const |
void | setMinimumPasswordLength (int minLength) |
int | minimumPasswordLength () const |
void | setMaximumPasswordLength (int maxLength) |
int | maximumPasswordLength () const |
void | setReasonablePasswordLength (int reasonableLength) |
int | reasonablePasswordLength () const |
void | setPasswordStrengthWarningLevel (int warningLevel) |
int | passwordStrengthWarningLevel () const |
const char * | password () const |
void | clearPassword () |
bool | keep () const |
Static Public Member Functions | |
int | getPassword (QCString &password, QString prompt, int *keep=0L) |
int | getNewPassword (QCString &password, QString prompt) |
void | disableCoreDumps () |
Protected Slots | |
void | slotOk () |
void | slotCancel () |
void | slotKeep (bool) |
Protected Member Functions | |
virtual bool | checkPassword (const char *) |
virtual void | virtual_hook (int id, void *data) |
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
QCString password; int result = KPasswordDialog::getPassword(password, i18n("Prompt message")); if (result == KPasswordDialog::Accepted) use(password);

KDE Password Dialog
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.
- Author:
- Geert Jansen <jansen@kde.org>
Definition at line 166 of file kpassdlg.h.
Member Enumeration Documentation
|
This enum distinguishes the two operation modes of this dialog:.
Definition at line 175 of file kpassdlg.h. |
Constructor & Destructor Documentation
|
Constructs a password dialog.
Definition at line 300 of file kpassdlg.cpp. Referenced by getNewPassword(), and getPassword(). |
|
Definition at line 321 of file kpassdlg.cpp. References setPrompt(). |
|
Construct a password dialog.
Essentially the same as above but allows the icon in the password dialog to be set via
Definition at line 309 of file kpassdlg.cpp. |
|
Destructs the password dialog.
Definition at line 454 of file kpassdlg.cpp. |
Member Function Documentation
|
Sets the password prompt.
Definition at line 466 of file kpassdlg.cpp. Referenced by KPasswordDialog(). |
|
Returns the password prompt.
Definition at line 473 of file kpassdlg.cpp. |
|
Adds a line of information to the dialog.
Definition at line 481 of file kpassdlg.cpp. |
|
Allow empty passwords? - Default: false
Definition at line 657 of file kpassdlg.cpp. References allowEmptyPasswords(). |
|
Allow empty passwords?
Definition at line 663 of file kpassdlg.cpp. Referenced by setAllowEmptyPasswords(). |
|
Minimum acceptable password length. Default: If empty passwords are forbidden, 1; Otherwise, 0.
Definition at line 667 of file kpassdlg.cpp. References minimumPasswordLength(). |
|
Minimum acceptable password length.
Definition at line 672 of file kpassdlg.cpp. Referenced by setMinimumPasswordLength(). |
|
Maximum acceptable password length. Limited to 199. Default: No limit, i.e. -1
Definition at line 676 of file kpassdlg.cpp. References maximumPasswordLength(), and KPasswordEdit::setMaxPasswordLength(). |
|
Maximum acceptable password length.
Definition at line 688 of file kpassdlg.cpp. Referenced by setMaximumPasswordLength(), and setReasonablePasswordLength(). |
|
Password length that is expected to be reasonably safe. Default: 8 - the standard UNIX password length
Definition at line 694 of file kpassdlg.cpp. References maximumPasswordLength(). |
|
Password length that is expected to be reasonably safe.
Definition at line 703 of file kpassdlg.cpp. |
|
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
Definition at line 708 of file kpassdlg.cpp. |
|
Password strength level below which a warning is given
Definition at line 714 of file kpassdlg.cpp. |
|
Returns the password entered. The memory is freed in the destructor, so you should make a copy. Definition at line 334 of file kpassdlg.h. Referenced by getNewPassword(), and getPassword(). |
|
Clears the password input field. You might want to use this after the user failed to enter the correct password.
Definition at line 460 of file kpassdlg.cpp. References KPasswordEdit::erase(). |
|
Returns true if the user wants to keep the password.
Definition at line 346 of file kpassdlg.h. Referenced by getPassword(). |
|
Pops up the dialog, asks the user for a password, and returns it.
Definition at line 552 of file kpassdlg.cpp. References keep(), KPasswordDialog(), password(), and Password. |
|
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.
Definition at line 569 of file kpassdlg.cpp. References KPasswordDialog(), NewPassword, and password(). |
|
Static helper function that disables core dumps.
Definition at line 581 of file kpassdlg.cpp. |
|
Activated when the Ok button has been clicked. The QDialog::accept() is activated. Reimplemented from KDialogBase. Definition at line 508 of file kpassdlg.cpp. References checkPassword(), KPasswordEdit::password(), KMessageBox::sorry(), and KMessageBox::warningYesNo(). |
|
Activated when the Cancel button has been clicked. The QDialog::reject() is activated in regular mode and QDialog::done( Cancel ) when in message box mode. Reimplemented from KDialogBase. Definition at line 539 of file kpassdlg.cpp. |
|
Virtual function that can be overridden to provide password checking in derived classes.
It should return Definition at line 391 of file kpassdlg.h. Referenced by slotOk(). |
The documentation for this class was generated from the following files: