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

KDE3Support

Public Types | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | List of all members
K3PasswordDialog Class Reference

#include <k3passworddialog.h>

Inheritance diagram for K3PasswordDialog:
Inheritance graph
[legend]

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

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 janse.nosp@m.n@kd.nosp@m.e.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
typeif NewPassword is given here, the dialog contains two input fields, so that the user must confirm his password and possible typos are detected immediately.
enableKeepif true, a check box is shown in the dialog which allows the user to keep his password input for later.
extraBttnallows to show additional buttons, KDialog.
parentPassed 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
typeif NewPassword is given here, the dialog contains two input fields, so that the user must confirm his password and possible typos are detected immediately
enableKeepif true, a check box is shown in the dialog which allows the user to keep his password input for later.
extraBttnallows to show additional buttons.
iconNamethe name of the icon to be shown in the dialog. If empty, a default icon is used
parentPassed to lower level constructor.

Definition at line 305 of file k3passworddialog.cpp.

K3PasswordDialog::~K3PasswordDialog ( )
virtual

Destructs the password dialog.

Definition at line 442 of file k3passworddialog.cpp.

Member Function Documentation

void K3PasswordDialog::accept ( )
virtual

Definition at line 495 of file k3passworddialog.cpp.

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

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.

bool K3PasswordDialog::checkPassword ( const char *  password)
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.

void K3PasswordDialog::disableCoreDumps ( )
static

Static helper function that disables core dumps.

Definition at line 592 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
parentThe widget the dialog belongs too
passwordThe password is returned in this reference parameter.
captionA caption for the dialog.
promptA 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.

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 585 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
parentThe widget the dialog belongs too
passwordThe password is returned in this reference parameter.
captionA caption for the dialog.
promptA prompt for the password. This can be a few lines of information. The text is word broken to fit nicely in the dialog.
keepEnable/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.

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 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
maxLengthThe 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
minLengthThe 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
warningLevelThe 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
reasonableLengthThe new reasonable password length.

Definition at line 703 of file k3passworddialog.cpp.

void K3PasswordDialog::slotKeep ( bool  keep)
protectedslot

Definition at line 528 of file k3passworddialog.cpp.


The documentation for this class was generated from the following files:
  • k3passworddialog.h
  • k3passworddialog.cpp
This file is part of the KDE documentation.
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.

KDE3Support

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal