From 73f00336178a9f312bac2992649120d462e0ac2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Wed, 11 Dec 2019 01:41:26 +0100 Subject: kopete: Restore the MSN protocol because a replacement MSN server was created. This reverts commits 0486034738 - 2d5f9c55da and f6fd4ab6c0. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- kopete/protocols/msn/msnsecureloginhandler.cpp | 131 +++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 kopete/protocols/msn/msnsecureloginhandler.cpp (limited to 'kopete/protocols/msn/msnsecureloginhandler.cpp') diff --git a/kopete/protocols/msn/msnsecureloginhandler.cpp b/kopete/protocols/msn/msnsecureloginhandler.cpp new file mode 100644 index 00000000..f8431f9f --- /dev/null +++ b/kopete/protocols/msn/msnsecureloginhandler.cpp @@ -0,0 +1,131 @@ +/* + msnsecureloginhandler.cpp - SSL login for MSN protocol + + Copyright (c) 2005 by Michaël Larouche + + Kopete (c) 2002-2005 by the Kopete developers + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#include "msnsecureloginhandler.h" + +// TQt includes +#include + +// KDE includes +#include +#include +#include + +MSNSecureLoginHandler::MSNSecureLoginHandler(const TQString &accountId, const TQString &password, const TQString &authParameters) + : m_password(password), m_accountId(accountId), m_authentification(authParameters) +{ + +} + +MSNSecureLoginHandler::~MSNSecureLoginHandler() +{ +// kdDebug(14140) << k_funcinfo << endl; +} + +void MSNSecureLoginHandler::login() +{ + // Retrive the login server. + // Do a reload and don't show the progress. + TDEIO::Job *getLoginServer = TDEIO::get(KURL("https://nexus.passport.com/rdr/pprdr.asp"), true, false); + + getLoginServer->addMetaData("cookies", "manual"); + getLoginServer->addMetaData("cache", "reload"); + getLoginServer->addMetaData("PropagateHttpHeader", "true"); + + connect(getLoginServer, TQT_SIGNAL(result(TDEIO::Job *)), this, TQT_SLOT(slotLoginServerReceived(TDEIO::Job* ))); +} + +void MSNSecureLoginHandler::slotLoginServerReceived(TDEIO::Job *loginJob) +{ + if(!loginJob->error()) + { + // Retrive the HTTP header + TQString httpHeaders = loginJob->queryMetaData("HTTP-Headers"); + + // Get the login URL using TQRegExp + TQRegExp rx("PassportURLs: DARealm=(.*),DALogin=(.*),DAReg="); + rx.search(httpHeaders); + + // Set the loginUrl and loginServer + TQString loginUrl = rx.cap(2); + TQString loginServer = loginUrl.section('/', 0, 0); + + kdDebug(14140) << k_funcinfo << loginServer << endl; + + TQString authURL = "https://" + loginUrl; + + TDEIO::Job *authJob = TDEIO::get(KURL(authURL), true, false); + authJob->addMetaData("cookies", "manual"); + + TQString authRequest = "Authorization: Passport1.4 " + "OrgVerb=GET," + "OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom," + "sign-in=" + KURL::encode_string(m_accountId) + + ",pwd=" + KURL::encode_string( m_password ).replace(',',"%2C") + + "," + m_authentification + "\r\n"; + +// warning, this debug contains the password +// kdDebug(14140) << k_funcinfo << "Auth request: " << authRequest << endl; + + authJob->addMetaData("customHTTPHeader", authRequest); + authJob->addMetaData("SendLanguageSettings", "false"); + authJob->addMetaData("PropagateHttpHeader", "true"); + authJob->addMetaData("cookies", "manual"); + authJob->addMetaData("cache", "reload"); + + connect(authJob, TQT_SIGNAL(result(TDEIO::Job *)), this, TQT_SLOT(slotTweenerReceived(TDEIO::Job* ))); + } + else + { + kdDebug(14140) << k_funcinfo << loginJob->errorString() << endl; + + emit loginFailed(); + } +} + +void MSNSecureLoginHandler::slotTweenerReceived(TDEIO::Job *authJob) +{ + if(!authJob->error()) + { + TQString httpHeaders = authJob->queryMetaData("HTTP-Headers"); + +// kdDebug(14140) << k_funcinfo << "HTTP headers: " << httpHeaders << endl; + + // Check if we get "401 Unauthorized", thats means it's a bad password. + if(httpHeaders.contains(TQString::fromUtf8("401 Unauthorized"))) + { +// kdDebug(14140) << k_funcinfo << "MSN Login Bad password." << endl; + emit loginBadPassword(); + } + else + { + TQRegExp rx("from-PP='(.*)'"); + rx.search(httpHeaders); + TQString ticket = rx.cap(1); + + // kdDebug(14140) << k_funcinfo << "Received ticket: " << ticket << endl; + + emit loginSuccesful(ticket); + } + } + else + { + kdDebug(14140) << k_funcinfo << authJob->errorString() << endl; + + emit loginFailed(); + } +} +#include "msnsecureloginhandler.moc" -- cgit v1.2.1