<HTML> <HEAD> <TITLE>class KPasswordDialog</TITLE> <META NAME="Generator" CONTENT="KDOC "> </HEAD> <BODY bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000099" alink= "#ffffff"> <TABLE WIDTH="100%" BORDER="0"> <TR> <TD> <TABLE BORDER="0"> <TR><TD valign="top" align="left" cellspacing="10"> <h1>class KPasswordDialog</h1> </TD> <TD valign="top" align="right" colspan="1">A password input dialog. <small><A HREF="#longdesc">More...</A></small></TD></TR> </TABLE> <HR> <TABLE BORDER="0"> <TR><TH>Definition</TH><TD><code>#include <<A HREF="kpassdlg_h.html">kpassdlg.h</A>></code></TD></TR> <TR><TH>Inherits</TH><TD><A HREF="KDialogBase.html">KDialogBase</A> <small>[public ]</small></TD></TR> <TR><TH><A HREF="full-list-KPasswordDialog.html">List of all Methods</A></TH></TR> </TABLE> </TD> <TD align="right"><TABLE BORDER="0"><TR><TD><small><A HREF="index-long.html">Annotated List</A></small></TD></TR> <TR><TD><small><A HREF="header-list.html">Files</A></small></TD></TR> <TR><TD><small><A HREF="all-globals.html">Globals</A></small></TD></TR> <TR><TD><small><A HREF="hier.html">Hierarchy</A></small></TD></TR> <TR><TD><small><A HREF="index.html">Index</A></small></TD></TR> </TABLE></TD></TR></TABLE> <h4>Public Types</h4><ul><LI>enum <A HREF="#ref10">Types</A> { Password, NewPassword } </LI> </ul><h4>Public Methods</h4><ul><LI> <b><A HREF="#ref1">KPasswordDialog</A></b> (int type, <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> prompt, bool enableKeep=false, int extraBttn=0) </LI> <LI>virtual <b><A HREF="#ref2">~KPasswordDialog</A></b> () </LI> <LI>void <b><A HREF="#ref3">setPrompt</A></b> (<A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> prompt) </LI> <LI>void <b><A HREF="#ref4">addLine</A></b> (<A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> key, <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> value) </LI> <LI>const char * <b><A HREF="#ref5">password</A></b> () const </LI> <LI>bool <b><A HREF="#ref6">keep</A></b> () const </LI> </ul><h4>Public Static Methods</h4><ul><LI>static int <b><A HREF="#ref7">getPassword</A></b> (<A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qcstring.html">QCString</A> &password, <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> prompt, int *keep=0L) </LI> <LI>static int <b><A HREF="#ref8">getNewPassword</A></b> (<A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qcstring.html">QCString</A> &password, <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> prompt) </LI> <LI>static void <b><A HREF="#ref9">disableCoreDumps</A></b> () </LI> </ul><h4>Protected Methods</h4><ul><LI>virtual bool <b><A HREF="#ref14">checkPassword</A></b> (const char *) </LI> </ul><h4>Protected Slots</h4><ul><LI>void <b><A HREF="#ref11">slotOk</A></b> () </LI> <LI>void <b><A HREF="#ref12">slotCancel</A></b> () </LI> <LI>void <b><A HREF="#ref13">slotKeep</A></b> (bool) </LI> </ul><HR><H2><A NAME="longdesc">Detailed Description</A></H2><p> This dialog asks the user to enter a password. The functions you're probably interested in are the static methods, <A HREF="KPasswordDialog.html#getPassword">getPassword</A>() and <A HREF="KPasswordDialog.html#getNewPassword">getNewPassword</A>(). </p> <p></p> <H3>Usage example </H3> <p> </p> <p></p><table border="0" width="100%"> <tr> <td bgcolor="#BEEAE0"> <pre> <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qcstring.html">QCString</A> <A HREF="KPasswordDialog.html#password">password</A>; int result = KPasswordDialog::getPassword(<A HREF="KPasswordDialog.html#password">password</A>, <A HREF="../kdecore/.html#i18n">i18n</A>("Password")); if (result == KPasswordDialog::Accepted) use(<A HREF="KPasswordDialog.html#password">password</A>); </pre> </td></tr> </table> <p> </p> <p></p> <H3>Security notes </H3> <p> </p> <p> Keeping passwords in memory can be a potential security hole. You should handle this situation with care. </p> <p></p> <ul> <li>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. </li> </ul> <p> </p> <p></p> <ul> <li>You should delete passwords as soon as they are not needed anymore. The functions <A HREF="KPasswordDialog.html#getPassword">getPassword</A>() and <A HREF="KPasswordDialog.html#getNewPassword">getNewPassword</A>() 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. </li> </ul> <p> </p> <p></p> <A NAME="KPasswordDialog"></A><A NAME="ref1"></A><table width="100%"><tr bgcolor="#eeeeee"><td> <strong>KPasswordDialog</strong> (int type, <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> prompt, bool enableKeep=false, int extraBttn=0) <br></td><td align="right"><h3><strong>KPasswordDialog</strong></h3></td></tr></table><p></p><A NAME="~KPasswordDialog"></A><A NAME="ref2"></A><table width="100%"><tr bgcolor="#eeeeee"><td> <strong>~KPasswordDialog</strong> () <br></td><td align="right"><h3><strong>~KPasswordDialog</strong></h3></td></tr></table><p> <small>[virtual]</small></p><A NAME="setPrompt"></A><A NAME="ref3"></A><table width="100%"><tr bgcolor="#eeeeee"><td>void <strong>setPrompt</strong> (<A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> prompt) <br></td><td align="right"><h3><strong>setPrompt</strong></h3></td></tr></table><p></p><A NAME="addLine"></A><A NAME="ref4"></A><table width="100%"><tr bgcolor="#eeeeee"><td>void <strong>addLine</strong> (<A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> key, <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> value) <br></td><td align="right"><h3><strong>addLine</strong></h3></td></tr></table><p></p><A NAME="password"></A><A NAME="ref5"></A><table width="100%"><tr bgcolor="#eeeeee"><td>const char * <strong>password</strong> () <br></td><td align="right"><h3><strong>password</strong></h3></td></tr></table><p> <small>[const]</small></p><p> Returns the password entered. The memory is freed in the destructor, so you should make a copy. </p> <A NAME="keep"></A><A NAME="ref6"></A><table width="100%"><tr bgcolor="#eeeeee"><td>bool <strong>keep</strong> () <br></td><td align="right"><h3><strong>keep</strong></h3></td></tr></table><p> <small>[const]</small></p><A NAME="getPassword"></A><A NAME="ref7"></A><table width="100%"><tr bgcolor="#eeeeee"><td> int <strong>getPassword</strong> (<A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qcstring.html">QCString</A> &password, <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> prompt, int *keep=0L) <br></td><td align="right"><h3><strong>getPassword</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Pops up the dialog, asks the user for a password, and returns it. </p> <p></p> <p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5"> <TR><TD align="left" valign="top"><i>password</i></TD><TD align="left" valign="top">The password is returned in this reference parameter. </TD></TR> <TR><TD align="left" valign="top"><i>prompt</i></TD><TD align="left" valign="top">A prompt for the password. This can be a few lines of information. The text is word broken to fit nicely in the dialog. </TD></TR> <TR><TD align="left" valign="top"><i>keep</i></TD><TD align="left" valign="top">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. </TD></TR> </TABLE></P> <p><b>Returns</b>: Result code: Accepted or Rejected. </p> <A NAME="getNewPassword"></A><A NAME="ref8"></A><table width="100%"><tr bgcolor="#eeeeee"><td> int <strong>getNewPassword</strong> (<A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qcstring.html">QCString</A> &password, <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> prompt) <br></td><td align="right"><h3><strong>getNewPassword</strong></h3></td></tr></table><p> <small>[static]</small></p><p> 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. </p> <p></p> <p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5"> <TR><TD align="left" valign="top"><i>password</i></TD><TD align="left" valign="top">The password is returned in this reference parameter. </TD></TR> <TR><TD align="left" valign="top"><i>prompt</i></TD><TD align="left" valign="top">A prompt for the password. This can be a few lines of information. The text is word broken to fit nicely in the dialog. </TD></TR> </TABLE></P> <p><b>Returns</b>: Result code: Accepted or Rejected. </p> <A NAME="disableCoreDumps"></A><A NAME="ref9"></A><table width="100%"><tr bgcolor="#eeeeee"><td> void <strong>disableCoreDumps</strong> () <br></td><td align="right"><h3><strong>disableCoreDumps</strong></h3></td></tr></table><p> <small>[static]</small></p><A NAME="Types"></A><A NAME="ref10"></A><table width="100%"><tr bgcolor="#eeeeee"><td>enum <strong>Types</strong> { Password, NewPassword } </td><td align="right"><h3><strong>Types</strong></h3></td></tr></table><p></p><A NAME="slotOk"></A><A NAME="ref11"></A><table width="100%"><tr bgcolor="#eeeeee"><td>void <strong>slotOk</strong> () <br></td><td align="right"><h3><strong>slotOk</strong></h3></td></tr></table><p> <small>[protected slots slot]</small></p><p>Reimplemented from <A HREF="KDialogBase.html#slotOk">KDialogBase</A>.</p> <A NAME="slotCancel"></A><A NAME="ref12"></A><table width="100%"><tr bgcolor="#eeeeee"><td>void <strong>slotCancel</strong> () <br></td><td align="right"><h3><strong>slotCancel</strong></h3></td></tr></table><p> <small>[protected slots slot]</small></p><p>Reimplemented from <A HREF="KDialogBase.html#slotCancel">KDialogBase</A>.</p> <A NAME="slotKeep"></A><A NAME="ref13"></A><table width="100%"><tr bgcolor="#eeeeee"><td>void <strong>slotKeep</strong> (bool) <br></td><td align="right"><h3><strong>slotKeep</strong></h3></td></tr></table><p> <small>[protected slots slot]</small></p><A NAME="checkPassword"></A><A NAME="ref14"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool <strong>checkPassword</strong> (const char *) <br></td><td align="right"><h3><strong>checkPassword</strong></h3></td></tr></table><p> <small>[protected virtual]</small></p><p> Virtual function that can be overridden to provide password checking in derived classes. It should return <code>true</code> if the password is valid, <code>false</code> otherwise. </p> <HR><UL><LI><i>Author</i>: Geert Jansen <jansen@kde.org> </LI><LI><i>Generated</i>: qateam on updates.mandrakesoft.com on Mon Dec 30 16:09:05 2002, using kdoc 2.0a53.</LI></UL></BODY></HTML>