summaryrefslogtreecommitdiff
path: root/libopie2
authorclem <clem>2004-10-05 23:38:06 (UTC)
committer clem <clem>2004-10-05 23:38:06 (UTC)
commitc09e45b02053c61b4e195c9d79a573ebfed2c521 (patch) (side-by-side diff)
tree504a1a7d6b29e9dc186b2a7a7431ea41482041e3 /libopie2
parent2d05ffb4bad93532e17b9350ff2d66fe3419cbe3 (diff)
downloadopie-c09e45b02053c61b4e195c9d79a573ebfed2c521.zip
opie-c09e45b02053c61b4e195c9d79a573ebfed2c521.tar.gz
opie-c09e45b02053c61b4e195c9d79a573ebfed2c521.tar.bz2
Changed the way to test authentication: instead of having a hardcoded config
option, allowByPass, we now have a "Test now" button in the configuration interface. We add to change both the config app and the libopie2security files for that, since the MultiauthMainWindow constructor has to know whether to implement a debug mode (with an new argument, false by default). We also had to give MultiauthGeneralConfig a link to MultiauthConfig, since the test button triggers the writing of the whole configuration. Some cleaning too (m_ on *all* member attributes, removal of obsolete allowByPass / explanScreens checking code.
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiesecurity/multiauthmainwindow.cpp29
-rw-r--r--libopie2/opiesecurity/multiauthmainwindow.h2
2 files changed, 20 insertions, 11 deletions
diff --git a/libopie2/opiesecurity/multiauthmainwindow.cpp b/libopie2/opiesecurity/multiauthmainwindow.cpp
index fa247ab..fb720bb 100644
--- a/libopie2/opiesecurity/multiauthmainwindow.cpp
+++ b/libopie2/opiesecurity/multiauthmainwindow.cpp
@@ -1,135 +1,144 @@
#include "multiauthmainwindow.h"
#include "multiauthcommon.h"
#include <qpe/config.h>
namespace Opie {
namespace Security {
-/// Initializes widgets according to allowBypass and explanScreens config
-MultiauthMainWindow::MultiauthMainWindow()
+/// Initializes widgets according to allowBypass argument (false by default) and explanScreens config
+/**
+ * \note if allowBypass is true, we will show explanatory screens anyway
+ */
+MultiauthMainWindow::MultiauthMainWindow(bool allowBypass = false)
: QDialog(0, "main Opie multiauth modal dialog", TRUE,
Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop)
{
alreadyDone = false;
// initializes widget pointers which not always point to an object
quit = 0;
message2 = 0;
- Config *pcfg = new Config("Security");
- pcfg->setGroup("Misc");
- explanScreens = pcfg->readBoolEntry("explanScreens", true);
- allowBypass = pcfg->readBoolEntry("allowBypass", false);
- delete pcfg;
+ if (allowBypass == true)
+ explanScreens = true;
+ else
+ {
+ Config *pcfg = new Config("Security");
+ pcfg->setGroup("Misc");
+ explanScreens = pcfg->readBoolEntry("explanScreens", true);
+ delete pcfg;
+ }
layout = new QVBoxLayout(this);
layout->setSpacing(11);
layout->setMargin(11);
layout->setAlignment( Qt::AlignTop );
// if explanScreens is false, we don't show any text in the QDialog,
// and we proceed directly
if ( explanScreens == true )
{
title = new QLabel("<center><h1>" + tr("Welcome to Opie Multi-authentication Framework") + "</h1></center>", this);
message = new QLabel("<center><h3>" + tr("Launching authentication plugins...") + "</h3></center>", this);
} else {
title = new QLabel("", this);
message = new QLabel("", this);
}
layout->addWidget(title);
layout->addWidget(message);
proceedButton = new QPushButton(tr("Proceed..."), this);
layout->addWidget(proceedButton, 0, Qt::AlignHCenter);
QObject::connect(proceedButton, SIGNAL(clicked()), this, SLOT(proceed()));
if ( explanScreens == true )
{
quit = new QPushButton("Exit", this);
layout->addWidget(quit, 0, Qt::AlignHCenter);
if ( allowBypass == true )
{
// very important: we can close the widget through the quit button, and bypass authentication, only if allowBypass is set!
- message2 = new QLabel("<center><i>" + tr("Note: the 'exit' button should be removed for real protection, through Security config dialog") + ".</i></center>", this);
+ message2 = new QLabel("<center><i>" + tr("Note: this 'exit' button only appears during <b>simulations</b>, like the one we are in.") + "</i></center>", this);
layout->addWidget(message2);
QObject::connect(quit, SIGNAL(clicked()), this, SLOT(close()));
}
else
{
quit->hide();
}
}
else
{
// we will need this button only if runPlugins() fails in proceed()
proceedButton->hide();
// let's proceed now
proceed();
}
}
/// nothing to do
MultiauthMainWindow::~MultiauthMainWindow() {
}
/// launch the authentication
void MultiauthMainWindow::proceed() {
int result = Internal::runPlugins();
if ( (result == 0) && !explanScreens )
{
// the authentication has succeeded, we can exit directly
// this will work if we haven't been called by the constructor of MultiauthMainWindow
close();
// and if we've been called by this constructor, we use this variable to tell our
// caller we're already done
alreadyDone = true;
return;
}
else
{
proceedButton->setText("Another try?");
QString resultMessage;
if (result == 0)
{
// authentication has succeeded, adapt interface then
message->setText( "<center><h3>" + tr("Congratulations! Your authentication has been successful.") + "</h3></center>" );
quit->setText("Enter Opie");
if ( quit->isHidden() )
{
// that means we don't allow to bypass, but now we can show and connect this button
QObject::connect(quit, SIGNAL(clicked()), this, SLOT(close()));
quit->show();
} else {
if ( message2 != 0 ) message2->hide();
}
}
else
{
// authentication has failed, explain that according to allowBypass
- message->setText( "<center><h3>" + tr("You have not succeeded enough authentication steps!") + "</h3></center>" );
+ message->setText( "<center><h3>" + tr("You have <b>not</b> succeeded enough authentication steps!") + "</h3></center>" );
proceedButton->show();
if ( allowBypass == true )
- message2->setText( "<center><p>" + tr("Note: if 'allow to bypass' was uncheck in Security config, you would have to go back through all the steps now.") + "</p></center>" );
+ {
+ message2->setText( "<center><p>" + tr("Be careful: if this was not a <b>simulation</b>, you would have to go back through all the steps now.") + "</p></center>" );
+ message2->show();
}
}
}
/** When we don't show explanatory screens and we succeed authentication,
* as early as during the proceed() call of the constructor, the caller must know
* (through this function) authentication has already been succeeded..
* \todo try to avoid this hack?
*/
bool MultiauthMainWindow::isAlreadyDone() {
return alreadyDone;
}
}
}
diff --git a/libopie2/opiesecurity/multiauthmainwindow.h b/libopie2/opiesecurity/multiauthmainwindow.h
index 626b8b3..9d2376b 100644
--- a/libopie2/opiesecurity/multiauthmainwindow.h
+++ b/libopie2/opiesecurity/multiauthmainwindow.h
@@ -1,84 +1,84 @@
/**
* \file multiauthmainwindow.h
* \brief Defines the Opie multiauth main window.
*
* This implementation was derived from the today plugins implementation.
* \author Clément Séveillac (clement . seveillac (at) via . ecp . fr)
*/
/*
=. This file is part of the Opie Project
.=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
.>+-=
_;:, .> :=|. This library is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This library is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef MULTIAUTHMAINWINDOW_H
#define MULTIAUTHMAINWINDOW_H
#include <qdialog.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qlabel.h>
namespace Opie {
namespace Security {
/// Multiauth main window
/**
* This QDialog window displays some information and an exit button,
* and completely hides the desktop, preventing user interactions
* with it.
*/
class MultiauthMainWindow : public QDialog {
Q_OBJECT
public:
- MultiauthMainWindow();
+ MultiauthMainWindow(bool allowBypass = false);
~MultiauthMainWindow();
bool isAlreadyDone();
private:
QVBoxLayout * layout;
QLabel * title, * message, * message2;
QPushButton * proceedButton, * quit;
/// whether to show explanatory screens before and after the authentication plugins
bool explanScreens;
/// allow to bypass authnentication via 'exit' buttons on both explan. screens
bool allowBypass;
/// true when the authentication has been done successfully
bool alreadyDone;
private slots:
void proceed();
private:
struct Private;
Private *d;
};
}
}
#endif // MULTIAUTHMAINWINDOW_H