/*************************************************************************** * Copyright (C) 2006 by Michael Kaufmann * * michael@enlighter.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include "../config.h" #endif #ifndef AUTHMANAGER_H #define AUTHMANAGER_H #include #include #include class kovpn; /** @author Michael Kaufmann */ class authManager : public QWidget { Q_OBJECT public: static authManager * manager(); /* deprecated */ static authManager * self(); ~authManager(); /** * A Plugin can request a username and a password using this method. The auth manager cares * about where the auth data comes from (e.g. from direct user input or kwallet). Ressource * is used for the user that he/she knows what auth data is needed and for storing the data * using kwallet. The return value is false if no auth data was found (e.g. user pressed * the cancel button) */ bool authRequest( const QString &ressource, const QString &type, QString &username, QString &password, bool failure = false, const QString &message = QString::null, bool saveAccount = false ); /** * A Plugin can request a password using this method e.g. for a private key passphrase. The * manager cares about where the password comes from. Ressource is used for the user that he * knows what password is needed and for storing the data using kwallet. The return value is * false if no password was found (e.g. user pressed the cancel button). */ bool authRequest( const QString &ressource, const QString &type, QString &passphrase, bool failure = false, const QString &message = QString::null, bool savePassphrase = false ); /** * Used in kovpnsetup to create a password. */ bool newPassword( const QString &ressource, const QString &type, QString &password, const QString &message = QString::null, bool savePassword = false ); public slots: void walletClosed(); signals: void error( QString message ); void authRequestGUI( bool &cancel, bool &failure, const QString &ressource, QString &password, QString &username, const QString &message ); void passRequestGUI( bool &cancel, bool &failure, const QString &ressource, QString &passphrase, const QString &message ); void newPasswordGUI( bool &cancel, bool &failure, const QString &ressource, QString &password, const QString &message ); protected: void debug( const QString & method, const QString & message = "I was called" ); private: authManager(); bool mSaveAccount; bool mSavePassphrase; KWallet::Wallet * wallet; bool authRequestGUI( bool & cancel, QString &username, QString &password, const QString &ressource, const QString &message = QString::null ); bool passRequestGUI( bool & cancel, QString &passphrase, const QString &ressource, const QString &message = QString::null ); bool newPasswordGUI( bool & cancel, QString &password, const QString &ressource, const QString &message = QString::null ); KWallet::Wallet * openWallet(); bool storeInWallet( const QString &ressource, const QString &type, const QString &password, const QString &username = QString::null ); }; #endif