summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/securityplugins/pin/pin.cpp22
-rw-r--r--noncore/securityplugins/pin/pin.h3
2 files changed, 19 insertions, 6 deletions
diff --git a/noncore/securityplugins/pin/pin.cpp b/noncore/securityplugins/pin/pin.cpp
index c21ffcd..2accb9c 100644
--- a/noncore/securityplugins/pin/pin.cpp
+++ b/noncore/securityplugins/pin/pin.cpp
@@ -1,345 +1,355 @@
1/** 1/**
2 * \note Taken from opie-security and libqpe password.cpp, and modified for Opie multiauth by Clement Seveillac 2 * \note Taken from opie-security and libqpe password.cpp, and modified for Opie multiauth by Clement Seveillac
3 */ 3 */
4/********************************************************************** 4/**********************************************************************
5 ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 5 ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
6 ** 6 **
7 ** This file is part of the Qtopia Environment. 7 ** This file is part of the Qtopia Environment.
8 ** 8 **
9 ** This file may be distributed and/or modified under the terms of the 9 ** This file may be distributed and/or modified under the terms of the
10 ** GNU General Public License version 2 as published by the Free Software 10 ** GNU General Public License version 2 as published by the Free Software
11 ** Foundation and appearing in the file LICENSE.GPL included in the 11 ** Foundation and appearing in the file LICENSE.GPL included in the
12 ** packaging of this file. 12 ** packaging of this file.
13 ** 13 **
14 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 14 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
15 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 15 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16 ** 16 **
17 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 17 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
18 ** 18 **
19 ** Contact info@trolltech.com if any conditions of this licensing are 19 ** Contact info@trolltech.com if any conditions of this licensing are
20 ** not clear to you. 20 ** not clear to you.
21 ** 21 **
22 **********************************************************************/ 22 **********************************************************************/
23 23
24#include "pin.h" 24#include "pin.h"
25#include "pinDialogBase.h" 25#include "pinDialogBase.h"
26#include "pinConfigWidget.h"
27/* OPIE */ 26/* OPIE */
28#include <opie2/odebug.h> 27#include <opie2/odebug.h>
29#include <opie2/oapplication.h> 28#include <opie2/oapplication.h>
30/* QT */ 29/* QT */
31#include <qpe/config.h> 30#include <qpe/config.h>
32#include <qlabel.h> 31#include <qlabel.h>
33#include <qlineedit.h> 32#include <qlineedit.h>
34#include <qtextview.h> 33#include <qtextview.h>
35#include <qstring.h> 34#include <qstring.h>
36#include <qdialog.h> 35#include <qdialog.h>
37/* UNIX */ 36/* UNIX */
38#include <unistd.h> 37#include <unistd.h>
39#include <stdlib.h> 38#include <stdlib.h>
40#include <time.h> 39#include <time.h>
41 40
42extern "C" char *crypt(const char *key, const char *salt); 41extern "C" char *crypt(const char *key, const char *salt);
43 42
44using Opie::Security::MultiauthConfigWidget; 43using Opie::Security::MultiauthConfigWidget;
45using Opie::Security::MultiauthPluginObject; 44using Opie::Security::MultiauthPluginObject;
46 45
47/// set to TRUE when we press the 'Skip' button 46/// set to TRUE when we press the 'Skip' button
48static bool isSkip = FALSE; 47static bool isSkip = FALSE;
49 48
50/// PIN input graphical widget. 49/// PIN input graphical widget.
51/** 50/**
52 * Inherits the PinDialogBase class defined originally in pinDialogBase.ui interface file. 51 * Inherits the PinDialogBase class defined originally in pinDialogBase.ui interface file.
53 * \sa PinDlg and PinDialog (the class generated from the .ui file) 52 * \sa PinDlg and PinDialog (the class generated from the .ui file)
54 * It comes from the original PIN locking code in Opie : 53 * It comes from the original PIN locking code in Opie :
55 * \sa http://dudu.dyn.2-h.org/opiedoxydoc/library_2password_8cpp-source.html 54 * \sa http://dudu.dyn.2-h.org/opiedoxydoc/library_2password_8cpp-source.html
56 */ 55 */
57class PinDialog : public PinDialogBase 56class PinDialog : public PinDialogBase
58{ 57{
59 Q_OBJECT 58 Q_OBJECT
60 59
61 public: 60 public:
62 PinDialog( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 61 PinDialog( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
63 ~PinDialog(); 62 ~PinDialog();
64 63
65 void clear(); 64 void clear();
66 void setPrompt( const QString& ); 65 void setPrompt( const QString& );
67 66
68signals: 67signals:
69 /// emitted when we press the Enter button 68 /// emitted when we press the Enter button
70 void passwordEntered( const QString& ); 69 void passwordEntered( const QString& );
71 /// emitted when we press the Skip button 70 /// emitted when we press the Skip button
72 void skip(); 71 void skip();
73 72
74 protected: 73 protected:
75 bool eventFilter( QObject*, QEvent* ); 74 bool eventFilter( QObject*, QEvent* );
76 75
77 private: 76 private:
78 void input( QString ); 77 void input( QString );
79 friend class PinPlugin; 78 friend class PinPlugin;
80 QString text; 79 QString text;
81}; 80};
82 81
83 82
84/// Constructs a PinDialog widget, and initializes things 83/// Constructs a PinDialog widget, and initializes things
85PinDialog::PinDialog( QWidget* parent, const char* name, WFlags fl ) 84PinDialog::PinDialog( QWidget* parent, const char* name, WFlags fl )
86 : PinDialogBase( parent, name, fl ) 85 : PinDialogBase( parent, name, fl )
87{ 86{
88 QRect desk = oApp->desktop()->geometry(); 87 QRect desk = oApp->desktop()->geometry();
89 88
90 if ( desk.width() < 220 ) { 89 if ( desk.width() < 220 ) {
91 QFont f( font() ); 90 QFont f( font() );
92 f.setPointSize( 18 ); 91 f.setPointSize( 18 );
93 setFont( f ); 92 setFont( f );
94 f.setPointSize( 12 ); 93 f.setPointSize( 12 );
95 prompt->setFont( f ); 94 prompt->setFont( f );
96 } 95 }
97 96
98 button_0->installEventFilter( this ); 97 button_0->installEventFilter( this );
99 button_1->installEventFilter( this ); 98 button_1->installEventFilter( this );
100 button_2->installEventFilter( this ); 99 button_2->installEventFilter( this );
101 button_3->installEventFilter( this ); 100 button_3->installEventFilter( this );
102 button_4->installEventFilter( this ); 101 button_4->installEventFilter( this );
103 button_5->installEventFilter( this ); 102 button_5->installEventFilter( this );
104 button_6->installEventFilter( this ); 103 button_6->installEventFilter( this );
105 button_7->installEventFilter( this ); 104 button_7->installEventFilter( this );
106 button_8->installEventFilter( this ); 105 button_8->installEventFilter( this );
107 button_9->installEventFilter( this ); 106 button_9->installEventFilter( this );
108 button_Skip->installEventFilter( this ); 107 button_Skip->installEventFilter( this );
109 button_OK->installEventFilter( this ); 108 button_OK->installEventFilter( this );
110 setFocus(); 109 setFocus();
111} 110}
112 111
113/// nothing to do 112/// nothing to do
114PinDialog::~PinDialog() 113PinDialog::~PinDialog()
115{ 114{
116 // no need to delete child widgets, Qt does it all for us 115 // no need to delete child widgets, Qt does it all for us
117} 116}
118 117
119/// Record the pressed numbers, and the Skip and Enter commands 118/// Record the pressed numbers, and the Skip and Enter commands
120bool PinDialog::eventFilter( QObject*o, QEvent*e ) 119bool PinDialog::eventFilter( QObject*o, QEvent*e )
121{ 120{
122 if ( e->type() == QEvent::MouseButtonRelease ) { 121 if ( e->type() == QEvent::MouseButtonRelease ) {
123 if ( o == button_OK ) { 122 if ( o == button_OK ) {
124 emit passwordEntered( text ); 123 emit passwordEntered( text );
125 } 124 }
126 else if ( o == button_Skip ) { 125 else if ( o == button_Skip ) {
127 isSkip = TRUE; 126 isSkip = TRUE;
128 emit skip(); 127 emit skip();
129 } 128 }
130 else { 129 else {
131 QLabel *l = (QLabel*)o; 130 QLabel *l = (QLabel*)o;
132 input(l->text()); 131 input(l->text());
133 } 132 }
134 } 133 }
135 return FALSE; 134 return FALSE;
136} 135}
137 136
138void PinDialog::input( QString c ) 137void PinDialog::input( QString c )
139{ 138{
140 text += c; 139 text += c;
141 display->setText( text ); 140 display->setText( text );
142} 141}
143 142
144void PinDialog::setPrompt( const QString& s ) 143void PinDialog::setPrompt( const QString& s )
145{ 144{
146 prompt->setText( s ); 145 prompt->setText( s );
147} 146}
148 147
149void PinDialog::clear() 148void PinDialog::clear()
150{ 149{
151 text = ""; 150 text = "";
152 input(""); 151 input("");
153} 152}
154 153
155/// PIN dialog 154/// PIN dialog
156/** 155/**
157 * Dialog containing the PinDialog widget (which asks for a PIN) and interfacing with its I/O. 156 * Dialog containing the PinDialog widget (which asks for a PIN) and interfacing with its I/O.
158 * \sa PinDialog 157 * \sa PinDialog
159 */ 158 */
160class PinDlg : public QDialog 159class PinDlg : public QDialog
161{ 160{
162 public: 161 public:
163 PinDlg( QWidget *parent, const char * name, bool modal, bool fullscreen = FALSE ) 162 PinDlg( QWidget *parent, const char * name, bool modal, bool fullscreen = FALSE )
164 : QDialog( parent, name, modal, fullscreen ? WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop : 0 ), 163 : QDialog( parent, name, modal, fullscreen ? WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop : 0 ),
165 modl(modal) 164 modl(modal)
166 { 165 {
167 pinD = new PinDialog( this ); 166 pinD = new PinDialog( this );
168 167
169 if ( fullscreen ) { 168 if ( fullscreen ) {
170 QRect desk = oApp->desktop()->geometry(); 169 QRect desk = oApp->desktop()->geometry();
171 setGeometry( 0, 0, desk.width(), desk.height() ); 170 setGeometry( 0, 0, desk.width(), desk.height() );
172 } 171 }
173 172
174 connect( pinD, SIGNAL(passwordEntered(const QString&)), 173 connect( pinD, SIGNAL(passwordEntered(const QString&)),
175 this, SLOT(accept()) ); 174 this, SLOT(accept()) );
176 connect( pinD, SIGNAL(skip()), this, SLOT(accept()) ); 175 connect( pinD, SIGNAL(skip()), this, SLOT(accept()) );
177 } 176 }
178 177
179 void resizeEvent( QResizeEvent * ) 178 void resizeEvent( QResizeEvent * )
180 { 179 {
181 pinD->resize( size() ); 180 pinD->resize( size() );
182 } 181 }
183 182
184 void reset() 183 void reset()
185 { 184 {
186 pinD->clear(); 185 pinD->clear();
187 } 186 }
188 187
189 /// Slot receiving the Skip or Enter commands, and closing the QDialog 188 /// Slot receiving the Skip or Enter commands, and closing the QDialog
190 void accept() 189 void accept()
191 { 190 {
192 if ( !modl ) 191 if ( !modl )
193 oApp->exit_loop(); 192 oApp->exit_loop();
194 QDialog::accept(); 193 QDialog::accept();
195 } 194 }
196 195
197 PinDialog *pinD; 196 PinDialog *pinD;
198 bool modl; 197 bool modl;
199}; 198};
200 199
201/// generate a fairly random salt and return the PIN hashed by crypt() 200/// generate a fairly random salt and return the PIN hashed by crypt()
202QString PinPlugin::encrypt(const QString& pin) 201QString PinPlugin::encrypt(const QString& pin)
203{ 202{
204 // the salt must begin by "$1$" if we want crypt() to use MD5 203 // the salt must begin by "$1$" if we want crypt() to use MD5
205 char salt[] = "$1$........"; 204 char salt[] = "$1$........";
206 const char *const seedchars = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 205 const char *const seedchars = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
207 // initialize the random generator 206 // initialize the random generator
208 srandom(time(0)); 207 srandom(time(0));
209 int i; 208 int i;
210 for(i = 0; i < 8; i++) 209 for(i = 0; i < 8; i++)
211 { 210 {
212 // initialize the salt with random() 211 // initialize the salt with random()
213 salt[i+3] = seedchars[random() % 64]; 212 salt[i+3] = seedchars[random() % 64];
214 } 213 }
215 return QString::fromLatin1(crypt(pin.latin1(),salt)); 214 return QString::fromLatin1(crypt(pin.latin1(),salt));
216} 215}
217 216
218/// verify a PIN against its crypt() hash 217/// verify a PIN against its crypt() hash
219/** 218/**
220 * \return true if the \a pin matches its \a hash 219 * \return true if the \a pin matches its \a hash
221 */ 220 */
222bool PinPlugin::verify(const QString& pin, const QString& hash) 221bool PinPlugin::verify(const QString& pin, const QString& hash)
223{ 222{
224 // the hash, which contains the salt (8 chars after "$1$"), can be given as the salt 223 // the hash, which contains the salt (8 chars after "$1$"), can be given as the salt
225 return hash.compare( QString::fromLatin1(crypt( pin.latin1(), hash.latin1() )) ) == 0 ? true : false; 224 return hash.compare( QString::fromLatin1(crypt( pin.latin1(), hash.latin1() )) ) == 0 ? true : false;
226} 225}
227 226
228/// Displays a PinDialog and returns the typed in PIN 227/// Displays a PinDialog and returns the typed in PIN
229/** 228/**
230 * The returned value is QString::null if the user cancels the operation, 229 * The returned value is QString::null if the user cancels the operation,
231 * or the empty string if the user enters no password (but confirms the 230 * or the empty string if the user enters no password (but confirms the
232 * dialog). 231 * dialog).
233 */ 232 */
234QString PinPlugin::getPIN( const QString& prompt ) 233QString PinPlugin::getPIN( const QString& prompt )
235{ 234{
236 PinDlg pd(0,0,TRUE); 235 PinDlg pd(0,0,TRUE);
237 pd.pinD->setPrompt( prompt ); 236 pd.pinD->setPrompt( prompt );
238 237
239 pd.showMaximized(); 238 pd.showMaximized();
240 int r = pd.exec(); 239 int r = pd.exec();
241 240
242 if ( r == QDialog::Accepted ) { 241 if ( r == QDialog::Accepted ) {
243 if (pd.pinD->text.isEmpty()) 242 if (pd.pinD->text.isEmpty())
244 return ""; 243 return "";
245 else 244 else
246 return pd.pinD->text; 245 return pd.pinD->text;
247 } 246 }
248 else 247 else
249 return QString::null; 248 return QString::null;
250} 249}
251 250
252/// Displays the PIN dialog and returns a hash of the typed in PIN 251/// Displays the PIN dialog and returns a hash of the typed in PIN
253/** 252/**
254 * \return the hashed ( =one-way encrypted) PIN typed in by the user 253 * \return the hashed ( =one-way encrypted) PIN typed in by the user
255 * \param prompt the prompt to display in the PinDialog 254 * \param prompt the prompt to display in the PinDialog
256 */ 255 */
257QString PinPlugin::getCryptedPIN( const QString& prompt ) 256QString PinPlugin::getCryptedPIN( const QString& prompt )
258{ 257{
259 return encrypt(getPIN(prompt)); 258 return encrypt(getPIN(prompt));
260} 259}
261 260
262/// Displays the PIN dialog, asks 2 times for a new PIN, saves it if entered two times 261/// Displays the PIN dialog, asks 2 times for a new PIN, saves it if entered two times
263/** 262/**
264 * writes nothing if we enter nothing the first time 263 * writes nothing if we enter nothing the first time
265 */ 264 */
266void PinPlugin::changePIN() 265void PinPlugin::changePIN()
267{ 266{
268 QString new1, new2; 267 QString new1, new2;
269 do { 268 do {
270 new1 = getPIN(QObject::tr("Enter new PIN")); 269 new1 = getPIN(QObject::tr("Enter new PIN"));
271 if ( new1.isNull() ) 270 if ( new1.isNull() )
272 return; 271 return;
273 new2 = getPIN(QObject::tr("Re-enter new PIN")); 272 new2 = getPIN(QObject::tr("Re-enter new PIN"));
274 } while (new1 != new2); 273 } while (new1 != new2);
275 274
276 odebug << "writing new PIN hash in Security.conf" << oendl; 275 odebug << "writing new PIN hash in Security.conf" << oendl;
277 Config cfg("Security"); 276 Config cfg("Security");
278 cfg.setGroup("PinPlugin"); 277 cfg.setGroup("PinPlugin");
279 cfg.writeEntry("hashedPIN", encrypt(new1)); 278 cfg.writeEntry("hashedPIN", encrypt(new1));
280} 279}
281 280
282/// Removes the PIN hashed value in the config file 281/// Removes the PIN hashed value in the config file
283void PinPlugin::clearPIN() 282void PinPlugin::clearPIN()
284{ 283{
285 Config cfg("Security"); 284 Config cfg("Security");
286 cfg.setGroup("PinPlugin"); 285 cfg.setGroup("PinPlugin");
287 cfg.removeEntry("hashedPIN"); 286 cfg.removeEntry("hashedPIN");
288} 287}
289 288
290/// Prompt, fullscreen, for the user's PIN and compare it to the stored one. 289/// Prompt, fullscreen, for the user's PIN and compare it to the stored one.
291/** 290/**
292 * \return the result code, as a MultiauthPluginObject::authResult object 291 * \return the result code, as a MultiauthPluginObject::authResult object
293 */ 292 */
294int PinPlugin::authenticate() 293int PinPlugin::authenticate()
295{ 294{
296 // reset skip (if we ran Pin two times in a row, skipping the first time, it must be put to 0 again) 295 // reset skip (if we ran Pin two times in a row, skipping the first time, it must be put to 0 again)
297 isSkip = FALSE; 296 isSkip = FALSE;
298 // fetch value in config 297 // fetch value in config
299 Config cfg("Security"); 298 Config cfg("Security");
300 cfg.setGroup("PinPlugin"); 299 cfg.setGroup("PinPlugin");
301 QString hashedPin = cfg.readEntry("hashedPIN"); 300 QString hashedPin = cfg.readEntry("hashedPIN");
302 if (!hashedPin.isEmpty()) 301 if (!hashedPin.isEmpty())
303 { 302 {
304 // prompt for the PIN in a fullscreen modal dialog 303 // prompt for the PIN in a fullscreen modal dialog
305 PinDlg pd(0,0,TRUE,TRUE); 304 PinDlg pd(0,0,TRUE,TRUE);
306 pd.reset(); 305 pd.reset();
307 pd.exec(); 306 pd.exec();
308 307
309 // analyse the result 308 // analyse the result
310 if (isSkip == TRUE) 309 if (isSkip == TRUE)
311 return MultiauthPluginObject::Skip; 310 return MultiauthPluginObject::Skip;
312 else if (verify(pd.pinD->text, hashedPin)) 311 else if (verify(pd.pinD->text, hashedPin))
313 return MultiauthPluginObject::Success; 312 return MultiauthPluginObject::Success;
314 else 313 else
315 return MultiauthPluginObject::Failure; 314 return MultiauthPluginObject::Failure;
316 } 315 }
317 owarn << "No PIN has been defined! We consider it as a successful authentication though." << oendl; 316 owarn << "No PIN has been defined! We consider it as a successful authentication though." << oendl;
318 return MultiauthPluginObject::Success; 317 return MultiauthPluginObject::Success;
319} 318}
320 319
320/// Standard c'tor
321PinPlugin::PinPlugin() : MultiauthPluginObject(), m_pinW(0) {
322}
323
324/// deletes m_pinW if we need to
325PinPlugin::~PinPlugin() {
326 if (m_pinW != 0)
327 delete m_pinW;
328}
329
321/// Simply returns the plugin name (PIN plugin) 330/// Simply returns the plugin name (PIN plugin)
322QString PinPlugin::pluginName() const { 331QString PinPlugin::pluginName() const {
323 return "PIN Plugin"; 332 return "PIN Plugin";
324} 333}
325 334
326QString PinPlugin::pixmapNameWidget() const { 335QString PinPlugin::pixmapNameWidget() const {
327 return "security/pinplugin"; 336 return "security/pinplugin";
328} 337}
329 338
330QString PinPlugin::pixmapNameConfig() const { 339QString PinPlugin::pixmapNameConfig() const {
331 return "security/pinplugin"; 340 return "security/pinplugin";
332} 341}
333 342
334/// returns a PinConfigWidget 343/// returns a PinConfigWidget
335MultiauthConfigWidget * PinPlugin::configWidget(QWidget * parent) { 344MultiauthConfigWidget * PinPlugin::configWidget(QWidget * parent) {
336 PinConfigWidget * pinw = new PinConfigWidget(parent, "PIN configuration widget"); 345 if (m_pinW == 0) {
337 346 m_pinW = new PinConfigWidget(parent, "PIN configuration widget");
338 connect(pinw->changePIN, SIGNAL( clicked() ), this, SLOT( changePIN() ));
339 connect(pinw->clearPIN, SIGNAL( clicked() ), this, SLOT( clearPIN() ));
340 347
341 return pinw; 348 connect(m_pinW->changePIN, SIGNAL( clicked() ), this, SLOT( changePIN() ));
349 connect(m_pinW->clearPIN, SIGNAL( clicked() ), this, SLOT( clearPIN() ));
350 }
351 return m_pinW;
342} 352}
343 353
344#include "pin.moc" 354#include "pin.moc"
345 355
diff --git a/noncore/securityplugins/pin/pin.h b/noncore/securityplugins/pin/pin.h
index 1832210..b5ae10a 100644
--- a/noncore/securityplugins/pin/pin.h
+++ b/noncore/securityplugins/pin/pin.h
@@ -1,68 +1,71 @@
1/** 1/**
2 * \file pin.h 2 * \file pin.h
3 * \brief Standard Opie multiauth plugin definition 3 * \brief Standard Opie multiauth plugin definition
4 * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) 4 * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr)
5 */ 5 */
6/* 6/*
7 =. This file is part of the Opie Project 7 =. This file is part of the Opie Project
8 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> 8 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
9 .>+-= 9 .>+-=
10 _;:, .> :=|. This library is free software; you can 10 _;:, .> :=|. This library is free software; you can
11.> <`_, > . <= redistribute it and/or modify it under 11.> <`_, > . <= redistribute it and/or modify it under
12:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 12:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
13.="- .-=="i, .._ License as published by the Free Software 13.="- .-=="i, .._ License as published by the Free Software
14 - . .-<_> .<> Foundation; either version 2 of the License, 14 - . .-<_> .<> Foundation; either version 2 of the License,
15 ._= =} : or (at your option) any later version. 15 ._= =} : or (at your option) any later version.
16 .%`+i> _;_. 16 .%`+i> _;_.
17 .i_,=:_. -<s. This library is distributed in the hope that 17 .i_,=:_. -<s. This library is distributed in the hope that
18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
19 : .. .:, . . . without even the implied warranty of 19 : .. .:, . . . without even the implied warranty of
20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.= = ; Library General Public License for more 22..}^=.= = ; Library General Public License for more
23++= -. .` .: details. 23++= -. .` .: details.
24 : = ...= . :.=- 24 : = ...= . :.=-
25 -. .:....=;==+<; You should have received a copy of the GNU 25 -. .:....=;==+<; You should have received a copy of the GNU
26 -_. . . )=. = Library General Public License along with 26 -_. . . )=. = Library General Public License along with
27 -- :-=` this library; see the file COPYING.LIB. 27 -- :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef PIN_H 34#ifndef PIN_H
35#define PIN_H 35#define PIN_H
36 36
37#include <qobject.h> 37#include <qobject.h>
38#include <qstring.h> 38#include <qstring.h>
39#include <opie2/multiauthplugininterface.h> 39#include <opie2/multiauthplugininterface.h>
40#include "pinConfigWidget.h" 40#include "pinConfigWidget.h"
41 41
42/// Multi-authentication plugin, implementing a PIN verification. 42/// Multi-authentication plugin, implementing a PIN verification.
43/** 43/**
44 * The plugin itself, implementing the main authenticate() function. 44 * The plugin itself, implementing the main authenticate() function.
45 */ 45 */
46class PinPlugin : public QObject, public Opie::Security::MultiauthPluginObject { 46class PinPlugin : public QObject, public Opie::Security::MultiauthPluginObject {
47 47
48 Q_OBJECT 48 Q_OBJECT
49 49
50public: 50public:
51 PinPlugin();
52 virtual ~PinPlugin();
51 int authenticate(); 53 int authenticate();
52 Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent); 54 Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent);
53 QString pixmapNameConfig() const; 55 QString pixmapNameConfig() const;
54 QString pixmapNameWidget() const; 56 QString pixmapNameWidget() const;
55 QString pluginName() const; 57 QString pluginName() const;
56 58
57private slots: 59private slots:
58 QString getPIN( const QString& prompt ); 60 QString getPIN( const QString& prompt );
59 QString getCryptedPIN( const QString& prompt ); 61 QString getCryptedPIN( const QString& prompt );
60 void changePIN(); 62 void changePIN();
61 void clearPIN(); 63 void clearPIN();
62 64
63private: 65private:
66 PinConfigWidget * m_pinW;
64 QString encrypt(const QString& pin); 67 QString encrypt(const QString& pin);
65 bool verify(const QString& pin, const QString& hash); 68 bool verify(const QString& pin, const QString& hash);
66}; 69};
67 70
68#endif // PIN_H 71#endif // PIN_H