• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDE3Support

K3PasswordDialog Class Reference

A password input dialog. More...

#include <k3passworddialog.h>

Inheritance diagram for K3PasswordDialog:
KDialog QDialog

List of all members.

Public Types

enum  Types { Password, NewPassword }

Public Member Functions

virtual void accept ()
void addLine (const QString &key, const QString &value)
bool allowEmptyPasswords () const
void clearPassword ()
 K3PasswordDialog (Types type, bool enableKeep, ButtonCodes extraBttn, const QString &iconName, QWidget *parent=0)
 K3PasswordDialog (Types type, bool enableKeep, ButtonCodes extraBttn, QWidget *parent=0)
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)
virtual ~K3PasswordDialog ()

Static Public Member Functions

static void disableCoreDumps ()
static KDE_DEPRECATED int getNewPassword (QWidget *parent, QByteArray &password, const QString &prompt)
static int getNewPassword (QWidget *parent, QByteArray &password, const QString &caption, const QString &prompt)
static KDE_DEPRECATED int getPassword (QWidget *parent, QByteArray &password, const QString &prompt, int *keep=0L)
static int getPassword (QWidget *parent, QByteArray &password, const QString &caption, const QString &prompt, bool *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

 QCString password;
 int result = K3PasswordDialog::getPassword(parent, password, i18n("Prompt message"));
 if (result == K3PasswordDialog::Accepted)
     use(password);
k3passworddialog.png

KDE Password Dialog

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.
Author:
Geert Jansen <jansen@kde.org>
Deprecated:
use KPasswordDialog or KNewPasswordDialog

Definition at line 159 of file k3passworddialog.h.


Member Enumeration Documentation

enum K3PasswordDialog::Types

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 306 of file k3passworddialog.cpp.

K3PasswordDialog::~K3PasswordDialog (  )  [virtual]

Destructs the password dialog.

Definition at line 444 of file k3passworddialog.cpp.


Member Function Documentation

void K3PasswordDialog::accept (  )  [virtual]

Definition at line 497 of file k3passworddialog.cpp.

void K3PasswordDialog::addLine ( const QString &  key,
const QString &  value 
)

Adds a line of information to the dialog.

Definition at line 469 of file k3passworddialog.cpp.

bool K3PasswordDialog::allowEmptyPasswords (  )  const

Allow empty passwords?

Definition at line 674 of file k3passworddialog.cpp.

bool K3PasswordDialog::checkPassword ( const char *  password  )  [protected, virtual]

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 535 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 450 of file k3passworddialog.cpp.

void K3PasswordDialog::disableCoreDumps (  )  [static]

Static helper function that disables core dumps.

Definition at line 594 of file k3passworddialog.cpp.

int K3PasswordDialog::getNewPassword ( QWidget *  parent,
QByteArray &  password,
const QString &  prompt 
) [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 587 of file k3passworddialog.cpp.

int K3PasswordDialog::getNewPassword ( QWidget *  parent,
QByteArray &  password,
const QString &  caption,
const QString &  prompt 
) [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 574 of file k3passworddialog.cpp.

int K3PasswordDialog::getPassword ( QWidget *  parent,
QByteArray &  password,
const QString &  prompt,
int *  keep = 0L 
) [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 558 of file k3passworddialog.cpp.

int K3PasswordDialog::getPassword ( QWidget *  parent,
QByteArray &  password,
const QString &  caption,
const QString &  prompt,
bool *  keep = 0L 
) [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 541 of file k3passworddialog.cpp.

bool K3PasswordDialog::keep (  )  const

Returns true if the user wants to keep the password.

Definition at line 734 of file k3passworddialog.cpp.

int K3PasswordDialog::maximumPasswordLength (  )  const

Maximum acceptable password length.

Definition at line 699 of file k3passworddialog.cpp.

int K3PasswordDialog::minimumPasswordLength (  )  const

Minimum acceptable password length.

Definition at line 683 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 729 of file k3passworddialog.cpp.

int K3PasswordDialog::passwordStrengthWarningLevel (  )  const

Password strength level below which a warning is given.

Definition at line 725 of file k3passworddialog.cpp.

QString K3PasswordDialog::prompt (  )  const

Returns the password prompt.

Definition at line 462 of file k3passworddialog.cpp.

int K3PasswordDialog::reasonablePasswordLength (  )  const

Password length that is expected to be reasonably safe.

Definition at line 714 of file k3passworddialog.cpp.

void K3PasswordDialog::setAllowEmptyPasswords ( bool  allowed  ) 

Allow empty passwords? - Default: false.

Definition at line 668 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 687 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 678 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 719 of file k3passworddialog.cpp.

void K3PasswordDialog::setPrompt ( const QString &  prompt  ) 

Sets the password prompt.

Definition at line 455 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 705 of file k3passworddialog.cpp.

void K3PasswordDialog::slotKeep ( bool  keep  )  [protected, slot]

Definition at line 530 of file k3passworddialog.cpp.


The documentation for this class was generated from the following files:
  • k3passworddialog.h
  • k3passworddialog.cpp

KDE3Support

Skip menu "KDE3Support"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal