Compare commits

...

4 Commits

Author SHA1 Message Date
Kevin Yue
337a94efcd Release 1.2.4 2020-05-31 12:15:06 +08:00
Kevin Yue
cf34f9f70f Improve the authentication workflow (#18) 2020-05-31 12:14:56 +08:00
Kevin Yue
3a790cdc63 Release v1.2.3 2020-05-30 23:00:38 +08:00
Kevin Yue
73925fd1e2 Add more logs to debug the portal login (#16) 2020-05-30 22:58:58 +08:00
13 changed files with 142 additions and 68 deletions

View File

@@ -23,6 +23,8 @@ GatewayAuthenticator::~GatewayAuthenticator()
void GatewayAuthenticator::authenticate() void GatewayAuthenticator::authenticate()
{ {
PLOGI << "Start gateway authentication...";
LoginParams params; LoginParams params;
params.setUser(portalConfig.username()); params.setUser(portalConfig.username());
params.setPassword(portalConfig.password()); params.setPassword(portalConfig.password());
@@ -118,6 +120,8 @@ void GatewayAuthenticator::normalAuth(QString labelUsername, QString labelPasswo
void GatewayAuthenticator::onPerformNormalLogin(const QString &username, const QString &password) void GatewayAuthenticator::onPerformNormalLogin(const QString &username, const QString &password)
{ {
PLOGI << "Start to perform normal login...";
normalLoginWindow->setProcessing(true); normalLoginWindow->setProcessing(true);
LoginParams params; LoginParams params;
params.setUser(username); params.setUser(username);

View File

@@ -97,6 +97,8 @@ void GPClient::initVpnStatus() {
void GPClient::populateGatewayMenu() void GPClient::populateGatewayMenu()
{ {
PLOGI << "Populating the Switch Gateway menu...";
const QList<GPGateway> gateways = allGateways(); const QList<GPGateway> gateways = allGateways();
gatewaySwitchMenu->clear(); gatewaySwitchMenu->clear();
@@ -200,6 +202,8 @@ void GPClient::onGatewayChanged(QAction *action)
void GPClient::doConnect() void GPClient::doConnect()
{ {
PLOGI << "Start connecting...";
const QString btnText = ui->connectButton->text(); const QString btnText = ui->connectButton->text();
const QString portal = this->portal(); const QString portal = this->portal();
@@ -214,16 +218,19 @@ void GPClient::doConnect()
// Login to the previously saved gateway // Login to the previously saved gateway
if (!currentGateway().name().isEmpty()) { if (!currentGateway().name().isEmpty()) {
PLOGI << "Start gateway login using the previously saved gateway...";
isQuickConnect = true; isQuickConnect = true;
gatewayLogin(); gatewayLogin();
} else { } else {
// Perform the portal login // Perform the portal login
PLOGI << "Start portal login...";
portalLogin(); portalLogin();
} }
} else { } else {
PLOGI << "Start disconnecting the VPN...";
ui->statusLabel->setText("Disconnecting..."); ui->statusLabel->setText("Disconnecting...");
updateConnectionStatus(VpnStatus::pending); updateConnectionStatus(VpnStatus::pending);
vpn->disconnect(); vpn->disconnect();
} }
} }
@@ -236,6 +243,7 @@ void GPClient::portalLogin()
connect(portalAuth, &PortalAuthenticator::success, this, &GPClient::onPortalSuccess); connect(portalAuth, &PortalAuthenticator::success, this, &GPClient::onPortalSuccess);
// Prelogin failed on the portal interface, try to treat the portal as a gateway interface // Prelogin failed on the portal interface, try to treat the portal as a gateway interface
connect(portalAuth, &PortalAuthenticator::preloginFailed, this, &GPClient::onPortalPreloginFail); connect(portalAuth, &PortalAuthenticator::preloginFailed, this, &GPClient::onPortalPreloginFail);
connect(portalAuth, &PortalAuthenticator::portalConfigFailed, this, &GPClient::onPortalConfigFail);
// Portal login failed // Portal login failed
connect(portalAuth, &PortalAuthenticator::fail, this, &GPClient::onPortalFail); connect(portalAuth, &PortalAuthenticator::fail, this, &GPClient::onPortalFail);
@@ -244,18 +252,49 @@ void GPClient::portalLogin()
portalAuth->authenticate(); portalAuth->authenticate();
} }
void GPClient::onPortalSuccess(const PortalConfigResponse portalConfig, const GPGateway gateway, QList<GPGateway> allGateways) void GPClient::onPortalSuccess(const PortalConfigResponse portalConfig, const QString region)
{ {
this->portalConfig = portalConfig; PLOGI << "Portal authentication succeeded.";
setAllGateways(allGateways);
// No gateway found in protal configuration
if (portalConfig.allGateways().size() == 0) {
PLOGI << "No gateway found in portal configuration, treat the portal address as a gateway.";
tryGatewayLogin();
return;
}
GPGateway gateway = filterPreferredGateway(portalConfig.allGateways(), region);
setAllGateways(portalConfig.allGateways());
setCurrentGateway(gateway); setCurrentGateway(gateway);
this->portalConfig = portalConfig;
gatewayLogin(); gatewayLogin();
} }
void GPClient::onPortalPreloginFail() void GPClient::onPortalPreloginFail(const QString msg)
{ {
PLOGI << "Portal prelogin failed, try to preform login on the the gateway interface..."; PLOGI << "Portal prelogin failed: " << msg;
tryGatewayLogin();
}
void GPClient::onPortalConfigFail(const QString msg)
{
PLOGI << "Failed to get the portal configuration, " << msg << " Treat the portal address as gateway.";
tryGatewayLogin();
}
void GPClient::onPortalFail(const QString &msg)
{
if (!msg.isEmpty()) {
openMessageBox("Portal authentication failed.", msg);
}
updateConnectionStatus(VpnStatus::disconnected);
}
void GPClient::tryGatewayLogin()
{
PLOGI << "Try to preform login on the the gateway interface...";
// Treat the portal input as the gateway address // Treat the portal input as the gateway address
GPGateway g; GPGateway g;
@@ -271,18 +310,11 @@ void GPClient::onPortalPreloginFail()
gatewayLogin(); gatewayLogin();
} }
void GPClient::onPortalFail(const QString &msg)
{
if (!msg.isEmpty()) {
openMessageBox("Portal authentication failed.", msg);
}
updateConnectionStatus(VpnStatus::disconnected);
}
// Login to the gateway // Login to the gateway
void GPClient::gatewayLogin() void GPClient::gatewayLogin()
{ {
PLOGI << "Performing gateway login...";
GatewayAuthenticator *gatewayAuth = new GatewayAuthenticator(currentGateway().address(), portalConfig); GatewayAuthenticator *gatewayAuth = new GatewayAuthenticator(currentGateway().address(), portalConfig);
connect(gatewayAuth, &GatewayAuthenticator::success, this, &GPClient::onGatewaySuccess); connect(gatewayAuth, &GatewayAuthenticator::success, this, &GPClient::onGatewaySuccess);
@@ -341,7 +373,6 @@ bool GPClient::connected() const
return statusText.contains("Connected") && !statusText.contains("Not"); return statusText.contains("Connected") && !statusText.contains("Not");
} }
QList<GPGateway> GPClient::allGateways() const QList<GPGateway> GPClient::allGateways() const
{ {
const QString gatewaysJson = settings::get(portal() + "_gateways").toString(); const QString gatewaysJson = settings::get(portal() + "_gateways").toString();
@@ -350,6 +381,8 @@ QList<GPGateway> GPClient::allGateways() const
void GPClient::setAllGateways(QList<GPGateway> gateways) void GPClient::setAllGateways(QList<GPGateway> gateways)
{ {
PLOGI << "Updating all the gateways...";
settings::save(portal() + "_gateways", GPGateway::serialize(gateways)); settings::save(portal() + "_gateways", GPGateway::serialize(gateways));
populateGatewayMenu(); populateGatewayMenu();
} }
@@ -368,6 +401,8 @@ GPGateway GPClient::currentGateway() const
void GPClient::setCurrentGateway(const GPGateway gateway) void GPClient::setCurrentGateway(const GPGateway gateway)
{ {
PLOGI << "Updating the current gateway to " << gateway.name();
settings::save(portal() + "_selectedGateway", gateway.name()); settings::save(portal() + "_selectedGateway", gateway.name());
populateGatewayMenu(); populateGatewayMenu();
} }

View File

@@ -30,8 +30,9 @@ private slots:
void onSystemTrayActivated(QSystemTrayIcon::ActivationReason reason); void onSystemTrayActivated(QSystemTrayIcon::ActivationReason reason);
void onGatewayChanged(QAction *action); void onGatewayChanged(QAction *action);
void onPortalSuccess(const PortalConfigResponse portalConfig, const GPGateway gateway, QList<GPGateway> allGateways); void onPortalSuccess(const PortalConfigResponse portalConfig, const QString region);
void onPortalPreloginFail(); void onPortalPreloginFail(const QString msg);
void onPortalConfigFail(const QString msg);
void onPortalFail(const QString &msg); void onPortalFail(const QString &msg);
void onGatewaySuccess(const QString &authCookie); void onGatewaySuccess(const QString &authCookie);
@@ -72,6 +73,7 @@ private:
void doConnect(); void doConnect();
void portalLogin(); void portalLogin();
void tryGatewayLogin();
void gatewayLogin(); void gatewayLogin();
QString portal() const; QString portal() const;

View File

@@ -23,10 +23,13 @@ QNetworkReply* gpclient::helper::createRequest(QString url, QByteArray params)
GPGateway gpclient::helper::filterPreferredGateway(QList<GPGateway> gateways, const QString ruleName) GPGateway gpclient::helper::filterPreferredGateway(QList<GPGateway> gateways, const QString ruleName)
{ {
PLOGI << gateways.size() << " gateway(s) avaiable, filter the gateways with rule: " << ruleName;
GPGateway gateway = gateways.first(); GPGateway gateway = gateways.first();
for (GPGateway g : gateways) { for (GPGateway g : gateways) {
if (g.priorityOf(ruleName) > gateway.priorityOf(ruleName)) { if (g.priorityOf(ruleName) > gateway.priorityOf(ruleName)) {
PLOGI << "Find a preferred gateway: " << g.name();
gateway = g; gateway = g;
} }
} }
@@ -36,6 +39,8 @@ GPGateway gpclient::helper::filterPreferredGateway(QList<GPGateway> gateways, co
QUrlQuery gpclient::helper::parseGatewayResponse(const QByteArray &xml) QUrlQuery gpclient::helper::parseGatewayResponse(const QByteArray &xml)
{ {
PLOGI << "Start parsing the gateway response...";
QXmlStreamReader xmlReader{xml}; QXmlStreamReader xmlReader{xml};
QList<QString> args; QList<QString> args;

View File

@@ -26,32 +26,32 @@ LoginParams::~LoginParams()
{ {
} }
void LoginParams::setUser(const QString &user) void LoginParams::setUser(const QString user)
{ {
updateQueryItem("user", user); updateQueryItem("user", user);
} }
void LoginParams::setServer(const QString &server) void LoginParams::setServer(const QString server)
{ {
updateQueryItem("server", server); updateQueryItem("server", server);
} }
void LoginParams::setPassword(const QString &password) void LoginParams::setPassword(const QString password)
{ {
updateQueryItem("passwd", password); updateQueryItem("passwd", password);
} }
void LoginParams::setUserAuthCookie(const QString &cookie) void LoginParams::setUserAuthCookie(const QString cookie)
{ {
updateQueryItem("portal-userauthcookie", cookie); updateQueryItem("portal-userauthcookie", cookie);
} }
void LoginParams::setPrelogonAuthCookie(const QString &cookie) void LoginParams::setPrelogonAuthCookie(const QString cookie)
{ {
updateQueryItem("portal-prelogonuserauthcookie", cookie); updateQueryItem("portal-prelogonuserauthcookie", cookie);
} }
void LoginParams::setPreloginCookie(const QString &cookie) void LoginParams::setPreloginCookie(const QString cookie)
{ {
updateQueryItem("prelogin-cookie", cookie); updateQueryItem("prelogin-cookie", cookie);
} }
@@ -61,7 +61,7 @@ QByteArray LoginParams::toUtf8() const
return params.toString().toUtf8(); return params.toString().toUtf8();
} }
void LoginParams::updateQueryItem(const QString &key, const QString &value) void LoginParams::updateQueryItem(const QString key, const QString value)
{ {
if (params.hasQueryItem(key)) { if (params.hasQueryItem(key)) {
params.removeQueryItem(key); params.removeQueryItem(key);

View File

@@ -9,19 +9,19 @@ public:
LoginParams(); LoginParams();
~LoginParams(); ~LoginParams();
void setUser(const QString &user); void setUser(const QString user);
void setServer(const QString &server); void setServer(const QString server);
void setPassword(const QString &password); void setPassword(const QString password);
void setUserAuthCookie(const QString &cookie); void setUserAuthCookie(const QString cookie);
void setPrelogonAuthCookie(const QString &cookie); void setPrelogonAuthCookie(const QString cookie);
void setPreloginCookie(const QString &cookie); void setPreloginCookie(const QString cookie);
QByteArray toUtf8() const; QByteArray toUtf8() const;
private: private:
QUrlQuery params; QUrlQuery params;
void updateQueryItem(const QString &key, const QString &value); void updateQueryItem(const QString key, const QString value);
}; };
#endif // LOGINPARAMS_H #endif // LOGINPARAMS_H

View File

@@ -6,7 +6,7 @@
#include <plog/Log.h> #include <plog/Log.h>
#include <plog/Appenders/ColorConsoleAppender.h> #include <plog/Appenders/ColorConsoleAppender.h>
static const QString version = "v1.2.2"; static const QString version = "v1.2.4";
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {

View File

@@ -46,6 +46,9 @@ void PortalAuthenticator::onPreloginFinished()
PLOGI << "Portal prelogin succeeded."; PLOGI << "Portal prelogin succeeded.";
preloginResponse = PreloginResponse::parse(reply->readAll()); preloginResponse = PreloginResponse::parse(reply->readAll());
PLOGI << "Finished parsing the prelogin response. The region field is: " << preloginResponse.region();
if (preloginResponse.hasSamlAuthFields()) { if (preloginResponse.hasSamlAuthFields()) {
// Do SAML authentication // Do SAML authentication
samlAuth(); samlAuth();
@@ -54,7 +57,7 @@ void PortalAuthenticator::onPreloginFinished()
tryAutoLogin(); tryAutoLogin();
} else { } else {
PLOGE << QString("Unknown prelogin response for %1 got %2").arg(preloginUrl).arg(QString::fromUtf8(preloginResponse.rawResponse())); PLOGE << QString("Unknown prelogin response for %1 got %2").arg(preloginUrl).arg(QString::fromUtf8(preloginResponse.rawResponse()));
emitFail("Unknown response for portal prelogin interface."); emit preloginFailed("Unknown response for portal prelogin interface.");
} }
delete reply; delete reply;
@@ -172,27 +175,29 @@ void PortalAuthenticator::onFetchConfigFinished()
isAutoLogin = false; isAutoLogin = false;
normalAuth(); normalAuth();
} else { } else {
emitFail("Failed to fetch the portal config."); emit portalConfigFailed("Failed to fetch the portal config.");
} }
return; return;
} }
PLOGI << "Fetch the portal config succeeded."; PLOGI << "Fetch the portal config succeeded.";
PortalConfigResponse response = PortalConfigResponse::parse(reply->readAll()); PortalConfigResponse response = PortalConfigResponse::parse(reply->readAll());
// Add the username & password to the response object // Add the username & password to the response object
response.setUsername(username); response.setUsername(username);
response.setPassword(password); response.setPassword(password);
// Close the login window // Close the login window
if (normalLoginWindow) { if (normalLoginWindow) {
PLOGI << "Closing the NormalLoginWindow...";
// Save the credentials for reuse // Save the credentials for reuse
settings::save("username", username); settings::save("username", username);
settings::save("password", password); settings::save("password", password);
normalLoginWindow->close(); normalLoginWindow->close();
} }
emit success(response, filterPreferredGateway(response.allGateways(), preloginResponse.region()), response.allGateways()); emit success(response, preloginResponse.region());
} }
void PortalAuthenticator::emitFail(const QString& msg) void PortalAuthenticator::emitFail(const QString& msg)

View File

@@ -18,9 +18,10 @@ public:
void authenticate(); void authenticate();
signals: signals:
void success(const PortalConfigResponse, const GPGateway, QList<GPGateway> allGateways); void success(const PortalConfigResponse response, const QString region);
void fail(const QString& msg); void fail(const QString& msg);
void preloginFailed(const QString& msg); void preloginFailed(const QString& msg);
void portalConfigFailed(const QString msg);
private slots: private slots:
void onPreloginFinished(); void onPreloginFinished();

View File

@@ -15,8 +15,10 @@ PortalConfigResponse::~PortalConfigResponse()
{ {
} }
PortalConfigResponse PortalConfigResponse::parse(const QByteArray& xml) PortalConfigResponse PortalConfigResponse::parse(const QByteArray xml)
{ {
PLOGI << "Start parsing the portal configuration...";
QXmlStreamReader xmlReader(xml); QXmlStreamReader xmlReader(xml);
PortalConfigResponse response; PortalConfigResponse response;
response.setRawResponse(xml); response.setRawResponse(xml);
@@ -27,18 +29,22 @@ PortalConfigResponse PortalConfigResponse::parse(const QByteArray& xml)
QString name = xmlReader.name().toString(); QString name = xmlReader.name().toString();
if (name == xmlUserAuthCookie) { if (name == xmlUserAuthCookie) {
PLOGI << "Start reading " << name;
response.setUserAuthCookie(xmlReader.readElementText()); response.setUserAuthCookie(xmlReader.readElementText());
} else if (name == xmlPrelogonUserAuthCookie) { } else if (name == xmlPrelogonUserAuthCookie) {
PLOGI << "Start reading " << name;
response.setPrelogonUserAuthCookie(xmlReader.readElementText()); response.setPrelogonUserAuthCookie(xmlReader.readElementText());
} else if (name == xmlGateways) { } else if (name == xmlGateways) {
response.setAllGateways(parseGateways(xmlReader)); response.setAllGateways(parseGateways(xmlReader));
} }
} }
PLOGI << "Finished parsing portal configuration.";
return response; return response;
} }
const QByteArray& PortalConfigResponse::rawResponse() const const QByteArray PortalConfigResponse::rawResponse() const
{ {
return _rawResponse; return _rawResponse;
} }
@@ -55,6 +61,8 @@ QString PortalConfigResponse::password() const
QList<GPGateway> PortalConfigResponse::parseGateways(QXmlStreamReader &xmlReader) QList<GPGateway> PortalConfigResponse::parseGateways(QXmlStreamReader &xmlReader)
{ {
PLOGI << "Start parsing the gateways from portal configuration...";
QList<GPGateway> gateways; QList<GPGateway> gateways;
while (xmlReader.name() != xmlGateways || !xmlReader.isEndElement()) { while (xmlReader.name() != xmlGateways || !xmlReader.isEndElement()) {
@@ -69,11 +77,16 @@ QList<GPGateway> PortalConfigResponse::parseGateways(QXmlStreamReader &xmlReader
gateways.append(g); gateways.append(g);
} }
} }
PLOGI << "Finished parsing the gateways.";
return gateways; return gateways;
} }
QMap<QString, int> PortalConfigResponse::parsePriorityRules(QXmlStreamReader &xmlReader) QMap<QString, int> PortalConfigResponse::parsePriorityRules(QXmlStreamReader &xmlReader)
{ {
PLOGI << "Start parsing the priority rules...";
QMap<QString, int> priorityRules; QMap<QString, int> priorityRules;
while (xmlReader.name() != "priority-rule" || !xmlReader.isEndElement()) { while (xmlReader.name() != "priority-rule" || !xmlReader.isEndElement()) {
@@ -87,20 +100,26 @@ QMap<QString, int> PortalConfigResponse::parsePriorityRules(QXmlStreamReader &xm
priorityRules.insert(ruleName, ruleValue); priorityRules.insert(ruleName, ruleValue);
} }
} }
PLOGI << "Finished parsing the priority rules.";
return priorityRules; return priorityRules;
} }
QString PortalConfigResponse::parseGatewayName(QXmlStreamReader &xmlReader) QString PortalConfigResponse::parseGatewayName(QXmlStreamReader &xmlReader)
{ {
while (xmlReader.name() != "description" || !xmlReader.isEndElement()) { PLOGI << "Start parsing the gateway name...";
xmlReader.readNext();
if (xmlReader.name() == "description" && xmlReader.tokenType() == xmlReader.StartElement) {
return xmlReader.readElementText();
}
}
PLOGE << "Error: <description> tag not found"; while (xmlReader.name() != "description" || !xmlReader.isEndElement()) {
return ""; xmlReader.readNext();
if (xmlReader.name() == "description" && xmlReader.tokenType() == xmlReader.StartElement) {
PLOGI << "Finished parsing the gateway name";
return xmlReader.readElementText();
}
}
PLOGE << "Error: <description> tag not found";
return "";
} }
QString PortalConfigResponse::userAuthCookie() const QString PortalConfigResponse::userAuthCookie() const
@@ -113,7 +132,7 @@ QString PortalConfigResponse::prelogonUserAuthCookie() const
return _prelogonAuthCookie; return _prelogonAuthCookie;
} }
QList<GPGateway> PortalConfigResponse::allGateways() QList<GPGateway> PortalConfigResponse::allGateways() const
{ {
return _gateways; return _gateways;
} }
@@ -123,27 +142,27 @@ void PortalConfigResponse::setAllGateways(QList<GPGateway> gateways)
_gateways = gateways; _gateways = gateways;
} }
void PortalConfigResponse::setRawResponse(const QByteArray &response) void PortalConfigResponse::setRawResponse(const QByteArray response)
{ {
_rawResponse = response; _rawResponse = response;
} }
void PortalConfigResponse::setUsername(const QString& username) void PortalConfigResponse::setUsername(const QString username)
{ {
_username = username; _username = username;
} }
void PortalConfigResponse::setPassword(const QString& password) void PortalConfigResponse::setPassword(const QString password)
{ {
_password = password; _password = password;
} }
void PortalConfigResponse::setUserAuthCookie(const QString &cookie) void PortalConfigResponse::setUserAuthCookie(const QString cookie)
{ {
_userAuthCookie = cookie; _userAuthCookie = cookie;
} }
void PortalConfigResponse::setPrelogonUserAuthCookie(const QString &cookie) void PortalConfigResponse::setPrelogonUserAuthCookie(const QString cookie)
{ {
_prelogonAuthCookie = cookie; _prelogonAuthCookie = cookie;
} }

View File

@@ -13,18 +13,18 @@ public:
PortalConfigResponse(); PortalConfigResponse();
~PortalConfigResponse(); ~PortalConfigResponse();
static PortalConfigResponse parse(const QByteArray& xml); static PortalConfigResponse parse(const QByteArray xml);
const QByteArray& rawResponse() const; const QByteArray rawResponse() const;
QString username() const; QString username() const;
QString password() const; QString password() const;
QString userAuthCookie() const; QString userAuthCookie() const;
QString prelogonUserAuthCookie() const; QString prelogonUserAuthCookie() const;
QList<GPGateway> allGateways(); QList<GPGateway> allGateways() const;
void setAllGateways(QList<GPGateway> gateways); void setAllGateways(QList<GPGateway> gateways);
void setUsername(const QString& username); void setUsername(const QString username);
void setPassword(const QString& password); void setPassword(const QString password);
private: private:
static QString xmlUserAuthCookie; static QString xmlUserAuthCookie;
@@ -39,9 +39,9 @@ private:
QList<GPGateway> _gateways; QList<GPGateway> _gateways;
void setRawResponse(const QByteArray& response); void setRawResponse(const QByteArray response);
void setUserAuthCookie(const QString& cookie); void setUserAuthCookie(const QString cookie);
void setPrelogonUserAuthCookie(const QString& cookie); void setPrelogonUserAuthCookie(const QString cookie);
static QList<GPGateway> parseGateways(QXmlStreamReader &xmlReader); static QList<GPGateway> parseGateways(QXmlStreamReader &xmlReader);
static QMap<QString, int> parsePriorityRules(QXmlStreamReader &xmlReader); static QMap<QString, int> parsePriorityRules(QXmlStreamReader &xmlReader);

View File

@@ -2,6 +2,7 @@
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <QMap> #include <QMap>
#include <plog/Log.h>
QString PreloginResponse::xmlAuthMessage = "authentication-message"; QString PreloginResponse::xmlAuthMessage = "authentication-message";
QString PreloginResponse::xmlLabelUsername = "username-label"; QString PreloginResponse::xmlLabelUsername = "username-label";
@@ -22,6 +23,8 @@ PreloginResponse::PreloginResponse()
PreloginResponse PreloginResponse::parse(const QByteArray& xml) PreloginResponse PreloginResponse::parse(const QByteArray& xml)
{ {
PLOGI << "Start parsing the prelogin response...";
QXmlStreamReader xmlReader(xml); QXmlStreamReader xmlReader(xml);
PreloginResponse response; PreloginResponse response;
response.setRawResponse(xml); response.setRawResponse(xml);
@@ -81,17 +84,17 @@ bool PreloginResponse::hasNormalAuthFields() const
return !labelUsername().isEmpty() && !labelPassword().isEmpty(); return !labelUsername().isEmpty() && !labelPassword().isEmpty();
} }
void PreloginResponse::setRawResponse(const QByteArray &response) void PreloginResponse::setRawResponse(const QByteArray response)
{ {
_rawResponse = response; _rawResponse = response;
} }
bool PreloginResponse::has(const QString &name) const bool PreloginResponse::has(const QString name) const
{ {
return resultMap.contains(name); return resultMap.contains(name);
} }
void PreloginResponse::add(const QString &name, const QString &value) void PreloginResponse::add(const QString name, const QString value)
{ {
resultMap.insert(name, value); resultMap.insert(name, value);
} }

View File

@@ -33,9 +33,9 @@ private:
QMap<QString, QString> resultMap; QMap<QString, QString> resultMap;
QByteArray _rawResponse; QByteArray _rawResponse;
void setRawResponse(const QByteArray &response); void setRawResponse(const QByteArray response);
void add(const QString &name, const QString &value); void add(const QString name, const QString value);
bool has(const QString &name) const; bool has(const QString name) const;
}; };
#endif // PRELOGINRESPONSE_H #endif // PRELOGINRESPONSE_H