class KPasswordDialog

# class KPasswordDialog | A password input dialog. More...
Definition | `#include <kpassdlg.h>`
Inherits | KDialogBase [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- enum Types { Password, /** }

#### Public Methods

- 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)
- virtual ~KPasswordDialog ()
- void setPrompt (QString prompt)
- QString prompt () const
- void addLine (QString key, QString value)
- const char * password () const
- bool keep () const

#### Public Static Methods

- static int getPassword (QCString &password, QString prompt, int *keep=0L)
- static int getNewPassword (QCString &password, QString prompt)
- static void disableCoreDumps ()

#### Protected Methods

- virtual bool checkPassword (const char *)
- virtual void virtual_hook ( int id, void* data )

#### Protected Slots

- void slotOk ()
- void slotCancel ()
- void slotKeep (bool)

## Detailed Description

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("Password"));
     if (result == KPasswordDialog::Accepted)
         use(password);

### 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.

enum Types { Password, /** } | ### Types

The user is asked to enter a password.

KPasswordDialog (Types type, bool enableKeep, int extraBttn, QWidget *parent=0, const char *name=0) | ### KPasswordDialog

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, KDialogBase.

KPasswordDialog (int type, QString prompt, bool enableKeep=false, int extraBttn=0) | ### KPasswordDialog

possibility to specify a parent. May be removed in KDE 4.0

~KPasswordDialog () | ### ~KPasswordDialog

[virtual]

Destructs the password dialog.

void setPrompt (QString prompt) | ### setPrompt

Sets the password prompt.

QString prompt () | ### prompt

[const]

Returns the password prompt.

void addLine (QString key, QString value) | ### addLine

Adds a line of information to the dialog.

const char * password () | ### password

[const]

Returns the password entered. The memory is freed in the destructor, so you should make a copy.

bool keep () | ### keep

[const]

Returns true if the user wants to keep the password.

int getPassword (QCString &password, QString prompt, int *keep=0L) | ### getPassword

[static]

Pops up the dialog, asks the user for a password, and returns it.

Parameters:

password | The password is returned in this reference parameter.
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 0, the checkbox is not shown. If you pass a pointer to a nonzero value, the checkbox is shown and the result is stored in *keep.

Returns: Result code: Accepted or Rejected.

int getNewPassword (QCString &password, QString prompt) | ### getNewPassword

[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:

password | The password is returned in this reference parameter.
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.

void disableCoreDumps () | ### disableCoreDumps

[static]

Static helper funtion that disables core dumps.

void slotOk () | ### slotOk

[protected slots slot]

Reimplemented from KDialogBase.

void slotCancel () | ### slotCancel

[protected slots slot]

Reimplemented from KDialogBase.

void slotKeep (bool) | ### slotKeep

[protected slots slot]

bool checkPassword (const char *) | ### checkPassword

[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.

void virtual_hook ( int id, void* data ) | ### virtual_hook

[protected virtual]

Reimplemented from KDialogBase.

- Author: Geert Jansen
- Generated: root on macppc.ports.openbsd.org on Sat Sep 6 10:36:37 2003, using kdoc 2.0a54.