summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/security/multiauthconfig.cpp129
-rw-r--r--core/settings/security/multiauthconfig.h18
-rw-r--r--libopie2/opiesecurity/multiauthmainwindow.cpp29
-rw-r--r--libopie2/opiesecurity/multiauthmainwindow.h2
4 files changed, 106 insertions, 72 deletions
diff --git a/core/settings/security/multiauthconfig.cpp b/core/settings/security/multiauthconfig.cpp
index 3c73d7b..192b8ca 100644
--- a/core/settings/security/multiauthconfig.cpp
+++ b/core/settings/security/multiauthconfig.cpp
@@ -1,4 +1,3 @@
1#include "multiauthconfig.h"
2
3#include <opie2/odebug.h> 1#include <opie2/odebug.h>
2#include <opie2/multiauthmainwindow.h>
4 3
@@ -19,2 +18,4 @@
19 18
19#include "multiauthconfig.h"
20
20 21
@@ -58,5 +59,7 @@ class ToolButton : public QToolButton {
58 59
59 MultiauthGeneralConfig::MultiauthGeneralConfig(QWidget * parent, const char * name = "general Opie-multiauthentication config widget") 60 MultiauthGeneralConfig::MultiauthGeneralConfig(MultiauthConfig * parentConfig, QWidget * parent, const char * name = "general Opie-multiauthentication config widget")
60: QWidget(parent, name), onStart(0), onResume(0), nbSuccessMin(0) 61: QWidget(parent, name), m_onStart(0), m_onResume(0), m_noProtectConfig(0), m_explanScreens(0), m_nbSuccessMin(0), m_tryButton(0)
61{ 62{
63 // keep track of the MultiauthConfig parent in one of our attributes
64 m_parentConfig = parentConfig;
62 QVBoxLayout *vb = new QVBoxLayout(this); 65 QVBoxLayout *vb = new QVBoxLayout(this);
@@ -69,6 +72,6 @@ class ToolButton : public QToolButton {
69 QGridLayout *boxLayout = new QGridLayout( lockBox->layout() ); 72 QGridLayout *boxLayout = new QGridLayout( lockBox->layout() );
70 onStart = new QCheckBox( tr( "on Opie start" ), lockBox, "lock on opie start"); 73 m_onStart = new QCheckBox( tr( "on Opie start" ), lockBox, "lock on opie start");
71 onResume = new QCheckBox( tr( "on Opie resume" ), lockBox, "lock on opie resume"); 74 m_onResume = new QCheckBox( tr( "on Opie resume" ), lockBox, "lock on opie resume");
72 boxLayout->addWidget(onStart, 0, 0); 75 boxLayout->addWidget(m_onStart, 0, 0);
73 boxLayout->addWidget(onResume, 0, 1); 76 boxLayout->addWidget(m_onResume, 0, 1);
74 77
@@ -77,22 +80,21 @@ class ToolButton : public QToolButton {
77 QGridLayout *nbBoxLayout = new QGridLayout( nbBox->layout() ); 80 QGridLayout *nbBoxLayout = new QGridLayout( nbBox->layout() );
78 nbSuccessMin = new QSpinBox(nbBox); 81 m_nbSuccessMin = new QSpinBox(nbBox);
79 QLabel *lNbSuccessMin = new QLabel( tr( "Required successes" ), nbBox); 82 QLabel *lNbSuccessMin = new QLabel( tr( "Required successes" ), nbBox);
80 nbBoxLayout->addWidget(nbSuccessMin, 0, 0); 83 nbBoxLayout->addWidget(m_nbSuccessMin, 0, 0);
81 nbBoxLayout->addWidget(lNbSuccessMin, 0, 1); 84 nbBoxLayout->addWidget(lNbSuccessMin, 0, 1);
82 nbSuccessMin->setMinValue(1); // the max value is defined in MultiauthConfig constructor 85 m_nbSuccessMin->setMinValue(1); // the max value is defined in MultiauthConfig constructor
83 86
84 QGroupBox *devBox = new QGroupBox(0, Qt::Vertical, tr("Debug options"), this, "dev box"); 87 QGroupBox *devBox = new QGroupBox(0, Qt::Vertical, tr("Options"), this, "dev box");
85 vb->addWidget(devBox); 88 vb->addWidget(devBox);
86 QGridLayout *devBoxLayout = new QGridLayout( devBox->layout() ); 89 QGridLayout *devBoxLayout = new QGridLayout( devBox->layout() );
87 noProtectConfig = new QCheckBox( tr("Don't protect this config screen"), devBox, "don't protect config"); 90 m_noProtectConfig = new QCheckBox( tr("Don't protect this config screen"), devBox, "don't protect config");
88 explanScreens = new QCheckBox( tr("Show explanatory screens"), devBox, "Show explan. screens"); 91 m_explanScreens = new QCheckBox( tr("Show explanatory screens"), devBox, "Show explan. screens");
89 allowBypass = new QCheckBox( tr("Allow to bypass authentication"), devBox, "AllowBypass"); 92 devBoxLayout->addWidget(m_noProtectConfig, 0, 0);
90 QLabel *logicNote = new QLabel( "<p>" + tr("Note: the third option implies the second one") + "</p>", devBox ); 93 devBoxLayout->addWidget(m_explanScreens, 1, 0);
91 devBoxLayout->addWidget(noProtectConfig, 0, 0); 94
92 devBoxLayout->addWidget(explanScreens, 1, 0); 95 QVGroupBox *tryBox = new QVGroupBox(tr("Testing"), this, "try box");
93 devBoxLayout->addWidget(allowBypass, 2, 0); 96 vb->addWidget(tryBox);
94 devBoxLayout->addMultiCellWidget(logicNote, 3, 3, 0, 1); 97 m_tryButton = new QPushButton( tr("Test the authentication now"), tryBox, "try button");
95 98 connect( m_tryButton, SIGNAL(clicked()), this, SLOT(tryAuth()) );
96 connect( explanScreens, SIGNAL(toggled(bool)), this, SLOT(checkBypass()) ); 99
97 connect( allowBypass, SIGNAL(toggled(bool)), this, SLOT(checkScreens()) );
98} 100}
@@ -103,24 +105,38 @@ MultiauthGeneralConfig::~MultiauthGeneralConfig()
103 105
104/// Be sure that explanScreens is checked if allowBypass is 106/// launches the authentication process, as configured, with the option to bypass it
105void MultiauthGeneralConfig::checkScreens() 107void MultiauthGeneralConfig::tryAuth()
106{ 108{
107 if ( (allowBypass->isChecked() == true) && (explanScreens->isChecked() == false) ) 109 QMessageBox confirmSave(
108 explanScreens->setChecked(true); 110 tr("Attention"),
109} 111 "<p>" + tr("You must save your current settings before trying to authenticate. Press OK to accept and launch a simulated authentication process.") + "</p><p><em>" +
110 112 tr("If you don't like the result of this test, don't forget to change your settings before you exit the configuration application!") + "</em></p>",
111/// Be sure that allowBypass is not checked if explanScreens is not 113 QMessageBox::Warning,
112void MultiauthGeneralConfig::checkBypass() 114 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton,
113{ 115 0, QString::null, TRUE, WStyle_StaysOnTop);
114 if ( (allowBypass->isChecked() == true) && (explanScreens->isChecked() == false) ) 116 confirmSave.setButtonText(QMessageBox::Cancel, tr("Cancel"));
115 allowBypass->setChecked(false); 117 confirmSave.setButtonText(QMessageBox::Yes, tr("OK"));
116}
117
118
119 118
119 if ( confirmSave.exec() == QMessageBox::Yes)
120 {
121 owarn << "writing config as user accepted" << oendl;
122 m_parentConfig->writeConfigs();
123 owarn << "testing authentication" << oendl;
120 124
125 /* launch the authentication in debug, aka "allowBypass == true", mode
126 */
121 127
128 Opie::Security::MultiauthMainWindow win(true);
129 // resize the QDialog object so it fills all the screen
130 QRect desk = qApp->desktop()->geometry();
131 win.setGeometry( 0, 0, desk.width(), desk.height() );
122 132
133 // the authentication has already succeeded (without win interactions)
134 if ( win.isAlreadyDone() )
135 return;
123 136
137 win.exec();
124 138
139 }
125 140
141}
126 142
@@ -141,3 +157,3 @@ static void test_and_start() {
141 157
142 MultiauthConfig::MultiauthConfig(QWidget* par, const char* w, WFlags f) 158 MultiauthConfig::MultiauthConfig(QWidget* par, const char* w = "MultiauthConfig dialog", WFlags f = 0)
143: QDialog(par, w, TRUE, f), 159: QDialog(par, w, TRUE, f),
@@ -164,3 +180,3 @@ static void test_and_start() {
164 QVBoxLayout *layout = new QVBoxLayout( this ); 180 QVBoxLayout *layout = new QVBoxLayout( this );
165 m_mainTW = new Opie::Ui::OTabWidget( this ); 181 m_mainTW = new Opie::Ui::OTabWidget( this, "main tab widget" );
166 layout->addWidget(m_mainTW); 182 layout->addWidget(m_mainTW);
@@ -192,3 +208,3 @@ static void test_and_start() {
192 // general Opie multi-authentication configuration tab 208 // general Opie multi-authentication configuration tab
193 m_generalConfig = new MultiauthGeneralConfig(m_mainTW); 209 m_generalConfig = new MultiauthGeneralConfig(this, m_mainTW);
194 m_mainTW->addTab(m_generalConfig, "SettingsIcon", tr( "Authentication") ); 210 m_mainTW->addTab(m_generalConfig, "SettingsIcon", tr( "Authentication") );
@@ -243,3 +259,3 @@ static void test_and_start() {
243 // put the number of plugins as the max number of req. auth. 259 // put the number of plugins as the max number of req. auth.
244 m_generalConfig->nbSuccessMin->setMaxValue( pluginList.count() ); 260 m_generalConfig->m_nbSuccessMin->setMaxValue( pluginList.count() );
245 } 261 }
@@ -273,3 +289,4 @@ MultiauthConfig::~MultiauthConfig()
273 289
274void MultiauthConfig::accept() { 290/// saves the general and plugin(s) configurations
291void MultiauthConfig::writeConfigs() {
275 writeConfig(); 292 writeConfig();
@@ -280,3 +297,7 @@ void MultiauthConfig::accept() {
280 confWidget->writeConfig(); 297 confWidget->writeConfig();
298}
281 299
300/// on QDialog::accept, we save all the configurations and exit the QDialog normally
301void MultiauthConfig::accept() {
302 writeConfigs();
282 QDialog::accept(); 303 QDialog::accept();
@@ -316,8 +337,7 @@ void MultiauthConfig::readConfig()
316 pcfg->setGroup( "Misc" ); 337 pcfg->setGroup( "Misc" );
317 m_generalConfig->onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) ); 338 m_generalConfig->m_onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) );
318 m_generalConfig->onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) ); 339 m_generalConfig->m_onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) );
319 m_generalConfig->nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) ); 340 m_generalConfig->m_nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) );
320 m_generalConfig->noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) ); 341 m_generalConfig->m_noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) );
321 m_generalConfig->explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) ); 342 m_generalConfig->m_explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) );
322 m_generalConfig->allowBypass->setChecked( pcfg->readBoolEntry( "allowBypass", false ) );
323 343
@@ -425,8 +445,7 @@ void MultiauthConfig::writeConfig()
425 pcfg->setGroup( "Misc" ); 445 pcfg->setGroup( "Misc" );
426 pcfg->writeEntry( "onStart", m_generalConfig->onStart->isChecked() ); 446 pcfg->writeEntry( "onStart", m_generalConfig->m_onStart->isChecked() );
427 pcfg->writeEntry( "onResume", m_generalConfig->onResume->isChecked() ); 447 pcfg->writeEntry( "onResume", m_generalConfig->m_onResume->isChecked() );
428 pcfg->writeEntry( "nbSuccessMin", m_generalConfig->nbSuccessMin->text() ); 448 pcfg->writeEntry( "nbSuccessMin", m_generalConfig->m_nbSuccessMin->text() );
429 pcfg->writeEntry( "noProtectConfig", m_generalConfig->noProtectConfig->isChecked() ); 449 pcfg->writeEntry( "noProtectConfig", m_generalConfig->m_noProtectConfig->isChecked() );
430 pcfg->writeEntry( "explanScreens", m_generalConfig->explanScreens->isChecked() ); 450 pcfg->writeEntry( "explanScreens", m_generalConfig->m_explanScreens->isChecked() );
431 pcfg->writeEntry( "allowBypass", m_generalConfig->allowBypass->isChecked() );
432 } 451 }
@@ -581,3 +600,3 @@ void MultiauthConfig::restoreDefaults()
581 unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel")); 600 unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel"));
582 unrecbox.setButtonText(QMessageBox::Yes, tr("Ok")); 601 unrecbox.setButtonText(QMessageBox::Yes, tr("OK"));
583 602
diff --git a/core/settings/security/multiauthconfig.h b/core/settings/security/multiauthconfig.h
index 5287083..e64795c 100644
--- a/core/settings/security/multiauthconfig.h
+++ b/core/settings/security/multiauthconfig.h
@@ -59,2 +59,4 @@
59 59
60class MultiauthConfig;
61class MultiauthGeneralConfig;
60 62
@@ -65,12 +67,14 @@ class MultiauthGeneralConfig : public QWidget
65public: 67public:
66 MultiauthGeneralConfig(QWidget * parent, const char * name); 68 MultiauthGeneralConfig(MultiauthConfig * parentConfig, QWidget * parent, const char * name);
67 ~MultiauthGeneralConfig(); 69 ~MultiauthGeneralConfig();
68protected: 70protected:
69 QCheckBox *onStart, *onResume, *noProtectConfig, *explanScreens, *allowBypass; 71 QCheckBox *m_onStart, *m_onResume, *m_noProtectConfig, *m_explanScreens;
70 QSpinBox *nbSuccessMin; 72 QSpinBox *m_nbSuccessMin;
71private: 73private:
72 friend class MultiauthConfig; 74 friend class MultiauthConfig;
75 /// pointer to the MultiauthConfig that called us
76 MultiauthConfig *m_parentConfig;
77 QPushButton *m_tryButton;
73private slots: 78private slots:
74 void checkBypass(); 79 void tryAuth();
75 void checkScreens();
76}; 80};
@@ -86,3 +90,2 @@ public:
86 virtual ~MultiauthConfig(); 90 virtual ~MultiauthConfig();
87 void writeConfig();
88 QList<Opie::Security::MultiauthConfigWidget> configWidgetList; 91 QList<Opie::Security::MultiauthConfigWidget> configWidgetList;
@@ -95,2 +98,3 @@ protected slots:
95 void moveSelectedDown(); 98 void moveSelectedDown();
99 void writeConfigs();
96 100
@@ -106,2 +110,3 @@ private slots:
106private: 110private:
111 friend class MultiauthGeneralConfig;
107 /// the widget holding all the tabs (or pages) 112 /// the widget holding all the tabs (or pages)
@@ -126,2 +131,3 @@ private:
126 void readConfig(); 131 void readConfig();
132 void writeConfig();
127 void loadPlugins(); 133 void loadPlugins();
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
@@ -8,4 +8,7 @@ namespace Security {
8 8
9/// Initializes widgets according to allowBypass and explanScreens config 9/// Initializes widgets according to allowBypass argument (false by default) and explanScreens config
10MultiauthMainWindow::MultiauthMainWindow() 10/**
11 * \note if allowBypass is true, we will show explanatory screens anyway
12 */
13MultiauthMainWindow::MultiauthMainWindow(bool allowBypass = false)
11 : QDialog(0, "main Opie multiauth modal dialog", TRUE, 14 : QDialog(0, "main Opie multiauth modal dialog", TRUE,
@@ -19,7 +22,11 @@ MultiauthMainWindow::MultiauthMainWindow()
19 22
20 Config *pcfg = new Config("Security"); 23 if (allowBypass == true)
21 pcfg->setGroup("Misc"); 24 explanScreens = true;
22 explanScreens = pcfg->readBoolEntry("explanScreens", true); 25 else
23 allowBypass = pcfg->readBoolEntry("allowBypass", false); 26 {
24 delete pcfg; 27 Config *pcfg = new Config("Security");
28 pcfg->setGroup("Misc");
29 explanScreens = pcfg->readBoolEntry("explanScreens", true);
30 delete pcfg;
31 }
25 32
@@ -55,3 +62,3 @@ MultiauthMainWindow::MultiauthMainWindow()
55 // very important: we can close the widget through the quit button, and bypass authentication, only if allowBypass is set! 62 // very important: we can close the widget through the quit button, and bypass authentication, only if allowBypass is set!
56 message2 = new QLabel("<center><i>" + tr("Note: the 'exit' button should be removed for real protection, through Security config dialog") + ".</i></center>", this); 63 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);
57 layout->addWidget(message2); 64 layout->addWidget(message2);
@@ -116,6 +123,8 @@ void MultiauthMainWindow::proceed() {
116 // authentication has failed, explain that according to allowBypass 123 // authentication has failed, explain that according to allowBypass
117 message->setText( "<center><h3>" + tr("You have not succeeded enough authentication steps!") + "</h3></center>" ); 124 message->setText( "<center><h3>" + tr("You have <b>not</b> succeeded enough authentication steps!") + "</h3></center>" );
118 proceedButton->show(); 125 proceedButton->show();
119 if ( allowBypass == true ) 126 if ( allowBypass == true )
120 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>" ); 127 {
128 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>" );
129 message2->show();
121 } 130 }
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
@@ -57,3 +57,3 @@ class MultiauthMainWindow : public QDialog {
57 public: 57 public:
58 MultiauthMainWindow(); 58 MultiauthMainWindow(bool allowBypass = false);
59 ~MultiauthMainWindow(); 59 ~MultiauthMainWindow();