From: konrad Date: Thu, 24 Dec 2009 14:33:39 +0000 (+0000) Subject: start of SSL exception handling, to be continued... X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=f01268f599a66f7221f581cde1ed4d3155ea8838;p=web%2Fkonrad%2Fsmoke.git start of SSL exception handling, to be continued... git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@347 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/msinterface.cpp b/src/msinterface.cpp index 4c31080..1a7afe6 100644 --- a/src/msinterface.cpp +++ b/src/msinterface.cpp @@ -12,8 +12,11 @@ #include "msinterface.h" #include "main.h" +#include "sslexception.h" +#include #include +#include #include #include #include @@ -35,11 +38,14 @@ MSInterface::MSInterface(QString pid) ); m_host=set.value("hostname").toString(); m_hostkey=set.value("hostkey").toString(); + sslexcept=new MSslExceptions(dataDir()+"/sslexceptions.xml"); } MSInterface::~MSInterface() { logout(); + if(sslexcept)delete sslexcept; + sslexcept=0; } bool MSInterface::login(QString username,QString passwd) @@ -167,3 +173,19 @@ void MSInterface::initialize() //TODO: retrieve scripts script: ; } + +void MSInterface::sslErrors(const QList&errs) +{ + //get source of error + QHttp*src=qobject_cast(sender()); + if(!src)return; + //check against known exceptions + if(sslexcept->checksslexcept(errs)){ + src->ignoreSslErrors(); + return; + } + //message box + if(!didsslerror){ + QMessageBox::warning(0,tr("Connection Error"),tr("There were problems while authenticating the server. Aborting. Check your configuration.")); + } +} diff --git a/src/msinterface.h b/src/msinterface.h index 61ddefc..f4532a2 100644 --- a/src/msinterface.h +++ b/src/msinterface.h @@ -15,6 +15,8 @@ #include "MInterface.h" +class MSslExceptions; + /**the MagicSmoke specific interface class - enhances the basic interface by some functionality needed in the MagicSmoke context*/ class MSInterface:public MInterface { @@ -66,12 +68,16 @@ class MSInterface:public MInterface bool relogin(); /**sets the session id to be transmitted*/ void setSessionId(QString sid){m_sessid=sid;} + /**handles SSL errors*/ + virtual void sslErrors(const QList&); private: QString profileid,m_sessid,m_uname,m_passwd,m_host,m_hostkey; mutable QListuserrights; mutable QStringList userroles; QByteArray servertranslation; + MSslExceptions*sslexcept; + bool didsslerror; }; diff --git a/src/smoke.pro b/src/smoke.pro index c6e936e..fab326a 100644 --- a/src/smoke.pro +++ b/src/smoke.pro @@ -47,7 +47,8 @@ SOURCES = \ office.cpp \ moneylog.cpp \ domquery.cpp \ - msinterface.cpp + msinterface.cpp \ + sslexception.cpp HEADERS = \ main.h \ @@ -75,7 +76,8 @@ HEADERS = \ office.h \ moneylog.h \ domquery.h \ - msinterface.h + msinterface.h \ + sslexception.h RESOURCES += files.qrc diff --git a/src/sslexception.cpp b/src/sslexception.cpp new file mode 100644 index 0000000..c9decc0 --- /dev/null +++ b/src/sslexception.cpp @@ -0,0 +1,49 @@ +// +// C++ Implementation: sslexception +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2009 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "sslexception.h" + +#include +#include +#include +#include +#include +#include + +MSslExceptions::MSslExceptions(QString p) +{ + path=p; + //load... + QFile fd(p); + if(fd.open(QIODevice::ReadOnly)){ + QDomDocument doc; + if(!doc.setContent(&fd))return; + fd.close(); + QDomElement root=doc.documentElement(); + } +} + +void MSslExceptions::savesslexcept(){} + +void MSslExceptions::showdialog(QWidget*){} + +bool MSslExceptions::checksslexcept(const QList&errs) +{ + qDebug("!!!!!!!!!!!!!!!!!!! %i SSL Exceptions!",errs.size()); + return true; + for(int i=0;i, (C) 2009 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef MAGICSMOKE_SSLEXCEPTION_H +#define MAGICSMOKE_SSLEXCEPTION_H + +#include +#include +#include +#include +#include + +class QWidget; + +class MSslExceptions +{ + public: + MSslExceptions(QString path); + + //ssl helper: save the exceptions + void savesslexcept(); + //ssl helper: check errors agains the exception list + bool checksslexcept(const QList&); + + void showdialog(QWidget*); + + private: + QMap > sslexcept; + QString path; +}; + +#endif diff --git a/src/wbase/WInterface.cpp b/src/wbase/WInterface.cpp index f410437..aee9cf8 100644 --- a/src/wbase/WInterface.cpp +++ b/src/wbase/WInterface.cpp @@ -56,7 +56,7 @@ QMap WInterface::headers(QString)const return QMap(); } -void WInterface::sslErrors(const QList&errs) +void WInterface::sslErrors(const QList&) { QHttp*src=qobject_cast(sender()); if(!src)return; diff --git a/src/wbase/WInterface.h b/src/wbase/WInterface.h index 2f51c3a..100f9db 100644 --- a/src/wbase/WInterface.h +++ b/src/wbase/WInterface.h @@ -82,8 +82,8 @@ class WInterface:public QObject /**sets the URL of the interface*/ void setUrl(QUrl u){m_url=u;} - /**handles SSL errors*/ - void sslErrors(const QList&); + /**handles SSL errors, per default ignores them, overwrite it if you need more sophisticated behavior*/ + virtual void sslErrors(const QList&); private: static QMapinst;