summaryrefslogtreecommitdiffstats
path: root/tdm/kfrontend/kgverify.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tdm/kfrontend/kgverify.cpp')
-rw-r--r--tdm/kfrontend/kgverify.cpp282
1 files changed, 213 insertions, 69 deletions
diff --git a/tdm/kfrontend/kgverify.cpp b/tdm/kfrontend/kgverify.cpp
index 46b89e9c5..93bcce27a 100644
--- a/tdm/kfrontend/kgverify.cpp
+++ b/tdm/kfrontend/kgverify.cpp
@@ -30,6 +30,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "themer/tdmthemer.h"
#include "themer/tdmitem.h"
+#include "themer/tdmlabel.h"
+
+#include <ksslcertificate.h>
+
+#include <tdehardwaredevices.h>
+#include <tdecryptographiccarddevice.h>
#include <tdeapplication.h>
#include <tdelocale.h>
@@ -66,30 +72,34 @@ void KGVerifyHandler::updateStatus( bool, bool, int )
{
}
-KGVerify::KGVerify( KGVerifyHandler *_handler, KdmThemer *_themer,
- TQWidget *_parent, TQWidget *_predecessor,
- const TQString &_fixedUser,
- const PluginList &_pluginList,
- KGreeterPlugin::Function _func,
- KGreeterPlugin::Context _ctx )
+KGVerify::KGVerify(KGVerifyHandler *_handler, KdmThemer *_themer,
+ TQWidget *_parent, TQWidget *_predecessor,
+ const TQString &_fixedUser,
+ const PluginList &_pluginList,
+ KGreeterPlugin::Function _func,
+ KGreeterPlugin::Context _ctx)
: inherited()
- , coreLock( 0 )
- , fixedEntity( _fixedUser )
- , pluginList( _pluginList )
- , handler( _handler )
- , themer( _themer )
- , parent( _parent )
- , predecessor( _predecessor )
- , plugMenu( 0 )
- , curPlugin( -1 )
- , timedLeft( 0 )
- , func( _func )
- , ctx( _ctx )
- , enabled( true )
- , running( false )
- , suspended( false )
- , failed( false )
- , isClear( true )
+ , coreLock(0)
+ , fixedEntity(_fixedUser)
+ , pluginList(_pluginList)
+ , handler(_handler)
+ , themer(_themer)
+ , parent(_parent)
+ , predecessor(_predecessor)
+ , plugMenu(0)
+ , curPlugin(-1)
+ , timedLeft(0)
+ , func(_func)
+ , ctx(_ctx)
+ , enabled(true)
+ , running(false)
+ , suspended(false)
+ , failed(false)
+ , isClear(true)
+ , inGreeterPlugin(false)
+ , abortRequested(false)
+ , cardLoginInProgress(false)
+ , cardLoginDevice(NULL)
{
connect( &timer, TQT_SIGNAL(timeout()), TQT_SLOT(slotTimeout()) );
connect( kapp, TQT_SIGNAL(activity()), TQT_SLOT(slotActivity()) );
@@ -269,6 +279,14 @@ KGVerify::setUser( const TQString &user )
}
void
+KGVerify::lockUserEntry(const bool lock)
+{
+ // assert( fixedEntity.isEmpty() );
+ Debug( "%s->lockUserEntry(%\"s)\n", pName.data(), lock );
+ greet->lockUserEntry(lock);
+}
+
+void
KGVerify::setPassword( const TQString &pass )
{
greet->setPassword( pass );
@@ -276,6 +294,26 @@ KGVerify::setPassword( const TQString &pass )
}
void
+KGVerify::setInfoMessageDisplay(bool on)
+{
+ // assert( fixedEntity.isEmpty() );
+ Debug( "%s->setInfoMessageDisplay(%\"s)\n", pName.data(), on );
+ greet->setInfoMessageDisplay(on);
+}
+
+void
+KGVerify::setPasswordPrompt(const TQString &prompt)
+{
+ greet->setPasswordPrompt(prompt);
+ if (prompt != TQString::null) {
+ setPassPromptText(prompt, false);
+ }
+ else {
+ setPassPromptText(TQString::null, true);
+ }
+}
+
+void
KGVerify::start()
{
authTok = (func == KGreeterPlugin::ChAuthTok);
@@ -285,8 +323,10 @@ KGVerify::start()
if (!_autoLoginAgain)
_autoLoginDelay = 0, timeable = false;
return;
- } else
+ }
+ else if (!cardLoginInProgress) {
applyPreset();
+ }
}
running = true;
Debug( "%s->start()\n", pName.data() );
@@ -350,30 +390,41 @@ KGVerify::doReject( bool initial )
{
// assert( !cont );
if (running) {
- Debug( "%s->abort()\n", pName.data() );
+ Debug("%s->abort()\n", pName.data());
greet->abort();
}
handler->verifyClear();
- Debug( "%s->clear()\n", pName.data() );
+ Debug("%s->clear()\n", pName.data());
greet->clear();
curUser = TQString::null;
- if (!scheduleAutoLogin( initial )) {
+ if (!scheduleAutoLogin(initial)) {
isClear = !(isClear && applyPreset());
if (running) {
Debug( "%s->start()\n", pName.data() );
greet->start();
}
- if (!failed)
+ if (!failed) {
timer.stop();
+ }
}
}
void // not a slot - called manually by greeter
KGVerify::reject()
{
+ inGreeterPlugin = false;
doReject( true );
}
+void // not a slot - called manually by greeter
+KGVerify::requestAbort()
+{
+ abortRequested = true;
+ if (inGreeterPlugin) {
+ greet->next();
+ }
+}
+
void
KGVerify::setEnabled( bool on )
{
@@ -478,27 +529,28 @@ KGVerify::VErrBox( TQWidget *parent, const TQString &user, const char *msg )
}
void // private static
-KGVerify::VInfoBox( TQWidget *parent, const TQString &user, const char *msg )
+KGVerify::VInfoBox(TQWidget *parent, const TQString &user, const char *msg)
{
TQString mesg = TQString::fromLocal8Bit( msg );
TQRegExp rx( "^Warning: your account will expire in (\\d+) day" );
- if (rx.search( mesg ) >= 0) {
- int expire = rx.cap( 1 ).toInt();
+ if (rx.search(mesg) >= 0) {
+ int expire = rx.cap(1).toInt();
mesg = expire ?
i18n("Your account expires tomorrow.",
"Your account expires in %n days.", expire) :
i18n("Your account expires today.");
- } else {
+ }
+ else {
rx.setPattern( "^Warning: your password will expire in (\\d+) day" );
- if (rx.search( mesg ) >= 0) {
- int expire = rx.cap( 1 ).toInt();
+ if (rx.search(mesg) >= 0) {
+ int expire = rx.cap(1).toInt();
mesg = expire ?
i18n("Your password expires tomorrow.",
"Your password expires in %n days.", expire) :
i18n("Your password expires today.");
}
}
- VMsgBox( parent, user, infobox, mesg );
+ VMsgBox(parent, user, infobox, mesg);
}
bool // public static
@@ -597,9 +649,40 @@ KGVerify::handleVerify()
Debug( " echo = %d\n", echo );
ndelay = GRecvInt();
Debug( " ndelay = %d\n%s->textPrompt(...)\n", ndelay, pName.data() );
- greet->textPrompt( msg, echo, ndelay );
- if (msg)
- free( msg );
+ if (abortRequested) {
+ inGreeterPlugin = true;
+ greet->textPrompt("", echo, ndelay);
+ inGreeterPlugin = !ndelay;
+ abortRequested = false;
+ }
+ else {
+ if (msg && (msg[0] != 0)) {
+ // Reset password entry and change text
+ setPassPromptText(msg);
+ greet->start();
+ inGreeterPlugin = true;
+ greet->textPrompt(msg, echo, ndelay);
+ inGreeterPlugin = !ndelay;
+
+ if (cardLoginInProgress) {
+ TQString autoPIN = cardLoginDevice->autoPIN();
+ if (autoPIN != TQString::null) {
+ // Initiate login
+ setPassword(autoPIN);
+ accept();
+ }
+ cardLoginInProgress = false;
+ }
+ }
+ else {
+ inGreeterPlugin = true;
+ greet->textPrompt(msg, echo, ndelay);
+ inGreeterPlugin = !ndelay;
+ }
+ }
+ if (msg) {
+ free(msg);
+ }
return;
case V_GET_BINARY:
Debug( " V_GET_BINARY\n" );
@@ -607,9 +690,17 @@ KGVerify::handleVerify()
Debug( " %d bytes prompt\n", ret );
ndelay = GRecvInt();
Debug( " ndelay = %d\n%s->binaryPrompt(...)\n", ndelay, pName.data() );
- greet->binaryPrompt( msg, ndelay );
- if (msg)
- free( msg );
+ if (abortRequested) {
+ gplugReturnBinary(NULL);
+ }
+ else {
+ inGreeterPlugin = true;
+ greet->binaryPrompt( msg, ndelay );
+ inGreeterPlugin = !ndelay;
+ }
+ if (msg) {
+ free(msg);
+ }
return;
}
@@ -622,11 +713,12 @@ KGVerify::handleVerify()
curUser = user = TQString::fromLocal8Bit( msg );
// greet needs this to be able to return something useful from
// getEntity(). but the backend is still unable to tell a domain ...
- Debug( " %s->setUser(%\"s)\n", pName.data(), user.latin1() );
+ Debug(" %s->setUser(%\"s)\n", pName.data(), user.latin1());
greet->setUser( curUser );
- handler->verifySetUser( curUser );
- if (msg)
- free( msg );
+ handler->verifySetUser(curUser);
+ if (msg) {
+ free(msg);
+ }
continue;
case V_PRE_OK: // this is only for func == AuthChAuthTok
Debug( " V_PRE_OK\n" );
@@ -636,8 +728,10 @@ KGVerify::handleVerify()
// is not implemented yet.
authTok = true;
cont = true;
- Debug( "%s->succeeded()\n", pName.data() );
+ Debug("%s->succeeded()\n", pName.data());
greet->succeeded();
+ abortRequested = false;
+ inGreeterPlugin = false;
continue;
case V_CHTOK_AUTH:
Debug( " V_CHTOK_AUTH\n" );
@@ -648,14 +742,17 @@ KGVerify::handleVerify()
Debug( " V_CHTOK\n" );
nfunc = KGreeterPlugin::ChAuthTok;
user = TQString::null;
- dchtok:
+ dchtok:
{
timer.stop();
Debug( "%s->succeeded()\n", pName.data() );
greet->succeeded();
+ abortRequested = false;
+ inGreeterPlugin = false;
KGChTok chtok( parent, user, pluginList, curPlugin, nfunc, KGreeterPlugin::Login );
- if (!chtok.exec())
+ if (!chtok.exec()) {
goto retry;
+ }
handler->verifyOk();
return;
}
@@ -663,24 +760,39 @@ KGVerify::handleVerify()
Debug( " V_MSG_ERR\n" );
msg = GRecvStr();
Debug( " %s->textMessage(%\"s, true)\n", pName.data(), msg );
+ inGreeterPlugin = true;
if (!greet->textMessage( msg, true )) {
+ inGreeterPlugin = false;
Debug( " message passed\n" );
- VErrBox( parent, user, msg );
- } else
+ if (!abortRequested) {
+ VErrBox( parent, user, msg );
+ }
+ }
+ else {
+ inGreeterPlugin = false;
Debug( " message swallowed\n" );
- if (msg)
- free( msg );
+ }
+ if (msg) {
+ free(msg);
+ }
continue;
case V_MSG_INFO:
Debug( " V_MSG_INFO\n" );
msg = GRecvStr();
Debug( " %s->textMessage(%\"s, false)\n", pName.data(), msg );
+ inGreeterPlugin = true;
if (!greet->textMessage( msg, false )) {
+ inGreeterPlugin = false;
Debug( " message passed\n" );
- VInfoBox( parent, user, msg );
- } else
- Debug( " message swallowed\n" );
- free( msg );
+ if (!abortRequested) {
+ VInfoBox(parent, user, msg);
+ }
+ }
+ else {
+ inGreeterPlugin = false;
+ Debug(" message swallowed\n");
+ }
+ free(msg);
continue;
}
@@ -698,6 +810,8 @@ KGVerify::handleVerify()
if (ent != fixedEntity) {
Debug( "%s->failed()\n", pName.data() );
greet->failed();
+ abortRequested = false;
+ inGreeterPlugin = false;
MsgBox( sorrybox,
i18n("Authenticated user (%1) does not match requested user (%2).\n")
.arg( ent ).arg( fixedEntity ) );
@@ -706,12 +820,19 @@ KGVerify::handleVerify()
}
Debug( "%s->succeeded()\n", pName.data() );
greet->succeeded();
+ abortRequested = false;
+ inGreeterPlugin = false;
handler->verifyOk();
return;
}
Debug( "%s->failed()\n", pName.data() );
greet->failed();
+ abortRequested = false;
+ inGreeterPlugin = false;
+
+ // Reset password prompt text
+ setPassPromptText(TQString::null, true);
if (ret == V_AUTH) {
Debug( " V_AUTH\n" );
@@ -730,23 +851,43 @@ KGVerify::handleVerify()
running = true;
Debug( "%s->start()\n", pName.data() );
greet->start();
- if (!cont)
+ if (!cont) {
return;
+ }
user = TQString::null;
}
}
+void KGVerify::setPassPromptText(TQString text, bool use_default_text) {
+ if (themer) {
+ KdmItem* password_label = themer->findNode("password-label");
+ if (password_label) {
+ KdmLabel* pass_label = static_cast<KdmLabel*>(password_label);
+ if (use_default_text) {
+ pass_label->setText(pass_label->lookupStock("password-label"));
+ }
+ else {
+ pass_label->setText(text);
+ }
+ pass_label->update();
+ themer->updateGeometry(true);
+ static_cast<TQWidget *>(themer->parent())->repaint(true);
+ }
+ }
+}
+
void
KGVerify::gplugReturnText( const char *text, int tag )
{
- Debug( "%s: gplugReturnText(%\"s, %d)\n", pName.data(),
- tag & V_IS_SECRET ? "<masked>" : text, tag );
- GSendStr( text );
+ Debug("%s: gplugReturnText(%\"s, %d)\n", pName.data(), tag & V_IS_SECRET ? "<masked>" : text, tag);
+ GSendStr(text);
if (text) {
- GSendInt( tag );
+ GSendInt(tag);
handleVerify();
- } else
+ }
+ else {
coreLock = 0;
+ }
}
void
@@ -755,12 +896,13 @@ KGVerify::gplugReturnBinary( const char *data )
if (data) {
unsigned const char *up = (unsigned const char *)data;
int len = up[3] | (up[2] << 8) | (up[1] << 16) | (up[0] << 24);
- Debug( "%s: gplugReturnBinary(%d bytes)\n", pName.data(), len );
- GSendArr( len, data );
+ Debug("%s: gplugReturnBinary(%d bytes)\n", pName.data(), len);
+ GSendArr(len, data);
handleVerify();
- } else {
- Debug( "%s: gplugReturnBinary(NULL)\n", pName.data() );
- GSendArr( 0, 0 );
+ }
+ else {
+ Debug("%s: gplugReturnBinary(NULL)\n", pName.data());
+ GSendArr(0, 0);
coreLock = 0;
}
}
@@ -965,8 +1107,9 @@ KGStdVerify::slotPluginSelected( int id )
delete greet;
selectPlugin( id );
handler->verifyPluginChanged( id );
- if (running)
+ if (running) {
start();
+ }
parent->setUpdatesEnabled( true );
}
}
@@ -1064,8 +1207,9 @@ KGThemedVerify::slotPluginSelected( int id )
delete greet;
selectPlugin( id );
handler->verifyPluginChanged( id );
- if (running)
+ if (running) {
start();
+ }
}
}